babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165
  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/webRequest" {
  4967. /**
  4968. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4969. */
  4970. export class WebRequest {
  4971. private _xhr;
  4972. /**
  4973. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4974. * i.e. when loading files, where the server/service expects an Authorization header
  4975. */
  4976. static CustomRequestHeaders: {
  4977. [key: string]: string;
  4978. };
  4979. /**
  4980. * Add callback functions in this array to update all the requests before they get sent to the network
  4981. */
  4982. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4983. private _injectCustomRequestHeaders;
  4984. /**
  4985. * Gets or sets a function to be called when loading progress changes
  4986. */
  4987. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4988. /**
  4989. * Returns client's state
  4990. */
  4991. readonly readyState: number;
  4992. /**
  4993. * Returns client's status
  4994. */
  4995. readonly status: number;
  4996. /**
  4997. * Returns client's status as a text
  4998. */
  4999. readonly statusText: string;
  5000. /**
  5001. * Returns client's response
  5002. */
  5003. readonly response: any;
  5004. /**
  5005. * Returns client's response url
  5006. */
  5007. readonly responseURL: string;
  5008. /**
  5009. * Returns client's response as text
  5010. */
  5011. readonly responseText: string;
  5012. /**
  5013. * Gets or sets the expected response type
  5014. */
  5015. responseType: XMLHttpRequestResponseType;
  5016. /** @hidden */
  5017. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5018. /** @hidden */
  5019. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5020. /**
  5021. * Cancels any network activity
  5022. */
  5023. abort(): void;
  5024. /**
  5025. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5026. * @param body defines an optional request body
  5027. */
  5028. send(body?: Document | BodyInit | null): void;
  5029. /**
  5030. * Sets the request method, request URL
  5031. * @param method defines the method to use (GET, POST, etc..)
  5032. * @param url defines the url to connect with
  5033. */
  5034. open(method: string, url: string): void;
  5035. }
  5036. }
  5037. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5038. /**
  5039. * Class used to evalaute queries containing `and` and `or` operators
  5040. */
  5041. export class AndOrNotEvaluator {
  5042. /**
  5043. * Evaluate a query
  5044. * @param query defines the query to evaluate
  5045. * @param evaluateCallback defines the callback used to filter result
  5046. * @returns true if the query matches
  5047. */
  5048. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5049. private static _HandleParenthesisContent;
  5050. private static _SimplifyNegation;
  5051. }
  5052. }
  5053. declare module "babylonjs/Misc/tags" {
  5054. /**
  5055. * Class used to store custom tags
  5056. */
  5057. export class Tags {
  5058. /**
  5059. * Adds support for tags on the given object
  5060. * @param obj defines the object to use
  5061. */
  5062. static EnableFor(obj: any): void;
  5063. /**
  5064. * Removes tags support
  5065. * @param obj defines the object to use
  5066. */
  5067. static DisableFor(obj: any): void;
  5068. /**
  5069. * Gets a boolean indicating if the given object has tags
  5070. * @param obj defines the object to use
  5071. * @returns a boolean
  5072. */
  5073. static HasTags(obj: any): boolean;
  5074. /**
  5075. * Gets the tags available on a given object
  5076. * @param obj defines the object to use
  5077. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5078. * @returns the tags
  5079. */
  5080. static GetTags(obj: any, asString?: boolean): any;
  5081. /**
  5082. * Adds tags to an object
  5083. * @param obj defines the object to use
  5084. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5085. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5086. */
  5087. static AddTagsTo(obj: any, tagsString: string): void;
  5088. /**
  5089. * @hidden
  5090. */
  5091. static _AddTagTo(obj: any, tag: string): void;
  5092. /**
  5093. * Removes specific tags from a specific object
  5094. * @param obj defines the object to use
  5095. * @param tagsString defines the tags to remove
  5096. */
  5097. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _RemoveTagFrom(obj: any, tag: string): void;
  5102. /**
  5103. * Defines if tags hosted on an object match a given query
  5104. * @param obj defines the object to use
  5105. * @param tagsQuery defines the tag query
  5106. * @returns a boolean
  5107. */
  5108. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5109. }
  5110. }
  5111. declare module "babylonjs/Materials/materialDefines" {
  5112. /**
  5113. * Manages the defines for the Material
  5114. */
  5115. export class MaterialDefines {
  5116. private _keys;
  5117. private _isDirty;
  5118. /** @hidden */
  5119. _renderId: number;
  5120. /** @hidden */
  5121. _areLightsDirty: boolean;
  5122. /** @hidden */
  5123. _areAttributesDirty: boolean;
  5124. /** @hidden */
  5125. _areTexturesDirty: boolean;
  5126. /** @hidden */
  5127. _areFresnelDirty: boolean;
  5128. /** @hidden */
  5129. _areMiscDirty: boolean;
  5130. /** @hidden */
  5131. _areImageProcessingDirty: boolean;
  5132. /** @hidden */
  5133. _normals: boolean;
  5134. /** @hidden */
  5135. _uvs: boolean;
  5136. /** @hidden */
  5137. _needNormals: boolean;
  5138. /** @hidden */
  5139. _needUVs: boolean;
  5140. /**
  5141. * Specifies if the material needs to be re-calculated
  5142. */
  5143. readonly isDirty: boolean;
  5144. /**
  5145. * Marks the material to indicate that it has been re-calculated
  5146. */
  5147. markAsProcessed(): void;
  5148. /**
  5149. * Marks the material to indicate that it needs to be re-calculated
  5150. */
  5151. markAsUnprocessed(): void;
  5152. /**
  5153. * Marks the material to indicate all of its defines need to be re-calculated
  5154. */
  5155. markAllAsDirty(): void;
  5156. /**
  5157. * Marks the material to indicate that image processing needs to be re-calculated
  5158. */
  5159. markAsImageProcessingDirty(): void;
  5160. /**
  5161. * Marks the material to indicate the lights need to be re-calculated
  5162. */
  5163. markAsLightDirty(): void;
  5164. /**
  5165. * Marks the attribute state as changed
  5166. */
  5167. markAsAttributesDirty(): void;
  5168. /**
  5169. * Marks the texture state as changed
  5170. */
  5171. markAsTexturesDirty(): void;
  5172. /**
  5173. * Marks the fresnel state as changed
  5174. */
  5175. markAsFresnelDirty(): void;
  5176. /**
  5177. * Marks the misc state as changed
  5178. */
  5179. markAsMiscDirty(): void;
  5180. /**
  5181. * Rebuilds the material defines
  5182. */
  5183. rebuild(): void;
  5184. /**
  5185. * Specifies if two material defines are equal
  5186. * @param other - A material define instance to compare to
  5187. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5188. */
  5189. isEqual(other: MaterialDefines): boolean;
  5190. /**
  5191. * Clones this instance's defines to another instance
  5192. * @param other - material defines to clone values to
  5193. */
  5194. cloneTo(other: MaterialDefines): void;
  5195. /**
  5196. * Resets the material define values
  5197. */
  5198. reset(): void;
  5199. /**
  5200. * Converts the material define values to a string
  5201. * @returns - String of material define information
  5202. */
  5203. toString(): string;
  5204. }
  5205. }
  5206. declare module "babylonjs/Misc/performanceMonitor" {
  5207. /**
  5208. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5209. */
  5210. export class PerformanceMonitor {
  5211. private _enabled;
  5212. private _rollingFrameTime;
  5213. private _lastFrameTimeMs;
  5214. /**
  5215. * constructor
  5216. * @param frameSampleSize The number of samples required to saturate the sliding window
  5217. */
  5218. constructor(frameSampleSize?: number);
  5219. /**
  5220. * Samples current frame
  5221. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5222. */
  5223. sampleFrame(timeMs?: number): void;
  5224. /**
  5225. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5226. */
  5227. readonly averageFrameTime: number;
  5228. /**
  5229. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5230. */
  5231. readonly averageFrameTimeVariance: number;
  5232. /**
  5233. * Returns the frame time of the most recent frame
  5234. */
  5235. readonly instantaneousFrameTime: number;
  5236. /**
  5237. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5238. */
  5239. readonly averageFPS: number;
  5240. /**
  5241. * Returns the average framerate in frames per second using the most recent frame time
  5242. */
  5243. readonly instantaneousFPS: number;
  5244. /**
  5245. * Returns true if enough samples have been taken to completely fill the sliding window
  5246. */
  5247. readonly isSaturated: boolean;
  5248. /**
  5249. * Enables contributions to the sliding window sample set
  5250. */
  5251. enable(): void;
  5252. /**
  5253. * Disables contributions to the sliding window sample set
  5254. * Samples will not be interpolated over the disabled period
  5255. */
  5256. disable(): void;
  5257. /**
  5258. * Returns true if sampling is enabled
  5259. */
  5260. readonly isEnabled: boolean;
  5261. /**
  5262. * Resets performance monitor
  5263. */
  5264. reset(): void;
  5265. }
  5266. /**
  5267. * RollingAverage
  5268. *
  5269. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5270. */
  5271. export class RollingAverage {
  5272. /**
  5273. * Current average
  5274. */
  5275. average: number;
  5276. /**
  5277. * Current variance
  5278. */
  5279. variance: number;
  5280. protected _samples: Array<number>;
  5281. protected _sampleCount: number;
  5282. protected _pos: number;
  5283. protected _m2: number;
  5284. /**
  5285. * constructor
  5286. * @param length The number of samples required to saturate the sliding window
  5287. */
  5288. constructor(length: number);
  5289. /**
  5290. * Adds a sample to the sample set
  5291. * @param v The sample value
  5292. */
  5293. add(v: number): void;
  5294. /**
  5295. * Returns previously added values or null if outside of history or outside the sliding window domain
  5296. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5297. * @return Value previously recorded with add() or null if outside of range
  5298. */
  5299. history(i: number): number;
  5300. /**
  5301. * Returns true if enough samples have been taken to completely fill the sliding window
  5302. * @return true if sample-set saturated
  5303. */
  5304. isSaturated(): boolean;
  5305. /**
  5306. * Resets the rolling average (equivalent to 0 samples taken so far)
  5307. */
  5308. reset(): void;
  5309. /**
  5310. * Wraps a value around the sample range boundaries
  5311. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5312. * @return Wrapped position in sample range
  5313. */
  5314. protected _wrapPosition(i: number): number;
  5315. }
  5316. }
  5317. declare module "babylonjs/Misc/stringDictionary" {
  5318. import { Nullable } from "babylonjs/types";
  5319. /**
  5320. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5321. * The underlying implementation relies on an associative array to ensure the best performances.
  5322. * The value can be anything including 'null' but except 'undefined'
  5323. */
  5324. export class StringDictionary<T> {
  5325. /**
  5326. * This will clear this dictionary and copy the content from the 'source' one.
  5327. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5328. * @param source the dictionary to take the content from and copy to this dictionary
  5329. */
  5330. copyFrom(source: StringDictionary<T>): void;
  5331. /**
  5332. * Get a value based from its key
  5333. * @param key the given key to get the matching value from
  5334. * @return the value if found, otherwise undefined is returned
  5335. */
  5336. get(key: string): T | undefined;
  5337. /**
  5338. * Get a value from its key or add it if it doesn't exist.
  5339. * This method will ensure you that a given key/data will be present in the dictionary.
  5340. * @param key the given key to get the matching value from
  5341. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5342. * The factory will only be invoked if there's no data for the given key.
  5343. * @return the value corresponding to the key.
  5344. */
  5345. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5346. /**
  5347. * Get a value from its key if present in the dictionary otherwise add it
  5348. * @param key the key to get the value from
  5349. * @param val if there's no such key/value pair in the dictionary add it with this value
  5350. * @return the value corresponding to the key
  5351. */
  5352. getOrAdd(key: string, val: T): T;
  5353. /**
  5354. * Check if there's a given key in the dictionary
  5355. * @param key the key to check for
  5356. * @return true if the key is present, false otherwise
  5357. */
  5358. contains(key: string): boolean;
  5359. /**
  5360. * Add a new key and its corresponding value
  5361. * @param key the key to add
  5362. * @param value the value corresponding to the key
  5363. * @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
  5364. */
  5365. add(key: string, value: T): boolean;
  5366. /**
  5367. * Update a specific value associated to a key
  5368. * @param key defines the key to use
  5369. * @param value defines the value to store
  5370. * @returns true if the value was updated (or false if the key was not found)
  5371. */
  5372. set(key: string, value: T): boolean;
  5373. /**
  5374. * Get the element of the given key and remove it from the dictionary
  5375. * @param key defines the key to search
  5376. * @returns the value associated with the key or null if not found
  5377. */
  5378. getAndRemove(key: string): Nullable<T>;
  5379. /**
  5380. * Remove a key/value from the dictionary.
  5381. * @param key the key to remove
  5382. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5383. */
  5384. remove(key: string): boolean;
  5385. /**
  5386. * Clear the whole content of the dictionary
  5387. */
  5388. clear(): void;
  5389. /**
  5390. * Gets the current count
  5391. */
  5392. readonly count: number;
  5393. /**
  5394. * Execute a callback on each key/val of the dictionary.
  5395. * Note that you can remove any element in this dictionary in the callback implementation
  5396. * @param callback the callback to execute on a given key/value pair
  5397. */
  5398. forEach(callback: (key: string, val: T) => void): void;
  5399. /**
  5400. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5401. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5402. * Note that you can remove any element in this dictionary in the callback implementation
  5403. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5404. * @returns the first item
  5405. */
  5406. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5407. private _count;
  5408. private _data;
  5409. }
  5410. }
  5411. declare module "babylonjs/Misc/promise" {
  5412. /**
  5413. * Helper class that provides a small promise polyfill
  5414. */
  5415. export class PromisePolyfill {
  5416. /**
  5417. * Static function used to check if the polyfill is required
  5418. * If this is the case then the function will inject the polyfill to window.Promise
  5419. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5420. */
  5421. static Apply(force?: boolean): void;
  5422. }
  5423. }
  5424. declare module "babylonjs/Meshes/buffer" {
  5425. import { Nullable, DataArray } from "babylonjs/types";
  5426. /**
  5427. * Class used to store data that will be store in GPU memory
  5428. */
  5429. export class Buffer {
  5430. private _engine;
  5431. private _buffer;
  5432. /** @hidden */
  5433. _data: Nullable<DataArray>;
  5434. private _updatable;
  5435. private _instanced;
  5436. /**
  5437. * Gets the byte stride.
  5438. */
  5439. readonly byteStride: number;
  5440. /**
  5441. * Constructor
  5442. * @param engine the engine
  5443. * @param data the data to use for this buffer
  5444. * @param updatable whether the data is updatable
  5445. * @param stride the stride (optional)
  5446. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5447. * @param instanced whether the buffer is instanced (optional)
  5448. * @param useBytes set to true if the stride in in bytes (optional)
  5449. */
  5450. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5451. /**
  5452. * Create a new VertexBuffer based on the current buffer
  5453. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5454. * @param offset defines offset in the buffer (0 by default)
  5455. * @param size defines the size in floats of attributes (position is 3 for instance)
  5456. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5457. * @param instanced defines if the vertex buffer contains indexed data
  5458. * @param useBytes defines if the offset and stride are in bytes
  5459. * @returns the new vertex buffer
  5460. */
  5461. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5462. /**
  5463. * Gets a boolean indicating if the Buffer is updatable?
  5464. * @returns true if the buffer is updatable
  5465. */
  5466. isUpdatable(): boolean;
  5467. /**
  5468. * Gets current buffer's data
  5469. * @returns a DataArray or null
  5470. */
  5471. getData(): Nullable<DataArray>;
  5472. /**
  5473. * Gets underlying native buffer
  5474. * @returns underlying native buffer
  5475. */
  5476. getBuffer(): Nullable<WebGLBuffer>;
  5477. /**
  5478. * Gets the stride in float32 units (i.e. byte stride / 4).
  5479. * May not be an integer if the byte stride is not divisible by 4.
  5480. * DEPRECATED. Use byteStride instead.
  5481. * @returns the stride in float32 units
  5482. */
  5483. getStrideSize(): number;
  5484. /**
  5485. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5486. * @param data defines the data to store
  5487. */
  5488. create(data?: Nullable<DataArray>): void;
  5489. /** @hidden */
  5490. _rebuild(): void;
  5491. /**
  5492. * Update current buffer data
  5493. * @param data defines the data to store
  5494. */
  5495. update(data: DataArray): void;
  5496. /**
  5497. * Updates the data directly.
  5498. * @param data the new data
  5499. * @param offset the new offset
  5500. * @param vertexCount the vertex count (optional)
  5501. * @param useBytes set to true if the offset is in bytes
  5502. */
  5503. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5504. /**
  5505. * Release all resources
  5506. */
  5507. dispose(): void;
  5508. }
  5509. /**
  5510. * Specialized buffer used to store vertex data
  5511. */
  5512. export class VertexBuffer {
  5513. /** @hidden */
  5514. _buffer: Buffer;
  5515. private _kind;
  5516. private _size;
  5517. private _ownsBuffer;
  5518. private _instanced;
  5519. private _instanceDivisor;
  5520. /**
  5521. * The byte type.
  5522. */
  5523. static readonly BYTE: number;
  5524. /**
  5525. * The unsigned byte type.
  5526. */
  5527. static readonly UNSIGNED_BYTE: number;
  5528. /**
  5529. * The short type.
  5530. */
  5531. static readonly SHORT: number;
  5532. /**
  5533. * The unsigned short type.
  5534. */
  5535. static readonly UNSIGNED_SHORT: number;
  5536. /**
  5537. * The integer type.
  5538. */
  5539. static readonly INT: number;
  5540. /**
  5541. * The unsigned integer type.
  5542. */
  5543. static readonly UNSIGNED_INT: number;
  5544. /**
  5545. * The float type.
  5546. */
  5547. static readonly FLOAT: number;
  5548. /**
  5549. * Gets or sets the instance divisor when in instanced mode
  5550. */
  5551. instanceDivisor: number;
  5552. /**
  5553. * Gets the byte stride.
  5554. */
  5555. readonly byteStride: number;
  5556. /**
  5557. * Gets the byte offset.
  5558. */
  5559. readonly byteOffset: number;
  5560. /**
  5561. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5562. */
  5563. readonly normalized: boolean;
  5564. /**
  5565. * Gets the data type of each component in the array.
  5566. */
  5567. readonly type: number;
  5568. /**
  5569. * Constructor
  5570. * @param engine the engine
  5571. * @param data the data to use for this vertex buffer
  5572. * @param kind the vertex buffer kind
  5573. * @param updatable whether the data is updatable
  5574. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5575. * @param stride the stride (optional)
  5576. * @param instanced whether the buffer is instanced (optional)
  5577. * @param offset the offset of the data (optional)
  5578. * @param size the number of components (optional)
  5579. * @param type the type of the component (optional)
  5580. * @param normalized whether the data contains normalized data (optional)
  5581. * @param useBytes set to true if stride and offset are in bytes (optional)
  5582. */
  5583. 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);
  5584. /** @hidden */
  5585. _rebuild(): void;
  5586. /**
  5587. * Returns the kind of the VertexBuffer (string)
  5588. * @returns a string
  5589. */
  5590. getKind(): string;
  5591. /**
  5592. * Gets a boolean indicating if the VertexBuffer is updatable?
  5593. * @returns true if the buffer is updatable
  5594. */
  5595. isUpdatable(): boolean;
  5596. /**
  5597. * Gets current buffer's data
  5598. * @returns a DataArray or null
  5599. */
  5600. getData(): Nullable<DataArray>;
  5601. /**
  5602. * Gets underlying native buffer
  5603. * @returns underlying native buffer
  5604. */
  5605. getBuffer(): Nullable<WebGLBuffer>;
  5606. /**
  5607. * Gets the stride in float32 units (i.e. byte stride / 4).
  5608. * May not be an integer if the byte stride is not divisible by 4.
  5609. * DEPRECATED. Use byteStride instead.
  5610. * @returns the stride in float32 units
  5611. */
  5612. getStrideSize(): number;
  5613. /**
  5614. * Returns the offset as a multiple of the type byte length.
  5615. * DEPRECATED. Use byteOffset instead.
  5616. * @returns the offset in bytes
  5617. */
  5618. getOffset(): number;
  5619. /**
  5620. * Returns the number of components per vertex attribute (integer)
  5621. * @returns the size in float
  5622. */
  5623. getSize(): number;
  5624. /**
  5625. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5626. * @returns true if this buffer is instanced
  5627. */
  5628. getIsInstanced(): boolean;
  5629. /**
  5630. * Returns the instancing divisor, zero for non-instanced (integer).
  5631. * @returns a number
  5632. */
  5633. getInstanceDivisor(): number;
  5634. /**
  5635. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5636. * @param data defines the data to store
  5637. */
  5638. create(data?: DataArray): void;
  5639. /**
  5640. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5641. * This function will create a new buffer if the current one is not updatable
  5642. * @param data defines the data to store
  5643. */
  5644. update(data: DataArray): void;
  5645. /**
  5646. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5647. * Returns the directly updated WebGLBuffer.
  5648. * @param data the new data
  5649. * @param offset the new offset
  5650. * @param useBytes set to true if the offset is in bytes
  5651. */
  5652. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5653. /**
  5654. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5655. */
  5656. dispose(): void;
  5657. /**
  5658. * Enumerates each value of this vertex buffer as numbers.
  5659. * @param count the number of values to enumerate
  5660. * @param callback the callback function called for each value
  5661. */
  5662. forEach(count: number, callback: (value: number, index: number) => void): void;
  5663. /**
  5664. * Positions
  5665. */
  5666. static readonly PositionKind: string;
  5667. /**
  5668. * Normals
  5669. */
  5670. static readonly NormalKind: string;
  5671. /**
  5672. * Tangents
  5673. */
  5674. static readonly TangentKind: string;
  5675. /**
  5676. * Texture coordinates
  5677. */
  5678. static readonly UVKind: string;
  5679. /**
  5680. * Texture coordinates 2
  5681. */
  5682. static readonly UV2Kind: string;
  5683. /**
  5684. * Texture coordinates 3
  5685. */
  5686. static readonly UV3Kind: string;
  5687. /**
  5688. * Texture coordinates 4
  5689. */
  5690. static readonly UV4Kind: string;
  5691. /**
  5692. * Texture coordinates 5
  5693. */
  5694. static readonly UV5Kind: string;
  5695. /**
  5696. * Texture coordinates 6
  5697. */
  5698. static readonly UV6Kind: string;
  5699. /**
  5700. * Colors
  5701. */
  5702. static readonly ColorKind: string;
  5703. /**
  5704. * Matrix indices (for bones)
  5705. */
  5706. static readonly MatricesIndicesKind: string;
  5707. /**
  5708. * Matrix weights (for bones)
  5709. */
  5710. static readonly MatricesWeightsKind: string;
  5711. /**
  5712. * Additional matrix indices (for bones)
  5713. */
  5714. static readonly MatricesIndicesExtraKind: string;
  5715. /**
  5716. * Additional matrix weights (for bones)
  5717. */
  5718. static readonly MatricesWeightsExtraKind: string;
  5719. /**
  5720. * Deduces the stride given a kind.
  5721. * @param kind The kind string to deduce
  5722. * @returns The deduced stride
  5723. */
  5724. static DeduceStride(kind: string): number;
  5725. /**
  5726. * Gets the byte length of the given type.
  5727. * @param type the type
  5728. * @returns the number of bytes
  5729. */
  5730. static GetTypeByteLength(type: number): number;
  5731. /**
  5732. * Enumerates each value of the given parameters as numbers.
  5733. * @param data the data to enumerate
  5734. * @param byteOffset the byte offset of the data
  5735. * @param byteStride the byte stride of the data
  5736. * @param componentCount the number of components per element
  5737. * @param componentType the type of the component
  5738. * @param count the total number of components
  5739. * @param normalized whether the data is normalized
  5740. * @param callback the callback function called for each value
  5741. */
  5742. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5743. private static _GetFloatValue;
  5744. }
  5745. }
  5746. declare module "babylonjs/Maths/sphericalPolynomial" {
  5747. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5748. /**
  5749. * Class representing spherical polynomial coefficients to the 3rd degree
  5750. */
  5751. export class SphericalPolynomial {
  5752. /**
  5753. * The x coefficients of the spherical polynomial
  5754. */
  5755. x: Vector3;
  5756. /**
  5757. * The y coefficients of the spherical polynomial
  5758. */
  5759. y: Vector3;
  5760. /**
  5761. * The z coefficients of the spherical polynomial
  5762. */
  5763. z: Vector3;
  5764. /**
  5765. * The xx coefficients of the spherical polynomial
  5766. */
  5767. xx: Vector3;
  5768. /**
  5769. * The yy coefficients of the spherical polynomial
  5770. */
  5771. yy: Vector3;
  5772. /**
  5773. * The zz coefficients of the spherical polynomial
  5774. */
  5775. zz: Vector3;
  5776. /**
  5777. * The xy coefficients of the spherical polynomial
  5778. */
  5779. xy: Vector3;
  5780. /**
  5781. * The yz coefficients of the spherical polynomial
  5782. */
  5783. yz: Vector3;
  5784. /**
  5785. * The zx coefficients of the spherical polynomial
  5786. */
  5787. zx: Vector3;
  5788. /**
  5789. * Adds an ambient color to the spherical polynomial
  5790. * @param color the color to add
  5791. */
  5792. addAmbient(color: Color3): void;
  5793. /**
  5794. * Scales the spherical polynomial by the given amount
  5795. * @param scale the amount to scale
  5796. */
  5797. scale(scale: number): void;
  5798. /**
  5799. * Gets the spherical polynomial from harmonics
  5800. * @param harmonics the spherical harmonics
  5801. * @returns the spherical polynomial
  5802. */
  5803. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5804. /**
  5805. * Constructs a spherical polynomial from an array.
  5806. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5807. * @returns the spherical polynomial
  5808. */
  5809. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5810. }
  5811. /**
  5812. * Class representing spherical harmonics coefficients to the 3rd degree
  5813. */
  5814. export class SphericalHarmonics {
  5815. /**
  5816. * The l0,0 coefficients of the spherical harmonics
  5817. */
  5818. l00: Vector3;
  5819. /**
  5820. * The l1,-1 coefficients of the spherical harmonics
  5821. */
  5822. l1_1: Vector3;
  5823. /**
  5824. * The l1,0 coefficients of the spherical harmonics
  5825. */
  5826. l10: Vector3;
  5827. /**
  5828. * The l1,1 coefficients of the spherical harmonics
  5829. */
  5830. l11: Vector3;
  5831. /**
  5832. * The l2,-2 coefficients of the spherical harmonics
  5833. */
  5834. l2_2: Vector3;
  5835. /**
  5836. * The l2,-1 coefficients of the spherical harmonics
  5837. */
  5838. l2_1: Vector3;
  5839. /**
  5840. * The l2,0 coefficients of the spherical harmonics
  5841. */
  5842. l20: Vector3;
  5843. /**
  5844. * The l2,1 coefficients of the spherical harmonics
  5845. */
  5846. l21: Vector3;
  5847. /**
  5848. * The l2,2 coefficients of the spherical harmonics
  5849. */
  5850. lL22: Vector3;
  5851. /**
  5852. * Adds a light to the spherical harmonics
  5853. * @param direction the direction of the light
  5854. * @param color the color of the light
  5855. * @param deltaSolidAngle the delta solid angle of the light
  5856. */
  5857. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5858. /**
  5859. * Scales the spherical harmonics by the given amount
  5860. * @param scale the amount to scale
  5861. */
  5862. scale(scale: number): void;
  5863. /**
  5864. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5865. *
  5866. * ```
  5867. * E_lm = A_l * L_lm
  5868. * ```
  5869. *
  5870. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5871. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5872. * the scaling factors are given in equation 9.
  5873. */
  5874. convertIncidentRadianceToIrradiance(): void;
  5875. /**
  5876. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5877. *
  5878. * ```
  5879. * L = (1/pi) * E * rho
  5880. * ```
  5881. *
  5882. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5883. */
  5884. convertIrradianceToLambertianRadiance(): void;
  5885. /**
  5886. * Gets the spherical harmonics from polynomial
  5887. * @param polynomial the spherical polynomial
  5888. * @returns the spherical harmonics
  5889. */
  5890. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5891. /**
  5892. * Constructs a spherical harmonics from an array.
  5893. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5894. * @returns the spherical harmonics
  5895. */
  5896. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5897. }
  5898. }
  5899. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5900. import { Nullable } from "babylonjs/types";
  5901. /**
  5902. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5903. */
  5904. export interface CubeMapInfo {
  5905. /**
  5906. * The pixel array for the front face.
  5907. * This is stored in format, left to right, up to down format.
  5908. */
  5909. front: Nullable<ArrayBufferView>;
  5910. /**
  5911. * The pixel array for the back face.
  5912. * This is stored in format, left to right, up to down format.
  5913. */
  5914. back: Nullable<ArrayBufferView>;
  5915. /**
  5916. * The pixel array for the left face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. left: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the right face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. right: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the up face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. up: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the down face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. down: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The size of the cubemap stored.
  5937. *
  5938. * Each faces will be size * size pixels.
  5939. */
  5940. size: number;
  5941. /**
  5942. * The format of the texture.
  5943. *
  5944. * RGBA, RGB.
  5945. */
  5946. format: number;
  5947. /**
  5948. * The type of the texture data.
  5949. *
  5950. * UNSIGNED_INT, FLOAT.
  5951. */
  5952. type: number;
  5953. /**
  5954. * Specifies whether the texture is in gamma space.
  5955. */
  5956. gammaSpace: boolean;
  5957. }
  5958. /**
  5959. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5960. */
  5961. export class PanoramaToCubeMapTools {
  5962. private static FACE_FRONT;
  5963. private static FACE_BACK;
  5964. private static FACE_RIGHT;
  5965. private static FACE_LEFT;
  5966. private static FACE_DOWN;
  5967. private static FACE_UP;
  5968. /**
  5969. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5970. *
  5971. * @param float32Array The source data.
  5972. * @param inputWidth The width of the input panorama.
  5973. * @param inputHeight The height of the input panorama.
  5974. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5975. * @return The cubemap data
  5976. */
  5977. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5978. private static CreateCubemapTexture;
  5979. private static CalcProjectionSpherical;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5983. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5985. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5986. /**
  5987. * Helper class dealing with the extraction of spherical polynomial dataArray
  5988. * from a cube map.
  5989. */
  5990. export class CubeMapToSphericalPolynomialTools {
  5991. private static FileFaces;
  5992. /**
  5993. * Converts a texture to the according Spherical Polynomial data.
  5994. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5995. *
  5996. * @param texture The texture to extract the information from.
  5997. * @return The Spherical Polynomial data.
  5998. */
  5999. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6000. /**
  6001. * Converts a cubemap to the according Spherical Polynomial data.
  6002. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6003. *
  6004. * @param cubeInfo The Cube map to extract the information from.
  6005. * @return The Spherical Polynomial data.
  6006. */
  6007. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6008. }
  6009. }
  6010. declare module "babylonjs/Engines/engineStore" {
  6011. import { Nullable } from "babylonjs/types";
  6012. import { Engine } from "babylonjs/Engines/engine";
  6013. import { Scene } from "babylonjs/scene";
  6014. /**
  6015. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6016. * during the life time of the application.
  6017. */
  6018. export class EngineStore {
  6019. /** Gets the list of created engines */
  6020. static Instances: import("babylonjs/Engines/engine").Engine[];
  6021. /**
  6022. * Gets the latest created engine
  6023. */
  6024. static readonly LastCreatedEngine: Nullable<Engine>;
  6025. /**
  6026. * Gets the latest created scene
  6027. */
  6028. static readonly LastCreatedScene: Nullable<Scene>;
  6029. }
  6030. }
  6031. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6032. /**
  6033. * Define options used to create a render target texture
  6034. */
  6035. export class RenderTargetCreationOptions {
  6036. /**
  6037. * Specifies is mipmaps must be generated
  6038. */
  6039. generateMipMaps?: boolean;
  6040. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6041. generateDepthBuffer?: boolean;
  6042. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6043. generateStencilBuffer?: boolean;
  6044. /** Defines texture type (int by default) */
  6045. type?: number;
  6046. /** Defines sampling mode (trilinear by default) */
  6047. samplingMode?: number;
  6048. /** Defines format (RGBA by default) */
  6049. format?: number;
  6050. }
  6051. }
  6052. declare module "babylonjs/States/alphaCullingState" {
  6053. /**
  6054. * @hidden
  6055. **/
  6056. export class _AlphaState {
  6057. private _isAlphaBlendDirty;
  6058. private _isBlendFunctionParametersDirty;
  6059. private _isBlendEquationParametersDirty;
  6060. private _isBlendConstantsDirty;
  6061. private _alphaBlend;
  6062. private _blendFunctionParameters;
  6063. private _blendEquationParameters;
  6064. private _blendConstants;
  6065. /**
  6066. * Initializes the state.
  6067. */
  6068. constructor();
  6069. readonly isDirty: boolean;
  6070. alphaBlend: boolean;
  6071. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6072. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6073. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6074. reset(): void;
  6075. apply(gl: WebGLRenderingContext): void;
  6076. }
  6077. }
  6078. declare module "babylonjs/States/depthCullingState" {
  6079. import { Nullable } from "babylonjs/types";
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _DepthCullingState {
  6084. private _isDepthTestDirty;
  6085. private _isDepthMaskDirty;
  6086. private _isDepthFuncDirty;
  6087. private _isCullFaceDirty;
  6088. private _isCullDirty;
  6089. private _isZOffsetDirty;
  6090. private _isFrontFaceDirty;
  6091. private _depthTest;
  6092. private _depthMask;
  6093. private _depthFunc;
  6094. private _cull;
  6095. private _cullFace;
  6096. private _zOffset;
  6097. private _frontFace;
  6098. /**
  6099. * Initializes the state.
  6100. */
  6101. constructor();
  6102. readonly isDirty: boolean;
  6103. zOffset: number;
  6104. cullFace: Nullable<number>;
  6105. cull: Nullable<boolean>;
  6106. depthFunc: Nullable<number>;
  6107. depthMask: boolean;
  6108. depthTest: boolean;
  6109. frontFace: Nullable<number>;
  6110. reset(): void;
  6111. apply(gl: WebGLRenderingContext): void;
  6112. }
  6113. }
  6114. declare module "babylonjs/States/stencilState" {
  6115. /**
  6116. * @hidden
  6117. **/
  6118. export class _StencilState {
  6119. /** 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 */
  6120. static readonly ALWAYS: number;
  6121. /** Passed to stencilOperation to specify that stencil value must be kept */
  6122. static readonly KEEP: number;
  6123. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6124. static readonly REPLACE: number;
  6125. private _isStencilTestDirty;
  6126. private _isStencilMaskDirty;
  6127. private _isStencilFuncDirty;
  6128. private _isStencilOpDirty;
  6129. private _stencilTest;
  6130. private _stencilMask;
  6131. private _stencilFunc;
  6132. private _stencilFuncRef;
  6133. private _stencilFuncMask;
  6134. private _stencilOpStencilFail;
  6135. private _stencilOpDepthFail;
  6136. private _stencilOpStencilDepthPass;
  6137. readonly isDirty: boolean;
  6138. stencilFunc: number;
  6139. stencilFuncRef: number;
  6140. stencilFuncMask: number;
  6141. stencilOpStencilFail: number;
  6142. stencilOpDepthFail: number;
  6143. stencilOpStencilDepthPass: number;
  6144. stencilMask: number;
  6145. stencilTest: boolean;
  6146. constructor();
  6147. reset(): void;
  6148. apply(gl: WebGLRenderingContext): void;
  6149. }
  6150. }
  6151. declare module "babylonjs/States/index" {
  6152. export * from "babylonjs/States/alphaCullingState";
  6153. export * from "babylonjs/States/depthCullingState";
  6154. export * from "babylonjs/States/stencilState";
  6155. }
  6156. declare module "babylonjs/Instrumentation/timeToken" {
  6157. import { Nullable } from "babylonjs/types";
  6158. /**
  6159. * @hidden
  6160. **/
  6161. export class _TimeToken {
  6162. _startTimeQuery: Nullable<WebGLQuery>;
  6163. _endTimeQuery: Nullable<WebGLQuery>;
  6164. _timeElapsedQuery: Nullable<WebGLQuery>;
  6165. _timeElapsedQueryEnded: boolean;
  6166. }
  6167. }
  6168. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6169. import { Nullable } from "babylonjs/types";
  6170. /**
  6171. * Internal interface used to track InternalTexture already bound to the GL context
  6172. */
  6173. export interface IInternalTextureTracker {
  6174. /**
  6175. * Gets or set the previous tracker in the list
  6176. */
  6177. previous: Nullable<IInternalTextureTracker>;
  6178. /**
  6179. * Gets or set the next tracker in the list
  6180. */
  6181. next: Nullable<IInternalTextureTracker>;
  6182. }
  6183. /**
  6184. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6185. */
  6186. export class DummyInternalTextureTracker {
  6187. /**
  6188. * Gets or set the previous tracker in the list
  6189. */
  6190. previous: Nullable<IInternalTextureTracker>;
  6191. /**
  6192. * Gets or set the next tracker in the list
  6193. */
  6194. next: Nullable<IInternalTextureTracker>;
  6195. }
  6196. }
  6197. declare module "babylonjs/Materials/Textures/internalTexture" {
  6198. import { Observable } from "babylonjs/Misc/observable";
  6199. import { Nullable, int } from "babylonjs/types";
  6200. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6201. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6202. import { Engine } from "babylonjs/Engines/engine";
  6203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6204. /**
  6205. * Class used to store data associated with WebGL texture data for the engine
  6206. * This class should not be used directly
  6207. */
  6208. export class InternalTexture implements IInternalTextureTracker {
  6209. /** hidden */
  6210. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6211. /**
  6212. * The source of the texture data is unknown
  6213. */
  6214. static DATASOURCE_UNKNOWN: number;
  6215. /**
  6216. * Texture data comes from an URL
  6217. */
  6218. static DATASOURCE_URL: number;
  6219. /**
  6220. * Texture data is only used for temporary storage
  6221. */
  6222. static DATASOURCE_TEMP: number;
  6223. /**
  6224. * Texture data comes from raw data (ArrayBuffer)
  6225. */
  6226. static DATASOURCE_RAW: number;
  6227. /**
  6228. * Texture content is dynamic (video or dynamic texture)
  6229. */
  6230. static DATASOURCE_DYNAMIC: number;
  6231. /**
  6232. * Texture content is generated by rendering to it
  6233. */
  6234. static DATASOURCE_RENDERTARGET: number;
  6235. /**
  6236. * Texture content is part of a multi render target process
  6237. */
  6238. static DATASOURCE_MULTIRENDERTARGET: number;
  6239. /**
  6240. * Texture data comes from a cube data file
  6241. */
  6242. static DATASOURCE_CUBE: number;
  6243. /**
  6244. * Texture data comes from a raw cube data
  6245. */
  6246. static DATASOURCE_CUBERAW: number;
  6247. /**
  6248. * Texture data come from a prefiltered cube data file
  6249. */
  6250. static DATASOURCE_CUBEPREFILTERED: number;
  6251. /**
  6252. * Texture content is raw 3D data
  6253. */
  6254. static DATASOURCE_RAW3D: number;
  6255. /**
  6256. * Texture content is a depth texture
  6257. */
  6258. static DATASOURCE_DEPTHTEXTURE: number;
  6259. /**
  6260. * Texture data comes from a raw cube data encoded with RGBD
  6261. */
  6262. static DATASOURCE_CUBERAW_RGBD: number;
  6263. /**
  6264. * Defines if the texture is ready
  6265. */
  6266. isReady: boolean;
  6267. /**
  6268. * Defines if the texture is a cube texture
  6269. */
  6270. isCube: boolean;
  6271. /**
  6272. * Defines if the texture contains 3D data
  6273. */
  6274. is3D: boolean;
  6275. /**
  6276. * Gets the URL used to load this texture
  6277. */
  6278. url: string;
  6279. /**
  6280. * Gets the sampling mode of the texture
  6281. */
  6282. samplingMode: number;
  6283. /**
  6284. * Gets a boolean indicating if the texture needs mipmaps generation
  6285. */
  6286. generateMipMaps: boolean;
  6287. /**
  6288. * Gets the number of samples used by the texture (WebGL2+ only)
  6289. */
  6290. samples: number;
  6291. /**
  6292. * Gets the type of the texture (int, float...)
  6293. */
  6294. type: number;
  6295. /**
  6296. * Gets the format of the texture (RGB, RGBA...)
  6297. */
  6298. format: number;
  6299. /**
  6300. * Observable called when the texture is loaded
  6301. */
  6302. onLoadedObservable: Observable<InternalTexture>;
  6303. /**
  6304. * Gets the width of the texture
  6305. */
  6306. width: number;
  6307. /**
  6308. * Gets the height of the texture
  6309. */
  6310. height: number;
  6311. /**
  6312. * Gets the depth of the texture
  6313. */
  6314. depth: number;
  6315. /**
  6316. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6317. */
  6318. baseWidth: number;
  6319. /**
  6320. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6321. */
  6322. baseHeight: number;
  6323. /**
  6324. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6325. */
  6326. baseDepth: number;
  6327. /**
  6328. * Gets a boolean indicating if the texture is inverted on Y axis
  6329. */
  6330. invertY: boolean;
  6331. /**
  6332. * Gets or set the previous tracker in the list
  6333. */
  6334. previous: Nullable<IInternalTextureTracker>;
  6335. /**
  6336. * Gets or set the next tracker in the list
  6337. */
  6338. next: Nullable<IInternalTextureTracker>;
  6339. /** @hidden */
  6340. _invertVScale: boolean;
  6341. /** @hidden */
  6342. _initialSlot: number;
  6343. /** @hidden */
  6344. _designatedSlot: number;
  6345. /** @hidden */
  6346. _dataSource: number;
  6347. /** @hidden */
  6348. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6349. /** @hidden */
  6350. _bufferView: Nullable<ArrayBufferView>;
  6351. /** @hidden */
  6352. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6353. /** @hidden */
  6354. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6355. /** @hidden */
  6356. _size: number;
  6357. /** @hidden */
  6358. _extension: string;
  6359. /** @hidden */
  6360. _files: Nullable<string[]>;
  6361. /** @hidden */
  6362. _workingCanvas: HTMLCanvasElement;
  6363. /** @hidden */
  6364. _workingContext: CanvasRenderingContext2D;
  6365. /** @hidden */
  6366. _framebuffer: Nullable<WebGLFramebuffer>;
  6367. /** @hidden */
  6368. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6369. /** @hidden */
  6370. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6371. /** @hidden */
  6372. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6373. /** @hidden */
  6374. _attachments: Nullable<number[]>;
  6375. /** @hidden */
  6376. _cachedCoordinatesMode: Nullable<number>;
  6377. /** @hidden */
  6378. _cachedWrapU: Nullable<number>;
  6379. /** @hidden */
  6380. _cachedWrapV: Nullable<number>;
  6381. /** @hidden */
  6382. _cachedWrapR: Nullable<number>;
  6383. /** @hidden */
  6384. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6385. /** @hidden */
  6386. _isDisabled: boolean;
  6387. /** @hidden */
  6388. _compression: Nullable<string>;
  6389. /** @hidden */
  6390. _generateStencilBuffer: boolean;
  6391. /** @hidden */
  6392. _generateDepthBuffer: boolean;
  6393. /** @hidden */
  6394. _comparisonFunction: number;
  6395. /** @hidden */
  6396. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6397. /** @hidden */
  6398. _lodGenerationScale: number;
  6399. /** @hidden */
  6400. _lodGenerationOffset: number;
  6401. /** @hidden */
  6402. _lodTextureHigh: BaseTexture;
  6403. /** @hidden */
  6404. _lodTextureMid: BaseTexture;
  6405. /** @hidden */
  6406. _lodTextureLow: BaseTexture;
  6407. /** @hidden */
  6408. _isRGBD: boolean;
  6409. /** @hidden */
  6410. _webGLTexture: Nullable<WebGLTexture>;
  6411. /** @hidden */
  6412. _references: number;
  6413. private _engine;
  6414. /**
  6415. * Gets the Engine the texture belongs to.
  6416. * @returns The babylon engine
  6417. */
  6418. getEngine(): Engine;
  6419. /**
  6420. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6421. */
  6422. readonly dataSource: number;
  6423. /**
  6424. * Creates a new InternalTexture
  6425. * @param engine defines the engine to use
  6426. * @param dataSource defines the type of data that will be used
  6427. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6428. */
  6429. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6430. /**
  6431. * Increments the number of references (ie. the number of Texture that point to it)
  6432. */
  6433. incrementReferences(): void;
  6434. /**
  6435. * Change the size of the texture (not the size of the content)
  6436. * @param width defines the new width
  6437. * @param height defines the new height
  6438. * @param depth defines the new depth (1 by default)
  6439. */
  6440. updateSize(width: int, height: int, depth?: int): void;
  6441. /** @hidden */
  6442. _rebuild(): void;
  6443. /** @hidden */
  6444. _swapAndDie(target: InternalTexture): void;
  6445. /**
  6446. * Dispose the current allocated resources
  6447. */
  6448. dispose(): void;
  6449. }
  6450. }
  6451. declare module "babylonjs/Animations/easing" {
  6452. /**
  6453. * This represents the main contract an easing function should follow.
  6454. * Easing functions are used throughout the animation system.
  6455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6456. */
  6457. export interface IEasingFunction {
  6458. /**
  6459. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6460. * of the easing function.
  6461. * The link below provides some of the most common examples of easing functions.
  6462. * @see https://easings.net/
  6463. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6464. * @returns the corresponding value on the curve defined by the easing function
  6465. */
  6466. ease(gradient: number): number;
  6467. }
  6468. /**
  6469. * Base class used for every default easing function.
  6470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6471. */
  6472. export class EasingFunction implements IEasingFunction {
  6473. /**
  6474. * Interpolation follows the mathematical formula associated with the easing function.
  6475. */
  6476. static readonly EASINGMODE_EASEIN: number;
  6477. /**
  6478. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6479. */
  6480. static readonly EASINGMODE_EASEOUT: number;
  6481. /**
  6482. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6483. */
  6484. static readonly EASINGMODE_EASEINOUT: number;
  6485. private _easingMode;
  6486. /**
  6487. * Sets the easing mode of the current function.
  6488. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6489. */
  6490. setEasingMode(easingMode: number): void;
  6491. /**
  6492. * Gets the current easing mode.
  6493. * @returns the easing mode
  6494. */
  6495. getEasingMode(): number;
  6496. /**
  6497. * @hidden
  6498. */
  6499. easeInCore(gradient: number): number;
  6500. /**
  6501. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6502. * of the easing function.
  6503. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6504. * @returns the corresponding value on the curve defined by the easing function
  6505. */
  6506. ease(gradient: number): number;
  6507. }
  6508. /**
  6509. * Easing function with a circle shape (see link below).
  6510. * @see https://easings.net/#easeInCirc
  6511. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6512. */
  6513. export class CircleEase extends EasingFunction implements IEasingFunction {
  6514. /** @hidden */
  6515. easeInCore(gradient: number): number;
  6516. }
  6517. /**
  6518. * Easing function with a ease back shape (see link below).
  6519. * @see https://easings.net/#easeInBack
  6520. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6521. */
  6522. export class BackEase extends EasingFunction implements IEasingFunction {
  6523. /** Defines the amplitude of the function */
  6524. amplitude: number;
  6525. /**
  6526. * Instantiates a back ease easing
  6527. * @see https://easings.net/#easeInBack
  6528. * @param amplitude Defines the amplitude of the function
  6529. */
  6530. constructor(
  6531. /** Defines the amplitude of the function */
  6532. amplitude?: number);
  6533. /** @hidden */
  6534. easeInCore(gradient: number): number;
  6535. }
  6536. /**
  6537. * Easing function with a bouncing shape (see link below).
  6538. * @see https://easings.net/#easeInBounce
  6539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6540. */
  6541. export class BounceEase extends EasingFunction implements IEasingFunction {
  6542. /** Defines the number of bounces */
  6543. bounces: number;
  6544. /** Defines the amplitude of the bounce */
  6545. bounciness: number;
  6546. /**
  6547. * Instantiates a bounce easing
  6548. * @see https://easings.net/#easeInBounce
  6549. * @param bounces Defines the number of bounces
  6550. * @param bounciness Defines the amplitude of the bounce
  6551. */
  6552. constructor(
  6553. /** Defines the number of bounces */
  6554. bounces?: number,
  6555. /** Defines the amplitude of the bounce */
  6556. bounciness?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 3 shape (see link below).
  6562. * @see https://easings.net/#easeInCubic
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class CubicEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with an elastic shape (see link below).
  6571. * @see https://easings.net/#easeInElastic
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6575. /** Defines the number of oscillations*/
  6576. oscillations: number;
  6577. /** Defines the amplitude of the oscillations*/
  6578. springiness: number;
  6579. /**
  6580. * Instantiates an elastic easing function
  6581. * @see https://easings.net/#easeInElastic
  6582. * @param oscillations Defines the number of oscillations
  6583. * @param springiness Defines the amplitude of the oscillations
  6584. */
  6585. constructor(
  6586. /** Defines the number of oscillations*/
  6587. oscillations?: number,
  6588. /** Defines the amplitude of the oscillations*/
  6589. springiness?: number);
  6590. /** @hidden */
  6591. easeInCore(gradient: number): number;
  6592. }
  6593. /**
  6594. * Easing function with an exponential shape (see link below).
  6595. * @see https://easings.net/#easeInExpo
  6596. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6597. */
  6598. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6599. /** Defines the exponent of the function */
  6600. exponent: number;
  6601. /**
  6602. * Instantiates an exponential easing function
  6603. * @see https://easings.net/#easeInExpo
  6604. * @param exponent Defines the exponent of the function
  6605. */
  6606. constructor(
  6607. /** Defines the exponent of the function */
  6608. exponent?: number);
  6609. /** @hidden */
  6610. easeInCore(gradient: number): number;
  6611. }
  6612. /**
  6613. * Easing function with a power shape (see link below).
  6614. * @see https://easings.net/#easeInQuad
  6615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6616. */
  6617. export class PowerEase extends EasingFunction implements IEasingFunction {
  6618. /** Defines the power of the function */
  6619. power: number;
  6620. /**
  6621. * Instantiates an power base easing function
  6622. * @see https://easings.net/#easeInQuad
  6623. * @param power Defines the power of the function
  6624. */
  6625. constructor(
  6626. /** Defines the power of the function */
  6627. power?: number);
  6628. /** @hidden */
  6629. easeInCore(gradient: number): number;
  6630. }
  6631. /**
  6632. * Easing function with a power of 2 shape (see link below).
  6633. * @see https://easings.net/#easeInQuad
  6634. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6635. */
  6636. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6637. /** @hidden */
  6638. easeInCore(gradient: number): number;
  6639. }
  6640. /**
  6641. * Easing function with a power of 4 shape (see link below).
  6642. * @see https://easings.net/#easeInQuart
  6643. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6644. */
  6645. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6646. /** @hidden */
  6647. easeInCore(gradient: number): number;
  6648. }
  6649. /**
  6650. * Easing function with a power of 5 shape (see link below).
  6651. * @see https://easings.net/#easeInQuint
  6652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6653. */
  6654. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a sin shape (see link below).
  6660. * @see https://easings.net/#easeInSine
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class SineEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a bezier shape (see link below).
  6669. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6673. /** Defines the x component of the start tangent in the bezier curve */
  6674. x1: number;
  6675. /** Defines the y component of the start tangent in the bezier curve */
  6676. y1: number;
  6677. /** Defines the x component of the end tangent in the bezier curve */
  6678. x2: number;
  6679. /** Defines the y component of the end tangent in the bezier curve */
  6680. y2: number;
  6681. /**
  6682. * Instantiates a bezier function
  6683. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6684. * @param x1 Defines the x component of the start tangent in the bezier curve
  6685. * @param y1 Defines the y component of the start tangent in the bezier curve
  6686. * @param x2 Defines the x component of the end tangent in the bezier curve
  6687. * @param y2 Defines the y component of the end tangent in the bezier curve
  6688. */
  6689. constructor(
  6690. /** Defines the x component of the start tangent in the bezier curve */
  6691. x1?: number,
  6692. /** Defines the y component of the start tangent in the bezier curve */
  6693. y1?: number,
  6694. /** Defines the x component of the end tangent in the bezier curve */
  6695. x2?: number,
  6696. /** Defines the y component of the end tangent in the bezier curve */
  6697. y2?: number);
  6698. /** @hidden */
  6699. easeInCore(gradient: number): number;
  6700. }
  6701. }
  6702. declare module "babylonjs/Animations/animationKey" {
  6703. /**
  6704. * Defines an interface which represents an animation key frame
  6705. */
  6706. export interface IAnimationKey {
  6707. /**
  6708. * Frame of the key frame
  6709. */
  6710. frame: number;
  6711. /**
  6712. * Value at the specifies key frame
  6713. */
  6714. value: any;
  6715. /**
  6716. * The input tangent for the cubic hermite spline
  6717. */
  6718. inTangent?: any;
  6719. /**
  6720. * The output tangent for the cubic hermite spline
  6721. */
  6722. outTangent?: any;
  6723. /**
  6724. * The animation interpolation type
  6725. */
  6726. interpolation?: AnimationKeyInterpolation;
  6727. }
  6728. /**
  6729. * Enum for the animation key frame interpolation type
  6730. */
  6731. export enum AnimationKeyInterpolation {
  6732. /**
  6733. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6734. */
  6735. STEP = 1
  6736. }
  6737. }
  6738. declare module "babylonjs/Animations/animationRange" {
  6739. /**
  6740. * Represents the range of an animation
  6741. */
  6742. export class AnimationRange {
  6743. /**The name of the animation range**/
  6744. name: string;
  6745. /**The starting frame of the animation */
  6746. from: number;
  6747. /**The ending frame of the animation*/
  6748. to: number;
  6749. /**
  6750. * Initializes the range of an animation
  6751. * @param name The name of the animation range
  6752. * @param from The starting frame of the animation
  6753. * @param to The ending frame of the animation
  6754. */
  6755. constructor(
  6756. /**The name of the animation range**/
  6757. name: string,
  6758. /**The starting frame of the animation */
  6759. from: number,
  6760. /**The ending frame of the animation*/
  6761. to: number);
  6762. /**
  6763. * Makes a copy of the animation range
  6764. * @returns A copy of the animation range
  6765. */
  6766. clone(): AnimationRange;
  6767. }
  6768. }
  6769. declare module "babylonjs/Animations/animationEvent" {
  6770. /**
  6771. * Composed of a frame, and an action function
  6772. */
  6773. export class AnimationEvent {
  6774. /** The frame for which the event is triggered **/
  6775. frame: number;
  6776. /** The event to perform when triggered **/
  6777. action: (currentFrame: number) => void;
  6778. /** Specifies if the event should be triggered only once**/
  6779. onlyOnce?: boolean | undefined;
  6780. /**
  6781. * Specifies if the animation event is done
  6782. */
  6783. isDone: boolean;
  6784. /**
  6785. * Initializes the animation event
  6786. * @param frame The frame for which the event is triggered
  6787. * @param action The event to perform when triggered
  6788. * @param onlyOnce Specifies if the event should be triggered only once
  6789. */
  6790. constructor(
  6791. /** The frame for which the event is triggered **/
  6792. frame: number,
  6793. /** The event to perform when triggered **/
  6794. action: (currentFrame: number) => void,
  6795. /** Specifies if the event should be triggered only once**/
  6796. onlyOnce?: boolean | undefined);
  6797. /** @hidden */
  6798. _clone(): AnimationEvent;
  6799. }
  6800. }
  6801. declare module "babylonjs/Behaviors/behavior" {
  6802. import { Nullable } from "babylonjs/types";
  6803. /**
  6804. * Interface used to define a behavior
  6805. */
  6806. export interface Behavior<T> {
  6807. /** gets or sets behavior's name */
  6808. name: string;
  6809. /**
  6810. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6811. */
  6812. init(): void;
  6813. /**
  6814. * Called when the behavior is attached to a target
  6815. * @param target defines the target where the behavior is attached to
  6816. */
  6817. attach(target: T): void;
  6818. /**
  6819. * Called when the behavior is detached from its target
  6820. */
  6821. detach(): void;
  6822. }
  6823. /**
  6824. * Interface implemented by classes supporting behaviors
  6825. */
  6826. export interface IBehaviorAware<T> {
  6827. /**
  6828. * Attach a behavior
  6829. * @param behavior defines the behavior to attach
  6830. * @returns the current host
  6831. */
  6832. addBehavior(behavior: Behavior<T>): T;
  6833. /**
  6834. * Remove a behavior from the current object
  6835. * @param behavior defines the behavior to detach
  6836. * @returns the current host
  6837. */
  6838. removeBehavior(behavior: Behavior<T>): T;
  6839. /**
  6840. * Gets a behavior using its name to search
  6841. * @param name defines the name to search
  6842. * @returns the behavior or null if not found
  6843. */
  6844. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6845. }
  6846. }
  6847. declare module "babylonjs/Collisions/intersectionInfo" {
  6848. import { Nullable } from "babylonjs/types";
  6849. /**
  6850. * @hidden
  6851. */
  6852. export class IntersectionInfo {
  6853. bu: Nullable<number>;
  6854. bv: Nullable<number>;
  6855. distance: number;
  6856. faceId: number;
  6857. subMeshId: number;
  6858. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6859. }
  6860. }
  6861. declare module "babylonjs/Culling/boundingSphere" {
  6862. import { DeepImmutable } from "babylonjs/types";
  6863. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6864. /**
  6865. * Class used to store bounding sphere information
  6866. */
  6867. export class BoundingSphere {
  6868. /**
  6869. * Gets the center of the bounding sphere in local space
  6870. */
  6871. readonly center: Vector3;
  6872. /**
  6873. * Radius of the bounding sphere in local space
  6874. */
  6875. radius: number;
  6876. /**
  6877. * Gets the center of the bounding sphere in world space
  6878. */
  6879. readonly centerWorld: Vector3;
  6880. /**
  6881. * Radius of the bounding sphere in world space
  6882. */
  6883. radiusWorld: number;
  6884. /**
  6885. * Gets the minimum vector in local space
  6886. */
  6887. readonly minimum: Vector3;
  6888. /**
  6889. * Gets the maximum vector in local space
  6890. */
  6891. readonly maximum: Vector3;
  6892. private _worldMatrix;
  6893. private static readonly TmpVector3;
  6894. /**
  6895. * Creates a new bounding sphere
  6896. * @param min defines the minimum vector (in local space)
  6897. * @param max defines the maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6901. /**
  6902. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6903. * @param min defines the new minimum vector (in local space)
  6904. * @param max defines the new maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6908. /**
  6909. * Scale the current bounding sphere by applying a scale factor
  6910. * @param factor defines the scale factor to apply
  6911. * @returns the current bounding box
  6912. */
  6913. scale(factor: number): BoundingSphere;
  6914. /**
  6915. * Gets the world matrix of the bounding box
  6916. * @returns a matrix
  6917. */
  6918. getWorldMatrix(): DeepImmutable<Matrix>;
  6919. /** @hidden */
  6920. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6921. /**
  6922. * Tests if the bounding sphere is intersecting the frustum planes
  6923. * @param frustumPlanes defines the frustum planes to test
  6924. * @returns true if there is an intersection
  6925. */
  6926. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6927. /**
  6928. * Tests if the bounding sphere center is in between the frustum planes.
  6929. * Used for optimistic fast inclusion.
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if the sphere center is in between the frustum planes
  6932. */
  6933. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a point is inside the bounding sphere
  6936. * @param point defines the point to test
  6937. * @returns true if the point is inside the bounding sphere
  6938. */
  6939. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6940. /**
  6941. * Checks if two sphere intersct
  6942. * @param sphere0 sphere 0
  6943. * @param sphere1 sphere 1
  6944. * @returns true if the speres intersect
  6945. */
  6946. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6947. }
  6948. }
  6949. declare module "babylonjs/Culling/boundingBox" {
  6950. import { DeepImmutable } from "babylonjs/types";
  6951. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6952. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6953. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6954. /**
  6955. * Class used to store bounding box information
  6956. */
  6957. export class BoundingBox implements ICullable {
  6958. /**
  6959. * Gets the 8 vectors representing the bounding box in local space
  6960. */
  6961. readonly vectors: Vector3[];
  6962. /**
  6963. * Gets the center of the bounding box in local space
  6964. */
  6965. readonly center: Vector3;
  6966. /**
  6967. * Gets the center of the bounding box in world space
  6968. */
  6969. readonly centerWorld: Vector3;
  6970. /**
  6971. * Gets the extend size in local space
  6972. */
  6973. readonly extendSize: Vector3;
  6974. /**
  6975. * Gets the extend size in world space
  6976. */
  6977. readonly extendSizeWorld: Vector3;
  6978. /**
  6979. * Gets the OBB (object bounding box) directions
  6980. */
  6981. readonly directions: Vector3[];
  6982. /**
  6983. * Gets the 8 vectors representing the bounding box in world space
  6984. */
  6985. readonly vectorsWorld: Vector3[];
  6986. /**
  6987. * Gets the minimum vector in world space
  6988. */
  6989. readonly minimumWorld: Vector3;
  6990. /**
  6991. * Gets the maximum vector in world space
  6992. */
  6993. readonly maximumWorld: Vector3;
  6994. /**
  6995. * Gets the minimum vector in local space
  6996. */
  6997. readonly minimum: Vector3;
  6998. /**
  6999. * Gets the maximum vector in local space
  7000. */
  7001. readonly maximum: Vector3;
  7002. private _worldMatrix;
  7003. private static readonly TmpVector3;
  7004. /**
  7005. * @hidden
  7006. */
  7007. _tag: number;
  7008. /**
  7009. * Creates a new bounding box
  7010. * @param min defines the minimum vector (in local space)
  7011. * @param max defines the maximum vector (in local space)
  7012. * @param worldMatrix defines the new world matrix
  7013. */
  7014. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7015. /**
  7016. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7017. * @param min defines the new minimum vector (in local space)
  7018. * @param max defines the new maximum vector (in local space)
  7019. * @param worldMatrix defines the new world matrix
  7020. */
  7021. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7022. /**
  7023. * Scale the current bounding box by applying a scale factor
  7024. * @param factor defines the scale factor to apply
  7025. * @returns the current bounding box
  7026. */
  7027. scale(factor: number): BoundingBox;
  7028. /**
  7029. * Gets the world matrix of the bounding box
  7030. * @returns a matrix
  7031. */
  7032. getWorldMatrix(): DeepImmutable<Matrix>;
  7033. /** @hidden */
  7034. _update(world: DeepImmutable<Matrix>): void;
  7035. /**
  7036. * Tests if the bounding box is intersecting the frustum planes
  7037. * @param frustumPlanes defines the frustum planes to test
  7038. * @returns true if there is an intersection
  7039. */
  7040. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7041. /**
  7042. * Tests if the bounding box is entirely inside the frustum planes
  7043. * @param frustumPlanes defines the frustum planes to test
  7044. * @returns true if there is an inclusion
  7045. */
  7046. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7047. /**
  7048. * Tests if a point is inside the bounding box
  7049. * @param point defines the point to test
  7050. * @returns true if the point is inside the bounding box
  7051. */
  7052. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7053. /**
  7054. * Tests if the bounding box intersects with a bounding sphere
  7055. * @param sphere defines the sphere to test
  7056. * @returns true if there is an intersection
  7057. */
  7058. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7059. /**
  7060. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7061. * @param min defines the min vector to use
  7062. * @param max defines the max vector to use
  7063. * @returns true if there is an intersection
  7064. */
  7065. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7066. /**
  7067. * Tests if two bounding boxes are intersections
  7068. * @param box0 defines the first box to test
  7069. * @param box1 defines the second box to test
  7070. * @returns true if there is an intersection
  7071. */
  7072. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7073. /**
  7074. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7075. * @param minPoint defines the minimum vector of the bounding box
  7076. * @param maxPoint defines the maximum vector of the bounding box
  7077. * @param sphereCenter defines the sphere center
  7078. * @param sphereRadius defines the sphere radius
  7079. * @returns true if there is an intersection
  7080. */
  7081. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7082. /**
  7083. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7084. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7085. * @param frustumPlanes defines the frustum planes to test
  7086. * @return true if there is an inclusion
  7087. */
  7088. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7089. /**
  7090. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7091. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7092. * @param frustumPlanes defines the frustum planes to test
  7093. * @return true if there is an intersection
  7094. */
  7095. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7096. }
  7097. }
  7098. declare module "babylonjs/Collisions/collider" {
  7099. import { Nullable, IndicesArray } from "babylonjs/types";
  7100. import { Vector3, Plane } from "babylonjs/Maths/math";
  7101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7102. /** @hidden */
  7103. export class Collider {
  7104. /** Define if a collision was found */
  7105. collisionFound: boolean;
  7106. /**
  7107. * Define last intersection point in local space
  7108. */
  7109. intersectionPoint: Vector3;
  7110. /**
  7111. * Define last collided mesh
  7112. */
  7113. collidedMesh: Nullable<AbstractMesh>;
  7114. private _collisionPoint;
  7115. private _planeIntersectionPoint;
  7116. private _tempVector;
  7117. private _tempVector2;
  7118. private _tempVector3;
  7119. private _tempVector4;
  7120. private _edge;
  7121. private _baseToVertex;
  7122. private _destinationPoint;
  7123. private _slidePlaneNormal;
  7124. private _displacementVector;
  7125. /** @hidden */
  7126. _radius: Vector3;
  7127. /** @hidden */
  7128. _retry: number;
  7129. private _velocity;
  7130. private _basePoint;
  7131. private _epsilon;
  7132. /** @hidden */
  7133. _velocityWorldLength: number;
  7134. /** @hidden */
  7135. _basePointWorld: Vector3;
  7136. private _velocityWorld;
  7137. private _normalizedVelocity;
  7138. /** @hidden */
  7139. _initialVelocity: Vector3;
  7140. /** @hidden */
  7141. _initialPosition: Vector3;
  7142. private _nearestDistance;
  7143. private _collisionMask;
  7144. collisionMask: number;
  7145. /**
  7146. * Gets the plane normal used to compute the sliding response (in local space)
  7147. */
  7148. readonly slidePlaneNormal: Vector3;
  7149. /** @hidden */
  7150. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7151. /** @hidden */
  7152. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7153. /** @hidden */
  7154. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7155. /** @hidden */
  7156. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7157. /** @hidden */
  7158. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7159. /** @hidden */
  7160. _getResponse(pos: Vector3, vel: Vector3): void;
  7161. }
  7162. }
  7163. declare module "babylonjs/Culling/boundingInfo" {
  7164. import { DeepImmutable } from "babylonjs/types";
  7165. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7166. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7167. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7168. import { Collider } from "babylonjs/Collisions/collider";
  7169. /**
  7170. * Interface for cullable objects
  7171. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7172. */
  7173. export interface ICullable {
  7174. /**
  7175. * Checks if the object or part of the object is in the frustum
  7176. * @param frustumPlanes Camera near/planes
  7177. * @returns true if the object is in frustum otherwise false
  7178. */
  7179. isInFrustum(frustumPlanes: Plane[]): boolean;
  7180. /**
  7181. * Checks if a cullable object (mesh...) is in the camera frustum
  7182. * Unlike isInFrustum this cheks the full bounding box
  7183. * @param frustumPlanes Camera near/planes
  7184. * @returns true if the object is in frustum otherwise false
  7185. */
  7186. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7187. }
  7188. /**
  7189. * Info for a bounding data of a mesh
  7190. */
  7191. export class BoundingInfo implements ICullable {
  7192. /**
  7193. * Bounding box for the mesh
  7194. */
  7195. readonly boundingBox: BoundingBox;
  7196. /**
  7197. * Bounding sphere for the mesh
  7198. */
  7199. readonly boundingSphere: BoundingSphere;
  7200. private _isLocked;
  7201. private static readonly TmpVector3;
  7202. /**
  7203. * Constructs bounding info
  7204. * @param minimum min vector of the bounding box/sphere
  7205. * @param maximum max vector of the bounding box/sphere
  7206. * @param worldMatrix defines the new world matrix
  7207. */
  7208. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7209. /**
  7210. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7211. * @param min defines the new minimum vector (in local space)
  7212. * @param max defines the new maximum vector (in local space)
  7213. * @param worldMatrix defines the new world matrix
  7214. */
  7215. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7216. /**
  7217. * min vector of the bounding box/sphere
  7218. */
  7219. readonly minimum: Vector3;
  7220. /**
  7221. * max vector of the bounding box/sphere
  7222. */
  7223. readonly maximum: Vector3;
  7224. /**
  7225. * If the info is locked and won't be updated to avoid perf overhead
  7226. */
  7227. isLocked: boolean;
  7228. /**
  7229. * Updates the bounding sphere and box
  7230. * @param world world matrix to be used to update
  7231. */
  7232. update(world: DeepImmutable<Matrix>): void;
  7233. /**
  7234. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7235. * @param center New center of the bounding info
  7236. * @param extend New extend of the bounding info
  7237. * @returns the current bounding info
  7238. */
  7239. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7240. /**
  7241. * Scale the current bounding info by applying a scale factor
  7242. * @param factor defines the scale factor to apply
  7243. * @returns the current bounding info
  7244. */
  7245. scale(factor: number): BoundingInfo;
  7246. /**
  7247. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7248. * @param frustumPlanes defines the frustum to test
  7249. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7250. * @returns true if the bounding info is in the frustum planes
  7251. */
  7252. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7253. /**
  7254. * Gets the world distance between the min and max points of the bounding box
  7255. */
  7256. readonly diagonalLength: number;
  7257. /**
  7258. * Checks if a cullable object (mesh...) is in the camera frustum
  7259. * Unlike isInFrustum this cheks the full bounding box
  7260. * @param frustumPlanes Camera near/planes
  7261. * @returns true if the object is in frustum otherwise false
  7262. */
  7263. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7264. /** @hidden */
  7265. _checkCollision(collider: Collider): boolean;
  7266. /**
  7267. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7268. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7269. * @param point the point to check intersection with
  7270. * @returns if the point intersects
  7271. */
  7272. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7273. /**
  7274. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7275. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7276. * @param boundingInfo the bounding info to check intersection with
  7277. * @param precise if the intersection should be done using OBB
  7278. * @returns if the bounding info intersects
  7279. */
  7280. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7281. }
  7282. }
  7283. declare module "babylonjs/Misc/smartArray" {
  7284. /**
  7285. * Defines an array and its length.
  7286. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7287. */
  7288. export interface ISmartArrayLike<T> {
  7289. /**
  7290. * The data of the array.
  7291. */
  7292. data: Array<T>;
  7293. /**
  7294. * The active length of the array.
  7295. */
  7296. length: number;
  7297. }
  7298. /**
  7299. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7300. */
  7301. export class SmartArray<T> implements ISmartArrayLike<T> {
  7302. /**
  7303. * The full set of data from the array.
  7304. */
  7305. data: Array<T>;
  7306. /**
  7307. * The active length of the array.
  7308. */
  7309. length: number;
  7310. protected _id: number;
  7311. /**
  7312. * Instantiates a Smart Array.
  7313. * @param capacity defines the default capacity of the array.
  7314. */
  7315. constructor(capacity: number);
  7316. /**
  7317. * Pushes a value at the end of the active data.
  7318. * @param value defines the object to push in the array.
  7319. */
  7320. push(value: T): void;
  7321. /**
  7322. * Iterates over the active data and apply the lambda to them.
  7323. * @param func defines the action to apply on each value.
  7324. */
  7325. forEach(func: (content: T) => void): void;
  7326. /**
  7327. * Sorts the full sets of data.
  7328. * @param compareFn defines the comparison function to apply.
  7329. */
  7330. sort(compareFn: (a: T, b: T) => number): void;
  7331. /**
  7332. * Resets the active data to an empty array.
  7333. */
  7334. reset(): void;
  7335. /**
  7336. * Releases all the data from the array as well as the array.
  7337. */
  7338. dispose(): void;
  7339. /**
  7340. * Concats the active data with a given array.
  7341. * @param array defines the data to concatenate with.
  7342. */
  7343. concat(array: any): void;
  7344. /**
  7345. * Returns the position of a value in the active data.
  7346. * @param value defines the value to find the index for
  7347. * @returns the index if found in the active data otherwise -1
  7348. */
  7349. indexOf(value: T): number;
  7350. /**
  7351. * Returns whether an element is part of the active data.
  7352. * @param value defines the value to look for
  7353. * @returns true if found in the active data otherwise false
  7354. */
  7355. contains(value: T): boolean;
  7356. private static _GlobalId;
  7357. }
  7358. /**
  7359. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7360. * The data in this array can only be present once
  7361. */
  7362. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7363. private _duplicateId;
  7364. /**
  7365. * Pushes a value at the end of the active data.
  7366. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7367. * @param value defines the object to push in the array.
  7368. */
  7369. push(value: T): void;
  7370. /**
  7371. * Pushes a value at the end of the active data.
  7372. * If the data is already present, it won t be added again
  7373. * @param value defines the object to push in the array.
  7374. * @returns true if added false if it was already present
  7375. */
  7376. pushNoDuplicate(value: T): boolean;
  7377. /**
  7378. * Resets the active data to an empty array.
  7379. */
  7380. reset(): void;
  7381. /**
  7382. * Concats the active data with a given array.
  7383. * This ensures no dupplicate will be present in the result.
  7384. * @param array defines the data to concatenate with.
  7385. */
  7386. concatWithNoDuplicate(array: any): void;
  7387. }
  7388. }
  7389. declare module "babylonjs/Materials/multiMaterial" {
  7390. import { Nullable } from "babylonjs/types";
  7391. import { Scene } from "babylonjs/scene";
  7392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7393. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7395. import { Material } from "babylonjs/Materials/material";
  7396. /**
  7397. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7398. * separate meshes. This can be use to improve performances.
  7399. * @see http://doc.babylonjs.com/how_to/multi_materials
  7400. */
  7401. export class MultiMaterial extends Material {
  7402. private _subMaterials;
  7403. /**
  7404. * Gets or Sets the list of Materials used within the multi material.
  7405. * They need to be ordered according to the submeshes order in the associated mesh
  7406. */
  7407. subMaterials: Nullable<Material>[];
  7408. /**
  7409. * Function used to align with Node.getChildren()
  7410. * @returns the list of Materials used within the multi material
  7411. */
  7412. getChildren(): Nullable<Material>[];
  7413. /**
  7414. * Instantiates a new Multi Material
  7415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7416. * separate meshes. This can be use to improve performances.
  7417. * @see http://doc.babylonjs.com/how_to/multi_materials
  7418. * @param name Define the name in the scene
  7419. * @param scene Define the scene the material belongs to
  7420. */
  7421. constructor(name: string, scene: Scene);
  7422. private _hookArray;
  7423. /**
  7424. * Get one of the submaterial by its index in the submaterials array
  7425. * @param index The index to look the sub material at
  7426. * @returns The Material if the index has been defined
  7427. */
  7428. getSubMaterial(index: number): Nullable<Material>;
  7429. /**
  7430. * Get the list of active textures for the whole sub materials list.
  7431. * @returns All the textures that will be used during the rendering
  7432. */
  7433. getActiveTextures(): BaseTexture[];
  7434. /**
  7435. * Gets the current class name of the material e.g. "MultiMaterial"
  7436. * Mainly use in serialization.
  7437. * @returns the class name
  7438. */
  7439. getClassName(): string;
  7440. /**
  7441. * Checks if the material is ready to render the requested sub mesh
  7442. * @param mesh Define the mesh the submesh belongs to
  7443. * @param subMesh Define the sub mesh to look readyness for
  7444. * @param useInstances Define whether or not the material is used with instances
  7445. * @returns true if ready, otherwise false
  7446. */
  7447. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7448. /**
  7449. * Clones the current material and its related sub materials
  7450. * @param name Define the name of the newly cloned material
  7451. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7452. * @returns the cloned material
  7453. */
  7454. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7455. /**
  7456. * Serializes the materials into a JSON representation.
  7457. * @returns the JSON representation
  7458. */
  7459. serialize(): any;
  7460. /**
  7461. * Dispose the material and release its associated resources
  7462. * @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)
  7463. * @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)
  7464. * @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)
  7465. */
  7466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7467. /**
  7468. * Creates a MultiMaterial from parsed MultiMaterial data.
  7469. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7470. * @param scene defines the hosting scene
  7471. * @returns a new MultiMaterial
  7472. */
  7473. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7474. }
  7475. }
  7476. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7477. /**
  7478. * Class used to represent data loading progression
  7479. */
  7480. export class SceneLoaderFlags {
  7481. private static _ForceFullSceneLoadingForIncremental;
  7482. private static _ShowLoadingScreen;
  7483. private static _CleanBoneMatrixWeights;
  7484. private static _loggingLevel;
  7485. /**
  7486. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7487. */
  7488. static ForceFullSceneLoadingForIncremental: boolean;
  7489. /**
  7490. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7491. */
  7492. static ShowLoadingScreen: boolean;
  7493. /**
  7494. * Defines the current logging level (while loading the scene)
  7495. * @ignorenaming
  7496. */
  7497. static loggingLevel: number;
  7498. /**
  7499. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7500. */
  7501. static CleanBoneMatrixWeights: boolean;
  7502. }
  7503. }
  7504. declare module "babylonjs/Meshes/transformNode" {
  7505. import { DeepImmutable } from "babylonjs/types";
  7506. import { Observable } from "babylonjs/Misc/observable";
  7507. import { Nullable } from "babylonjs/types";
  7508. import { Camera } from "babylonjs/Cameras/camera";
  7509. import { Scene } from "babylonjs/scene";
  7510. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7511. import { Node } from "babylonjs/node";
  7512. import { Bone } from "babylonjs/Bones/bone";
  7513. /**
  7514. * 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.
  7515. * @see https://doc.babylonjs.com/how_to/transformnode
  7516. */
  7517. export class TransformNode extends Node {
  7518. /**
  7519. * Object will not rotate to face the camera
  7520. */
  7521. static BILLBOARDMODE_NONE: number;
  7522. /**
  7523. * Object will rotate to face the camera but only on the x axis
  7524. */
  7525. static BILLBOARDMODE_X: number;
  7526. /**
  7527. * Object will rotate to face the camera but only on the y axis
  7528. */
  7529. static BILLBOARDMODE_Y: number;
  7530. /**
  7531. * Object will rotate to face the camera but only on the z axis
  7532. */
  7533. static BILLBOARDMODE_Z: number;
  7534. /**
  7535. * Object will rotate to face the camera
  7536. */
  7537. static BILLBOARDMODE_ALL: number;
  7538. private _forward;
  7539. private _forwardInverted;
  7540. private _up;
  7541. private _right;
  7542. private _rightInverted;
  7543. private _position;
  7544. private _rotation;
  7545. private _rotationQuaternion;
  7546. protected _scaling: Vector3;
  7547. protected _isDirty: boolean;
  7548. private _transformToBoneReferal;
  7549. /**
  7550. * Set the billboard mode. Default is 0.
  7551. *
  7552. * | Value | Type | Description |
  7553. * | --- | --- | --- |
  7554. * | 0 | BILLBOARDMODE_NONE | |
  7555. * | 1 | BILLBOARDMODE_X | |
  7556. * | 2 | BILLBOARDMODE_Y | |
  7557. * | 4 | BILLBOARDMODE_Z | |
  7558. * | 7 | BILLBOARDMODE_ALL | |
  7559. *
  7560. */
  7561. billboardMode: number;
  7562. /**
  7563. * 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
  7564. */
  7565. scalingDeterminant: number;
  7566. /**
  7567. * Sets the distance of the object to max, often used by skybox
  7568. */
  7569. infiniteDistance: boolean;
  7570. /**
  7571. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7572. * By default the system will update normals to compensate
  7573. */
  7574. ignoreNonUniformScaling: boolean;
  7575. /** @hidden */
  7576. _poseMatrix: Matrix;
  7577. /** @hidden */
  7578. _localMatrix: Matrix;
  7579. private _absolutePosition;
  7580. private _pivotMatrix;
  7581. private _pivotMatrixInverse;
  7582. protected _postMultiplyPivotMatrix: boolean;
  7583. private _tempMatrix;
  7584. private _tempMatrix2;
  7585. protected _isWorldMatrixFrozen: boolean;
  7586. /** @hidden */
  7587. _indexInSceneTransformNodesArray: number;
  7588. /**
  7589. * An event triggered after the world matrix is updated
  7590. */
  7591. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7592. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7593. /**
  7594. * Gets a string identifying the name of the class
  7595. * @returns "TransformNode" string
  7596. */
  7597. getClassName(): string;
  7598. /**
  7599. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7600. */
  7601. position: Vector3;
  7602. /**
  7603. * 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)).
  7604. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7605. */
  7606. rotation: Vector3;
  7607. /**
  7608. * 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)).
  7609. */
  7610. scaling: Vector3;
  7611. /**
  7612. * 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).
  7613. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7614. */
  7615. rotationQuaternion: Nullable<Quaternion>;
  7616. /**
  7617. * The forward direction of that transform in world space.
  7618. */
  7619. readonly forward: Vector3;
  7620. /**
  7621. * The up direction of that transform in world space.
  7622. */
  7623. readonly up: Vector3;
  7624. /**
  7625. * The right direction of that transform in world space.
  7626. */
  7627. readonly right: Vector3;
  7628. /**
  7629. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7630. * @param matrix the matrix to copy the pose from
  7631. * @returns this TransformNode.
  7632. */
  7633. updatePoseMatrix(matrix: Matrix): TransformNode;
  7634. /**
  7635. * Returns the mesh Pose matrix.
  7636. * @returns the pose matrix
  7637. */
  7638. getPoseMatrix(): Matrix;
  7639. /** @hidden */
  7640. _isSynchronized(): boolean;
  7641. /** @hidden */
  7642. _initCache(): void;
  7643. /**
  7644. * Flag the transform node as dirty (Forcing it to update everything)
  7645. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7646. * @returns this transform node
  7647. */
  7648. markAsDirty(property: string): TransformNode;
  7649. /**
  7650. * Returns the current mesh absolute position.
  7651. * Returns a Vector3.
  7652. */
  7653. readonly absolutePosition: Vector3;
  7654. /**
  7655. * Sets a new matrix to apply before all other transformation
  7656. * @param matrix defines the transform matrix
  7657. * @returns the current TransformNode
  7658. */
  7659. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7660. /**
  7661. * Sets a new pivot matrix to the current node
  7662. * @param matrix defines the new pivot matrix to use
  7663. * @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
  7664. * @returns the current TransformNode
  7665. */
  7666. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7667. /**
  7668. * Returns the mesh pivot matrix.
  7669. * Default : Identity.
  7670. * @returns the matrix
  7671. */
  7672. getPivotMatrix(): Matrix;
  7673. /**
  7674. * Prevents the World matrix to be computed any longer.
  7675. * @returns the TransformNode.
  7676. */
  7677. freezeWorldMatrix(): TransformNode;
  7678. /**
  7679. * Allows back the World matrix computation.
  7680. * @returns the TransformNode.
  7681. */
  7682. unfreezeWorldMatrix(): this;
  7683. /**
  7684. * True if the World matrix has been frozen.
  7685. */
  7686. readonly isWorldMatrixFrozen: boolean;
  7687. /**
  7688. * Retuns the mesh absolute position in the World.
  7689. * @returns a Vector3.
  7690. */
  7691. getAbsolutePosition(): Vector3;
  7692. /**
  7693. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7694. * @param absolutePosition the absolute position to set
  7695. * @returns the TransformNode.
  7696. */
  7697. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7698. /**
  7699. * Sets the mesh position in its local space.
  7700. * @param vector3 the position to set in localspace
  7701. * @returns the TransformNode.
  7702. */
  7703. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7704. /**
  7705. * Returns the mesh position in the local space from the current World matrix values.
  7706. * @returns a new Vector3.
  7707. */
  7708. getPositionExpressedInLocalSpace(): Vector3;
  7709. /**
  7710. * Translates the mesh along the passed Vector3 in its local space.
  7711. * @param vector3 the distance to translate in localspace
  7712. * @returns the TransformNode.
  7713. */
  7714. locallyTranslate(vector3: Vector3): TransformNode;
  7715. private static _lookAtVectorCache;
  7716. /**
  7717. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7718. * @param targetPoint the position (must be in same space as current mesh) to look at
  7719. * @param yawCor optional yaw (y-axis) correction in radians
  7720. * @param pitchCor optional pitch (x-axis) correction in radians
  7721. * @param rollCor optional roll (z-axis) correction in radians
  7722. * @param space the choosen space of the target
  7723. * @returns the TransformNode.
  7724. */
  7725. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7726. /**
  7727. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7728. * This Vector3 is expressed in the World space.
  7729. * @param localAxis axis to rotate
  7730. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7731. */
  7732. getDirection(localAxis: Vector3): Vector3;
  7733. /**
  7734. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7735. * localAxis is expressed in the mesh local space.
  7736. * result is computed in the Wordl space from the mesh World matrix.
  7737. * @param localAxis axis to rotate
  7738. * @param result the resulting transformnode
  7739. * @returns this TransformNode.
  7740. */
  7741. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7742. /**
  7743. * Sets this transform node rotation to the given local axis.
  7744. * @param localAxis the axis in local space
  7745. * @param yawCor optional yaw (y-axis) correction in radians
  7746. * @param pitchCor optional pitch (x-axis) correction in radians
  7747. * @param rollCor optional roll (z-axis) correction in radians
  7748. * @returns this TransformNode
  7749. */
  7750. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7751. /**
  7752. * Sets a new pivot point to the current node
  7753. * @param point defines the new pivot point to use
  7754. * @param space defines if the point is in world or local space (local by default)
  7755. * @returns the current TransformNode
  7756. */
  7757. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7758. /**
  7759. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7760. * @returns the pivot point
  7761. */
  7762. getPivotPoint(): Vector3;
  7763. /**
  7764. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7765. * @param result the vector3 to store the result
  7766. * @returns this TransformNode.
  7767. */
  7768. getPivotPointToRef(result: Vector3): TransformNode;
  7769. /**
  7770. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7771. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7772. */
  7773. getAbsolutePivotPoint(): Vector3;
  7774. /**
  7775. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7776. * @param result vector3 to store the result
  7777. * @returns this TransformNode.
  7778. */
  7779. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7780. /**
  7781. * Defines the passed node as the parent of the current node.
  7782. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7783. * @param node the node ot set as the parent
  7784. * @returns this TransformNode.
  7785. */
  7786. setParent(node: Nullable<Node>): TransformNode;
  7787. private _nonUniformScaling;
  7788. /**
  7789. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7790. */
  7791. readonly nonUniformScaling: boolean;
  7792. /** @hidden */
  7793. _updateNonUniformScalingState(value: boolean): boolean;
  7794. /**
  7795. * Attach the current TransformNode to another TransformNode associated with a bone
  7796. * @param bone Bone affecting the TransformNode
  7797. * @param affectedTransformNode TransformNode associated with the bone
  7798. * @returns this object
  7799. */
  7800. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7801. /**
  7802. * Detach the transform node if its associated with a bone
  7803. * @returns this object
  7804. */
  7805. detachFromBone(): TransformNode;
  7806. private static _rotationAxisCache;
  7807. /**
  7808. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7809. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7810. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7811. * The passed axis is also normalized.
  7812. * @param axis the axis to rotate around
  7813. * @param amount the amount to rotate in radians
  7814. * @param space Space to rotate in (Default: local)
  7815. * @returns the TransformNode.
  7816. */
  7817. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7818. /**
  7819. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7820. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7821. * The passed axis is also normalized. .
  7822. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7823. * @param point the point to rotate around
  7824. * @param axis the axis to rotate around
  7825. * @param amount the amount to rotate in radians
  7826. * @returns the TransformNode
  7827. */
  7828. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7829. /**
  7830. * Translates the mesh along the axis vector for the passed distance in the given space.
  7831. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7832. * @param axis the axis to translate in
  7833. * @param distance the distance to translate
  7834. * @param space Space to rotate in (Default: local)
  7835. * @returns the TransformNode.
  7836. */
  7837. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7838. /**
  7839. * Adds a rotation step to the mesh current rotation.
  7840. * x, y, z are Euler angles expressed in radians.
  7841. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7842. * This means this rotation is made in the mesh local space only.
  7843. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7844. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7845. * ```javascript
  7846. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7847. * ```
  7848. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7849. * 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.
  7850. * @param x Rotation to add
  7851. * @param y Rotation to add
  7852. * @param z Rotation to add
  7853. * @returns the TransformNode.
  7854. */
  7855. addRotation(x: number, y: number, z: number): TransformNode;
  7856. /**
  7857. * Computes the world matrix of the node
  7858. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7859. * @returns the world matrix
  7860. */
  7861. computeWorldMatrix(force?: boolean): Matrix;
  7862. protected _afterComputeWorldMatrix(): void;
  7863. /**
  7864. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7865. * @param func callback function to add
  7866. *
  7867. * @returns the TransformNode.
  7868. */
  7869. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7870. /**
  7871. * Removes a registered callback function.
  7872. * @param func callback function to remove
  7873. * @returns the TransformNode.
  7874. */
  7875. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7876. /**
  7877. * Gets the position of the current mesh in camera space
  7878. * @param camera defines the camera to use
  7879. * @returns a position
  7880. */
  7881. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7882. /**
  7883. * Returns the distance from the mesh to the active camera
  7884. * @param camera defines the camera to use
  7885. * @returns the distance
  7886. */
  7887. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7888. /**
  7889. * Clone the current transform node
  7890. * @param name Name of the new clone
  7891. * @param newParent New parent for the clone
  7892. * @param doNotCloneChildren Do not clone children hierarchy
  7893. * @returns the new transform node
  7894. */
  7895. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7896. /**
  7897. * Serializes the objects information.
  7898. * @param currentSerializationObject defines the object to serialize in
  7899. * @returns the serialized object
  7900. */
  7901. serialize(currentSerializationObject?: any): any;
  7902. /**
  7903. * Returns a new TransformNode object parsed from the source provided.
  7904. * @param parsedTransformNode is the source.
  7905. * @param scene the scne the object belongs to
  7906. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7907. * @returns a new TransformNode object parsed from the source provided.
  7908. */
  7909. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7910. /**
  7911. * Get all child-transformNodes of this node
  7912. * @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
  7913. * @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
  7914. * @returns an array of TransformNode
  7915. */
  7916. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7917. /**
  7918. * Releases resources associated with this transform node.
  7919. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7920. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7921. */
  7922. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7923. }
  7924. }
  7925. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7926. /**
  7927. * Class used to override all child animations of a given target
  7928. */
  7929. export class AnimationPropertiesOverride {
  7930. /**
  7931. * Gets or sets a value indicating if animation blending must be used
  7932. */
  7933. enableBlending: boolean;
  7934. /**
  7935. * Gets or sets the blending speed to use when enableBlending is true
  7936. */
  7937. blendingSpeed: number;
  7938. /**
  7939. * Gets or sets the default loop mode to use
  7940. */
  7941. loopMode: number;
  7942. }
  7943. }
  7944. declare module "babylonjs/Bones/bone" {
  7945. import { Skeleton } from "babylonjs/Bones/skeleton";
  7946. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7947. import { Nullable } from "babylonjs/types";
  7948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7949. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7950. import { Node } from "babylonjs/node";
  7951. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7952. /**
  7953. * Class used to store bone information
  7954. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7955. */
  7956. export class Bone extends Node {
  7957. /**
  7958. * defines the bone name
  7959. */
  7960. name: string;
  7961. private static _tmpVecs;
  7962. private static _tmpQuat;
  7963. private static _tmpMats;
  7964. /**
  7965. * Gets the list of child bones
  7966. */
  7967. children: Bone[];
  7968. /** Gets the animations associated with this bone */
  7969. animations: import("babylonjs/Animations/animation").Animation[];
  7970. /**
  7971. * Gets or sets bone length
  7972. */
  7973. length: number;
  7974. /**
  7975. * @hidden Internal only
  7976. * Set this value to map this bone to a different index in the transform matrices
  7977. * Set this value to -1 to exclude the bone from the transform matrices
  7978. */
  7979. _index: Nullable<number>;
  7980. private _skeleton;
  7981. private _localMatrix;
  7982. private _restPose;
  7983. private _baseMatrix;
  7984. private _absoluteTransform;
  7985. private _invertedAbsoluteTransform;
  7986. private _parent;
  7987. private _scalingDeterminant;
  7988. private _worldTransform;
  7989. private _localScaling;
  7990. private _localRotation;
  7991. private _localPosition;
  7992. private _needToDecompose;
  7993. private _needToCompose;
  7994. /** @hidden */
  7995. _linkedTransformNode: Nullable<TransformNode>;
  7996. /** @hidden */
  7997. /** @hidden */
  7998. _matrix: Matrix;
  7999. /**
  8000. * Create a new bone
  8001. * @param name defines the bone name
  8002. * @param skeleton defines the parent skeleton
  8003. * @param parentBone defines the parent (can be null if the bone is the root)
  8004. * @param localMatrix defines the local matrix
  8005. * @param restPose defines the rest pose matrix
  8006. * @param baseMatrix defines the base matrix
  8007. * @param index defines index of the bone in the hiearchy
  8008. */
  8009. constructor(
  8010. /**
  8011. * defines the bone name
  8012. */
  8013. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8014. /**
  8015. * Gets the current object class name.
  8016. * @return the class name
  8017. */
  8018. getClassName(): string;
  8019. /**
  8020. * Gets the parent skeleton
  8021. * @returns a skeleton
  8022. */
  8023. getSkeleton(): Skeleton;
  8024. /**
  8025. * Gets parent bone
  8026. * @returns a bone or null if the bone is the root of the bone hierarchy
  8027. */
  8028. getParent(): Nullable<Bone>;
  8029. /**
  8030. * Returns an array containing the root bones
  8031. * @returns an array containing the root bones
  8032. */
  8033. getChildren(): Array<Bone>;
  8034. /**
  8035. * Sets the parent bone
  8036. * @param parent defines the parent (can be null if the bone is the root)
  8037. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8038. */
  8039. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8040. /**
  8041. * Gets the local matrix
  8042. * @returns a matrix
  8043. */
  8044. getLocalMatrix(): Matrix;
  8045. /**
  8046. * Gets the base matrix (initial matrix which remains unchanged)
  8047. * @returns a matrix
  8048. */
  8049. getBaseMatrix(): Matrix;
  8050. /**
  8051. * Gets the rest pose matrix
  8052. * @returns a matrix
  8053. */
  8054. getRestPose(): Matrix;
  8055. /**
  8056. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8057. */
  8058. getWorldMatrix(): Matrix;
  8059. /**
  8060. * Sets the local matrix to rest pose matrix
  8061. */
  8062. returnToRest(): void;
  8063. /**
  8064. * Gets the inverse of the absolute transform matrix.
  8065. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8066. * @returns a matrix
  8067. */
  8068. getInvertedAbsoluteTransform(): Matrix;
  8069. /**
  8070. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8071. * @returns a matrix
  8072. */
  8073. getAbsoluteTransform(): Matrix;
  8074. /**
  8075. * Links with the given transform node.
  8076. * The local matrix of this bone is copied from the transform node every frame.
  8077. * @param transformNode defines the transform node to link to
  8078. */
  8079. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8080. /** Gets or sets current position (in local space) */
  8081. position: Vector3;
  8082. /** Gets or sets current rotation (in local space) */
  8083. rotation: Vector3;
  8084. /** Gets or sets current rotation quaternion (in local space) */
  8085. rotationQuaternion: Quaternion;
  8086. /** Gets or sets current scaling (in local space) */
  8087. scaling: Vector3;
  8088. /**
  8089. * Gets the animation properties override
  8090. */
  8091. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8092. private _decompose;
  8093. private _compose;
  8094. /**
  8095. * Update the base and local matrices
  8096. * @param matrix defines the new base or local matrix
  8097. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8098. * @param updateLocalMatrix defines if the local matrix should be updated
  8099. */
  8100. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8101. /** @hidden */
  8102. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8103. /**
  8104. * Flag the bone as dirty (Forcing it to update everything)
  8105. */
  8106. markAsDirty(): void;
  8107. private _markAsDirtyAndCompose;
  8108. private _markAsDirtyAndDecompose;
  8109. /**
  8110. * Translate the bone in local or world space
  8111. * @param vec The amount to translate the bone
  8112. * @param space The space that the translation is in
  8113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8114. */
  8115. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8116. /**
  8117. * Set the postion of the bone in local or world space
  8118. * @param position The position to set the bone
  8119. * @param space The space that the position is in
  8120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8121. */
  8122. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8123. /**
  8124. * Set the absolute position of the bone (world space)
  8125. * @param position The position to set the bone
  8126. * @param mesh The mesh that this bone is attached to
  8127. */
  8128. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8129. /**
  8130. * Scale the bone on the x, y and z axes (in local space)
  8131. * @param x The amount to scale the bone on the x axis
  8132. * @param y The amount to scale the bone on the y axis
  8133. * @param z The amount to scale the bone on the z axis
  8134. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8135. */
  8136. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8137. /**
  8138. * Set the bone scaling in local space
  8139. * @param scale defines the scaling vector
  8140. */
  8141. setScale(scale: Vector3): void;
  8142. /**
  8143. * Gets the current scaling in local space
  8144. * @returns the current scaling vector
  8145. */
  8146. getScale(): Vector3;
  8147. /**
  8148. * Gets the current scaling in local space and stores it in a target vector
  8149. * @param result defines the target vector
  8150. */
  8151. getScaleToRef(result: Vector3): void;
  8152. /**
  8153. * Set the yaw, pitch, and roll of the bone in local or world space
  8154. * @param yaw The rotation of the bone on the y axis
  8155. * @param pitch The rotation of the bone on the x axis
  8156. * @param roll The rotation of the bone on the z axis
  8157. * @param space The space that the axes of rotation are in
  8158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8159. */
  8160. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8161. /**
  8162. * Add a rotation to the bone on an axis in local or world space
  8163. * @param axis The axis to rotate the bone on
  8164. * @param amount The amount to rotate the bone
  8165. * @param space The space that the axis is in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. */
  8168. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8169. /**
  8170. * Set the rotation of the bone to a particular axis angle in local or world space
  8171. * @param axis The axis to rotate the bone on
  8172. * @param angle The angle that the bone should be rotated to
  8173. * @param space The space that the axis is in
  8174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8175. */
  8176. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8177. /**
  8178. * Set the euler rotation of the bone in local of world space
  8179. * @param rotation The euler rotation that the bone should be set to
  8180. * @param space The space that the rotation is in
  8181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8182. */
  8183. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8184. /**
  8185. * Set the quaternion rotation of the bone in local of world space
  8186. * @param quat The quaternion rotation that the bone should be set to
  8187. * @param space The space that the rotation is in
  8188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8189. */
  8190. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8191. /**
  8192. * Set the rotation matrix of the bone in local of world space
  8193. * @param rotMat The rotation matrix that the bone should be set to
  8194. * @param space The space that the rotation is in
  8195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8196. */
  8197. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8198. private _rotateWithMatrix;
  8199. private _getNegativeRotationToRef;
  8200. /**
  8201. * Get the position of the bone in local or world space
  8202. * @param space The space that the returned position is in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @returns The position of the bone
  8205. */
  8206. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8207. /**
  8208. * Copy the position of the bone to a vector3 in local or world space
  8209. * @param space The space that the returned position is in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @param result The vector3 to copy the position to
  8212. */
  8213. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8214. /**
  8215. * Get the absolute position of the bone (world space)
  8216. * @param mesh The mesh that this bone is attached to
  8217. * @returns The absolute position of the bone
  8218. */
  8219. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8220. /**
  8221. * Copy the absolute position of the bone (world space) to the result param
  8222. * @param mesh The mesh that this bone is attached to
  8223. * @param result The vector3 to copy the absolute position to
  8224. */
  8225. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8226. /**
  8227. * Compute the absolute transforms of this bone and its children
  8228. */
  8229. computeAbsoluteTransforms(): void;
  8230. /**
  8231. * Get the world direction from an axis that is in the local space of the bone
  8232. * @param localAxis The local direction that is used to compute the world direction
  8233. * @param mesh The mesh that this bone is attached to
  8234. * @returns The world direction
  8235. */
  8236. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8237. /**
  8238. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8239. * @param localAxis The local direction that is used to compute the world direction
  8240. * @param mesh The mesh that this bone is attached to
  8241. * @param result The vector3 that the world direction will be copied to
  8242. */
  8243. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8244. /**
  8245. * Get the euler rotation of the bone in local or world space
  8246. * @param space The space that the rotation should be in
  8247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8248. * @returns The euler rotation
  8249. */
  8250. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8251. /**
  8252. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8253. * @param space The space that the rotation should be in
  8254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8255. * @param result The vector3 that the rotation should be copied to
  8256. */
  8257. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8258. /**
  8259. * Get the quaternion rotation of the bone in either local or world space
  8260. * @param space The space that the rotation should be in
  8261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8262. * @returns The quaternion rotation
  8263. */
  8264. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8265. /**
  8266. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8267. * @param space The space that the rotation should be in
  8268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8269. * @param result The quaternion that the rotation should be copied to
  8270. */
  8271. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8272. /**
  8273. * Get the rotation matrix of the bone in local or world space
  8274. * @param space The space that the rotation should be in
  8275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8276. * @returns The rotation matrix
  8277. */
  8278. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8279. /**
  8280. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8281. * @param space The space that the rotation should be in
  8282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8283. * @param result The quaternion that the rotation should be copied to
  8284. */
  8285. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8286. /**
  8287. * Get the world position of a point that is in the local space of the bone
  8288. * @param position The local position
  8289. * @param mesh The mesh that this bone is attached to
  8290. * @returns The world position
  8291. */
  8292. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8293. /**
  8294. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8295. * @param position The local position
  8296. * @param mesh The mesh that this bone is attached to
  8297. * @param result The vector3 that the world position should be copied to
  8298. */
  8299. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8300. /**
  8301. * Get the local position of a point that is in world space
  8302. * @param position The world position
  8303. * @param mesh The mesh that this bone is attached to
  8304. * @returns The local position
  8305. */
  8306. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8307. /**
  8308. * Get the local position of a point that is in world space and copy it to the result param
  8309. * @param position The world position
  8310. * @param mesh The mesh that this bone is attached to
  8311. * @param result The vector3 that the local position should be copied to
  8312. */
  8313. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8314. }
  8315. }
  8316. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8317. import { Nullable } from "babylonjs/types";
  8318. import { Scene } from "babylonjs/scene";
  8319. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8321. /**
  8322. * Class for creating a cube texture
  8323. */
  8324. export class CubeTexture extends BaseTexture {
  8325. private _delayedOnLoad;
  8326. /**
  8327. * The url of the texture
  8328. */
  8329. url: string;
  8330. /**
  8331. * Gets or sets the center of the bounding box associated with the cube texture.
  8332. * It must define where the camera used to render the texture was set
  8333. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8334. */
  8335. boundingBoxPosition: Vector3;
  8336. private _boundingBoxSize;
  8337. /**
  8338. * Gets or sets the size of the bounding box associated with the cube texture
  8339. * When defined, the cubemap will switch to local mode
  8340. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8341. * @example https://www.babylonjs-playground.com/#RNASML
  8342. */
  8343. /**
  8344. * Returns the bounding box size
  8345. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8346. */
  8347. boundingBoxSize: Vector3;
  8348. protected _rotationY: number;
  8349. /**
  8350. * Sets texture matrix rotation angle around Y axis in radians.
  8351. */
  8352. /**
  8353. * Gets texture matrix rotation angle around Y axis radians.
  8354. */
  8355. rotationY: number;
  8356. /**
  8357. * Are mip maps generated for this texture or not.
  8358. */
  8359. readonly noMipmap: boolean;
  8360. private _noMipmap;
  8361. private _files;
  8362. private _extensions;
  8363. private _textureMatrix;
  8364. private _format;
  8365. private _createPolynomials;
  8366. /** @hidden */
  8367. _prefiltered: boolean;
  8368. /**
  8369. * Creates a cube texture from an array of image urls
  8370. * @param files defines an array of image urls
  8371. * @param scene defines the hosting scene
  8372. * @param noMipmap specifies if mip maps are not used
  8373. * @returns a cube texture
  8374. */
  8375. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8376. /**
  8377. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8378. * @param url defines the url of the prefiltered texture
  8379. * @param scene defines the scene the texture is attached to
  8380. * @param forcedExtension defines the extension of the file if different from the url
  8381. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8382. * @return the prefiltered texture
  8383. */
  8384. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8385. /**
  8386. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8387. * as prefiltered data.
  8388. * @param rootUrl defines the url of the texture or the root name of the six images
  8389. * @param scene defines the scene the texture is attached to
  8390. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8391. * @param noMipmap defines if mipmaps should be created or not
  8392. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8393. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8394. * @param onError defines a callback triggered in case of error during load
  8395. * @param format defines the internal format to use for the texture once loaded
  8396. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8397. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8398. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8399. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8400. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8401. * @return the cube texture
  8402. */
  8403. 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);
  8404. /**
  8405. * Get the current class name of the texture useful for serialization or dynamic coding.
  8406. * @returns "CubeTexture"
  8407. */
  8408. getClassName(): string;
  8409. /**
  8410. * Update the url (and optional buffer) of this texture if url was null during construction.
  8411. * @param url the url of the texture
  8412. * @param forcedExtension defines the extension to use
  8413. * @param onLoad callback called when the texture is loaded (defaults to null)
  8414. */
  8415. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8416. /**
  8417. * Delays loading of the cube texture
  8418. * @param forcedExtension defines the extension to use
  8419. */
  8420. delayLoad(forcedExtension?: string): void;
  8421. /**
  8422. * Returns the reflection texture matrix
  8423. * @returns the reflection texture matrix
  8424. */
  8425. getReflectionTextureMatrix(): Matrix;
  8426. /**
  8427. * Sets the reflection texture matrix
  8428. * @param value Reflection texture matrix
  8429. */
  8430. setReflectionTextureMatrix(value: Matrix): void;
  8431. /**
  8432. * Parses text to create a cube texture
  8433. * @param parsedTexture define the serialized text to read from
  8434. * @param scene defines the hosting scene
  8435. * @param rootUrl defines the root url of the cube texture
  8436. * @returns a cube texture
  8437. */
  8438. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8439. /**
  8440. * Makes a clone, or deep copy, of the cube texture
  8441. * @returns a new cube texture
  8442. */
  8443. clone(): CubeTexture;
  8444. }
  8445. }
  8446. declare module "babylonjs/Shaders/postprocess.vertex" {
  8447. /** @hidden */
  8448. export var postprocessVertexShader: {
  8449. name: string;
  8450. shader: string;
  8451. };
  8452. }
  8453. declare module "babylonjs/Cameras/targetCamera" {
  8454. import { Nullable } from "babylonjs/types";
  8455. import { Camera } from "babylonjs/Cameras/camera";
  8456. import { Scene } from "babylonjs/scene";
  8457. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8458. /**
  8459. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8460. * This is the base of the follow, arc rotate cameras and Free camera
  8461. * @see http://doc.babylonjs.com/features/cameras
  8462. */
  8463. export class TargetCamera extends Camera {
  8464. private static _RigCamTransformMatrix;
  8465. private static _TargetTransformMatrix;
  8466. private static _TargetFocalPoint;
  8467. /**
  8468. * Define the current direction the camera is moving to
  8469. */
  8470. cameraDirection: Vector3;
  8471. /**
  8472. * Define the current rotation the camera is rotating to
  8473. */
  8474. cameraRotation: Vector2;
  8475. /**
  8476. * When set, the up vector of the camera will be updated by the rotation of the camera
  8477. */
  8478. updateUpVectorFromRotation: boolean;
  8479. private _tmpQuaternion;
  8480. /**
  8481. * Define the current rotation of the camera
  8482. */
  8483. rotation: Vector3;
  8484. /**
  8485. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8486. */
  8487. rotationQuaternion: Quaternion;
  8488. /**
  8489. * Define the current speed of the camera
  8490. */
  8491. speed: number;
  8492. /**
  8493. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8494. * around all axis.
  8495. */
  8496. noRotationConstraint: boolean;
  8497. /**
  8498. * Define the current target of the camera as an object or a position.
  8499. */
  8500. lockedTarget: any;
  8501. /** @hidden */
  8502. _currentTarget: Vector3;
  8503. /** @hidden */
  8504. _initialFocalDistance: number;
  8505. /** @hidden */
  8506. _viewMatrix: Matrix;
  8507. /** @hidden */
  8508. _camMatrix: Matrix;
  8509. /** @hidden */
  8510. _cameraTransformMatrix: Matrix;
  8511. /** @hidden */
  8512. _cameraRotationMatrix: Matrix;
  8513. /** @hidden */
  8514. _referencePoint: Vector3;
  8515. /** @hidden */
  8516. _transformedReferencePoint: Vector3;
  8517. protected _globalCurrentTarget: Vector3;
  8518. protected _globalCurrentUpVector: Vector3;
  8519. /** @hidden */
  8520. _reset: () => void;
  8521. private _defaultUp;
  8522. /**
  8523. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8524. * This is the base of the follow, arc rotate cameras and Free camera
  8525. * @see http://doc.babylonjs.com/features/cameras
  8526. * @param name Defines the name of the camera in the scene
  8527. * @param position Defines the start position of the camera in the scene
  8528. * @param scene Defines the scene the camera belongs to
  8529. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8530. */
  8531. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8532. /**
  8533. * Gets the position in front of the camera at a given distance.
  8534. * @param distance The distance from the camera we want the position to be
  8535. * @returns the position
  8536. */
  8537. getFrontPosition(distance: number): Vector3;
  8538. /** @hidden */
  8539. _getLockedTargetPosition(): Nullable<Vector3>;
  8540. private _storedPosition;
  8541. private _storedRotation;
  8542. private _storedRotationQuaternion;
  8543. /**
  8544. * Store current camera state of the camera (fov, position, rotation, etc..)
  8545. * @returns the camera
  8546. */
  8547. storeState(): Camera;
  8548. /**
  8549. * Restored camera state. You must call storeState() first
  8550. * @returns whether it was successful or not
  8551. * @hidden
  8552. */
  8553. _restoreStateValues(): boolean;
  8554. /** @hidden */
  8555. _initCache(): void;
  8556. /** @hidden */
  8557. _updateCache(ignoreParentClass?: boolean): void;
  8558. /** @hidden */
  8559. _isSynchronizedViewMatrix(): boolean;
  8560. /** @hidden */
  8561. _computeLocalCameraSpeed(): number;
  8562. /**
  8563. * Defines the target the camera should look at.
  8564. * This will automatically adapt alpha beta and radius to fit within the new target.
  8565. * @param target Defines the new target as a Vector or a mesh
  8566. */
  8567. setTarget(target: Vector3): void;
  8568. /**
  8569. * Return the current target position of the camera. This value is expressed in local space.
  8570. * @returns the target position
  8571. */
  8572. getTarget(): Vector3;
  8573. /** @hidden */
  8574. _decideIfNeedsToMove(): boolean;
  8575. /** @hidden */
  8576. _updatePosition(): void;
  8577. /** @hidden */
  8578. _checkInputs(): void;
  8579. protected _updateCameraRotationMatrix(): void;
  8580. /**
  8581. * 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)
  8582. * @returns the current camera
  8583. */
  8584. private _rotateUpVectorWithCameraRotationMatrix;
  8585. private _cachedRotationZ;
  8586. private _cachedQuaternionRotationZ;
  8587. /** @hidden */
  8588. _getViewMatrix(): Matrix;
  8589. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8590. /**
  8591. * @hidden
  8592. */
  8593. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8594. /**
  8595. * @hidden
  8596. */
  8597. _updateRigCameras(): void;
  8598. private _getRigCamPositionAndTarget;
  8599. /**
  8600. * Gets the current object class name.
  8601. * @return the class name
  8602. */
  8603. getClassName(): string;
  8604. }
  8605. }
  8606. declare module "babylonjs/Cameras/cameraInputsManager" {
  8607. import { Nullable } from "babylonjs/types";
  8608. import { Camera } from "babylonjs/Cameras/camera";
  8609. /**
  8610. * @ignore
  8611. * This is a list of all the different input types that are available in the application.
  8612. * Fo instance: ArcRotateCameraGamepadInput...
  8613. */
  8614. export var CameraInputTypes: {};
  8615. /**
  8616. * This is the contract to implement in order to create a new input class.
  8617. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8618. */
  8619. export interface ICameraInput<TCamera extends Camera> {
  8620. /**
  8621. * Defines the camera the input is attached to.
  8622. */
  8623. camera: Nullable<TCamera>;
  8624. /**
  8625. * Gets the class name of the current intput.
  8626. * @returns the class name
  8627. */
  8628. getClassName(): string;
  8629. /**
  8630. * Get the friendly name associated with the input class.
  8631. * @returns the input friendly name
  8632. */
  8633. getSimpleName(): string;
  8634. /**
  8635. * Attach the input controls to a specific dom element to get the input from.
  8636. * @param element Defines the element the controls should be listened 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. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8640. /**
  8641. * Detach the current controls from the specified dom element.
  8642. * @param element Defines the element to stop listening the inputs from
  8643. */
  8644. detachControl(element: Nullable<HTMLElement>): void;
  8645. /**
  8646. * Update the current camera state depending on the inputs that have been used this frame.
  8647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8648. */
  8649. checkInputs?: () => void;
  8650. }
  8651. /**
  8652. * Represents a map of input types to input instance or input index to input instance.
  8653. */
  8654. export interface CameraInputsMap<TCamera extends Camera> {
  8655. /**
  8656. * Accessor to the input by input type.
  8657. */
  8658. [name: string]: ICameraInput<TCamera>;
  8659. /**
  8660. * Accessor to the input by input index.
  8661. */
  8662. [idx: number]: ICameraInput<TCamera>;
  8663. }
  8664. /**
  8665. * This represents the input manager used within a camera.
  8666. * It helps dealing with all the different kind of input attached to a camera.
  8667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8668. */
  8669. export class CameraInputsManager<TCamera extends Camera> {
  8670. /**
  8671. * Defines the list of inputs attahed to the camera.
  8672. */
  8673. attached: CameraInputsMap<TCamera>;
  8674. /**
  8675. * Defines the dom element the camera is collecting inputs from.
  8676. * This is null if the controls have not been attached.
  8677. */
  8678. attachedElement: Nullable<HTMLElement>;
  8679. /**
  8680. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8681. */
  8682. noPreventDefault: boolean;
  8683. /**
  8684. * Defined the camera the input manager belongs to.
  8685. */
  8686. camera: TCamera;
  8687. /**
  8688. * Update the current camera state depending on the inputs that have been used this frame.
  8689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8690. */
  8691. checkInputs: () => void;
  8692. /**
  8693. * Instantiate a new Camera Input Manager.
  8694. * @param camera Defines the camera the input manager blongs to
  8695. */
  8696. constructor(camera: TCamera);
  8697. /**
  8698. * Add an input method to a camera
  8699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8700. * @param input camera input method
  8701. */
  8702. add(input: ICameraInput<TCamera>): void;
  8703. /**
  8704. * Remove a specific input method from a camera
  8705. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8706. * @param inputToRemove camera input method
  8707. */
  8708. remove(inputToRemove: ICameraInput<TCamera>): void;
  8709. /**
  8710. * Remove a specific input type from a camera
  8711. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8712. * @param inputType the type of the input to remove
  8713. */
  8714. removeByType(inputType: string): void;
  8715. private _addCheckInputs;
  8716. /**
  8717. * Attach the input controls to the currently attached dom element to listen the events from.
  8718. * @param input Defines the input to attach
  8719. */
  8720. attachInput(input: ICameraInput<TCamera>): void;
  8721. /**
  8722. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8723. * @param element Defines the dom element to collect the events from
  8724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8725. */
  8726. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8727. /**
  8728. * Detach the current manager inputs controls from a specific dom element.
  8729. * @param element Defines the dom element to collect the events from
  8730. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8731. */
  8732. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8733. /**
  8734. * Rebuild the dynamic inputCheck function from the current list of
  8735. * defined inputs in the manager.
  8736. */
  8737. rebuildInputCheck(): void;
  8738. /**
  8739. * Remove all attached input methods from a camera
  8740. */
  8741. clear(): void;
  8742. /**
  8743. * Serialize the current input manager attached to a camera.
  8744. * This ensures than once parsed,
  8745. * the input associated to the camera will be identical to the current ones
  8746. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8747. */
  8748. serialize(serializedCamera: any): void;
  8749. /**
  8750. * Parses an input manager serialized JSON to restore the previous list of inputs
  8751. * and states associated to a camera.
  8752. * @param parsedCamera Defines the JSON to parse
  8753. */
  8754. parse(parsedCamera: any): void;
  8755. }
  8756. }
  8757. declare module "babylonjs/Events/keyboardEvents" {
  8758. /**
  8759. * Gather the list of keyboard event types as constants.
  8760. */
  8761. export class KeyboardEventTypes {
  8762. /**
  8763. * The keydown event is fired when a key becomes active (pressed).
  8764. */
  8765. static readonly KEYDOWN: number;
  8766. /**
  8767. * The keyup event is fired when a key has been released.
  8768. */
  8769. static readonly KEYUP: number;
  8770. }
  8771. /**
  8772. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8773. */
  8774. export class KeyboardInfo {
  8775. /**
  8776. * Defines the type of event (KeyboardEventTypes)
  8777. */
  8778. type: number;
  8779. /**
  8780. * Defines the related dom event
  8781. */
  8782. event: KeyboardEvent;
  8783. /**
  8784. * Instantiates a new keyboard info.
  8785. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8786. * @param type Defines the type of event (KeyboardEventTypes)
  8787. * @param event Defines the related dom event
  8788. */
  8789. constructor(
  8790. /**
  8791. * Defines the type of event (KeyboardEventTypes)
  8792. */
  8793. type: number,
  8794. /**
  8795. * Defines the related dom event
  8796. */
  8797. event: KeyboardEvent);
  8798. }
  8799. /**
  8800. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8801. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8802. */
  8803. export class KeyboardInfoPre extends KeyboardInfo {
  8804. /**
  8805. * Defines the type of event (KeyboardEventTypes)
  8806. */
  8807. type: number;
  8808. /**
  8809. * Defines the related dom event
  8810. */
  8811. event: KeyboardEvent;
  8812. /**
  8813. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8814. */
  8815. skipOnPointerObservable: boolean;
  8816. /**
  8817. * Instantiates a new keyboard pre info.
  8818. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8819. * @param type Defines the type of event (KeyboardEventTypes)
  8820. * @param event Defines the related dom event
  8821. */
  8822. constructor(
  8823. /**
  8824. * Defines the type of event (KeyboardEventTypes)
  8825. */
  8826. type: number,
  8827. /**
  8828. * Defines the related dom event
  8829. */
  8830. event: KeyboardEvent);
  8831. }
  8832. }
  8833. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8834. import { Nullable } from "babylonjs/types";
  8835. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8836. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8837. /**
  8838. * Manage the keyboard inputs to control the movement of a free camera.
  8839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8840. */
  8841. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8842. /**
  8843. * Defines the camera the input is attached to.
  8844. */
  8845. camera: FreeCamera;
  8846. /**
  8847. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8848. */
  8849. keysUp: number[];
  8850. /**
  8851. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8852. */
  8853. keysDown: number[];
  8854. /**
  8855. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8856. */
  8857. keysLeft: number[];
  8858. /**
  8859. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8860. */
  8861. keysRight: number[];
  8862. private _keys;
  8863. private _onCanvasBlurObserver;
  8864. private _onKeyboardObserver;
  8865. private _engine;
  8866. private _scene;
  8867. /**
  8868. * Attach the input controls to a specific dom element to get the input from.
  8869. * @param element Defines the element the controls should be listened from
  8870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8871. */
  8872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8873. /**
  8874. * Detach the current controls from the specified dom element.
  8875. * @param element Defines the element to stop listening the inputs from
  8876. */
  8877. detachControl(element: Nullable<HTMLElement>): void;
  8878. /**
  8879. * Update the current camera state depending on the inputs that have been used this frame.
  8880. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8881. */
  8882. checkInputs(): void;
  8883. /**
  8884. * Gets the class name of the current intput.
  8885. * @returns the class name
  8886. */
  8887. getClassName(): string;
  8888. /** @hidden */
  8889. _onLostFocus(): void;
  8890. /**
  8891. * Get the friendly name associated with the input class.
  8892. * @returns the input friendly name
  8893. */
  8894. getSimpleName(): string;
  8895. }
  8896. }
  8897. declare module "babylonjs/Lights/shadowLight" {
  8898. import { Camera } from "babylonjs/Cameras/camera";
  8899. import { Scene } from "babylonjs/scene";
  8900. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8902. import { Light } from "babylonjs/Lights/light";
  8903. /**
  8904. * Interface describing all the common properties and methods a shadow light needs to implement.
  8905. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8906. * as well as binding the different shadow properties to the effects.
  8907. */
  8908. export interface IShadowLight extends Light {
  8909. /**
  8910. * The light id in the scene (used in scene.findLighById for instance)
  8911. */
  8912. id: string;
  8913. /**
  8914. * The position the shdow will be casted from.
  8915. */
  8916. position: Vector3;
  8917. /**
  8918. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8919. */
  8920. direction: Vector3;
  8921. /**
  8922. * The transformed position. Position of the light in world space taking parenting in account.
  8923. */
  8924. transformedPosition: Vector3;
  8925. /**
  8926. * The transformed direction. Direction of the light in world space taking parenting in account.
  8927. */
  8928. transformedDirection: Vector3;
  8929. /**
  8930. * The friendly name of the light in the scene.
  8931. */
  8932. name: string;
  8933. /**
  8934. * Defines the shadow projection clipping minimum z value.
  8935. */
  8936. shadowMinZ: number;
  8937. /**
  8938. * Defines the shadow projection clipping maximum z value.
  8939. */
  8940. shadowMaxZ: number;
  8941. /**
  8942. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8943. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8944. */
  8945. computeTransformedInformation(): boolean;
  8946. /**
  8947. * Gets the scene the light belongs to.
  8948. * @returns The scene
  8949. */
  8950. getScene(): Scene;
  8951. /**
  8952. * Callback defining a custom Projection Matrix Builder.
  8953. * This can be used to override the default projection matrix computation.
  8954. */
  8955. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8956. /**
  8957. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8958. * @param matrix The materix to updated with the projection information
  8959. * @param viewMatrix The transform matrix of the light
  8960. * @param renderList The list of mesh to render in the map
  8961. * @returns The current light
  8962. */
  8963. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8964. /**
  8965. * Gets the current depth scale used in ESM.
  8966. * @returns The scale
  8967. */
  8968. getDepthScale(): number;
  8969. /**
  8970. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8971. * @returns true if a cube texture needs to be use
  8972. */
  8973. needCube(): boolean;
  8974. /**
  8975. * Detects if the projection matrix requires to be recomputed this frame.
  8976. * @returns true if it requires to be recomputed otherwise, false.
  8977. */
  8978. needProjectionMatrixCompute(): boolean;
  8979. /**
  8980. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8981. */
  8982. forceProjectionMatrixCompute(): void;
  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. * Gets the minZ used for shadow according to both the scene and the light.
  8991. * @param activeCamera The camera we are returning the min for
  8992. * @returns the depth min z
  8993. */
  8994. getDepthMinZ(activeCamera: Camera): number;
  8995. /**
  8996. * Gets the maxZ used for shadow according to both the scene and the light.
  8997. * @param activeCamera The camera we are returning the max for
  8998. * @returns the depth max z
  8999. */
  9000. getDepthMaxZ(activeCamera: Camera): number;
  9001. }
  9002. /**
  9003. * Base implementation IShadowLight
  9004. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9005. */
  9006. export abstract class ShadowLight extends Light implements IShadowLight {
  9007. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9008. protected _position: Vector3;
  9009. protected _setPosition(value: Vector3): void;
  9010. /**
  9011. * Sets the position the shadow will be casted from. Also use as the light position for both
  9012. * point and spot lights.
  9013. */
  9014. /**
  9015. * Sets the position the shadow will be casted from. Also use as the light position for both
  9016. * point and spot lights.
  9017. */
  9018. position: Vector3;
  9019. protected _direction: Vector3;
  9020. protected _setDirection(value: Vector3): void;
  9021. /**
  9022. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9023. * Also use as the light direction on spot and directional lights.
  9024. */
  9025. /**
  9026. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9027. * Also use as the light direction on spot and directional lights.
  9028. */
  9029. direction: Vector3;
  9030. private _shadowMinZ;
  9031. /**
  9032. * Gets the shadow projection clipping minimum z value.
  9033. */
  9034. /**
  9035. * Sets the shadow projection clipping minimum z value.
  9036. */
  9037. shadowMinZ: number;
  9038. private _shadowMaxZ;
  9039. /**
  9040. * Sets the shadow projection clipping maximum z value.
  9041. */
  9042. /**
  9043. * Gets the shadow projection clipping maximum z value.
  9044. */
  9045. shadowMaxZ: number;
  9046. /**
  9047. * Callback defining a custom Projection Matrix Builder.
  9048. * This can be used to override the default projection matrix computation.
  9049. */
  9050. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9051. /**
  9052. * The transformed position. Position of the light in world space taking parenting in account.
  9053. */
  9054. transformedPosition: Vector3;
  9055. /**
  9056. * The transformed direction. Direction of the light in world space taking parenting in account.
  9057. */
  9058. transformedDirection: Vector3;
  9059. private _needProjectionMatrixCompute;
  9060. /**
  9061. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9062. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9063. */
  9064. computeTransformedInformation(): boolean;
  9065. /**
  9066. * Return the depth scale used for the shadow map.
  9067. * @returns the depth scale.
  9068. */
  9069. getDepthScale(): number;
  9070. /**
  9071. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9072. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9073. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9074. */
  9075. getShadowDirection(faceIndex?: number): Vector3;
  9076. /**
  9077. * Returns the ShadowLight absolute position in the World.
  9078. * @returns the position vector in world space
  9079. */
  9080. getAbsolutePosition(): Vector3;
  9081. /**
  9082. * Sets the ShadowLight direction toward the passed target.
  9083. * @param target The point to target in local space
  9084. * @returns the updated ShadowLight direction
  9085. */
  9086. setDirectionToTarget(target: Vector3): Vector3;
  9087. /**
  9088. * Returns the light rotation in euler definition.
  9089. * @returns the x y z rotation in local space.
  9090. */
  9091. getRotation(): Vector3;
  9092. /**
  9093. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9094. * @returns true if a cube texture needs to be use
  9095. */
  9096. needCube(): boolean;
  9097. /**
  9098. * Detects if the projection matrix requires to be recomputed this frame.
  9099. * @returns true if it requires to be recomputed otherwise, false.
  9100. */
  9101. needProjectionMatrixCompute(): boolean;
  9102. /**
  9103. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9104. */
  9105. forceProjectionMatrixCompute(): void;
  9106. /** @hidden */
  9107. _initCache(): void;
  9108. /** @hidden */
  9109. _isSynchronized(): boolean;
  9110. /**
  9111. * Computes the world matrix of the node
  9112. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9113. * @returns the world matrix
  9114. */
  9115. computeWorldMatrix(force?: boolean): Matrix;
  9116. /**
  9117. * Gets the minZ used for shadow according to both the scene and the light.
  9118. * @param activeCamera The camera we are returning the min for
  9119. * @returns the depth min z
  9120. */
  9121. getDepthMinZ(activeCamera: Camera): number;
  9122. /**
  9123. * Gets the maxZ used for shadow according to both the scene and the light.
  9124. * @param activeCamera The camera we are returning the max for
  9125. * @returns the depth max z
  9126. */
  9127. getDepthMaxZ(activeCamera: Camera): number;
  9128. /**
  9129. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9130. * @param matrix The materix to updated with the projection information
  9131. * @param viewMatrix The transform matrix of the light
  9132. * @param renderList The list of mesh to render in the map
  9133. * @returns The current light
  9134. */
  9135. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9136. }
  9137. }
  9138. declare module "babylonjs/Materials/materialHelper" {
  9139. import { Nullable } from "babylonjs/types";
  9140. import { Scene } from "babylonjs/scene";
  9141. import { Engine } from "babylonjs/Engines/engine";
  9142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9143. import { Light } from "babylonjs/Lights/light";
  9144. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9145. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9147. /**
  9148. * "Static Class" containing the most commonly used helper while dealing with material for
  9149. * rendering purpose.
  9150. *
  9151. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9152. *
  9153. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9154. */
  9155. export class MaterialHelper {
  9156. /**
  9157. * Bind the current view position to an effect.
  9158. * @param effect The effect to be bound
  9159. * @param scene The scene the eyes position is used from
  9160. */
  9161. static BindEyePosition(effect: Effect, scene: Scene): void;
  9162. /**
  9163. * Helps preparing the defines values about the UVs in used in the effect.
  9164. * UVs are shared as much as we can accross channels in the shaders.
  9165. * @param texture The texture we are preparing the UVs for
  9166. * @param defines The defines to update
  9167. * @param key The channel key "diffuse", "specular"... used in the shader
  9168. */
  9169. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9170. /**
  9171. * Binds a texture matrix value to its corrsponding uniform
  9172. * @param texture The texture to bind the matrix for
  9173. * @param uniformBuffer The uniform buffer receivin the data
  9174. * @param key The channel key "diffuse", "specular"... used in the shader
  9175. */
  9176. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9177. /**
  9178. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9179. * @param mesh defines the current mesh
  9180. * @param scene defines the current scene
  9181. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9182. * @param pointsCloud defines if point cloud rendering has to be turned on
  9183. * @param fogEnabled defines if fog has to be turned on
  9184. * @param alphaTest defines if alpha testing has to be turned on
  9185. * @param defines defines the current list of defines
  9186. */
  9187. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9188. /**
  9189. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9190. * @param scene defines the current scene
  9191. * @param engine defines the current engine
  9192. * @param defines specifies the list of active defines
  9193. * @param useInstances defines if instances have to be turned on
  9194. * @param useClipPlane defines if clip plane have to be turned on
  9195. */
  9196. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9197. /**
  9198. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9199. * @param mesh The mesh containing the geometry data we will draw
  9200. * @param defines The defines to update
  9201. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9202. * @param useBones Precise whether bones should be used or not (override mesh info)
  9203. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9204. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9205. * @returns false if defines are considered not dirty and have not been checked
  9206. */
  9207. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9208. /**
  9209. * Prepares the defines related to the light information passed in parameter
  9210. * @param scene The scene we are intending to draw
  9211. * @param mesh The mesh the effect is compiling for
  9212. * @param defines The defines to update
  9213. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9214. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9215. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9216. * @returns true if normals will be required for the rest of the effect
  9217. */
  9218. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9219. /**
  9220. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9221. * that won t be acctive due to defines being turned off.
  9222. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9223. * @param samplersList The samplers list
  9224. * @param defines The defines helping in the list generation
  9225. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9226. */
  9227. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9228. /**
  9229. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9230. * @param defines The defines to update while falling back
  9231. * @param fallbacks The authorized effect fallbacks
  9232. * @param maxSimultaneousLights The maximum number of lights allowed
  9233. * @param rank the current rank of the Effect
  9234. * @returns The newly affected rank
  9235. */
  9236. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9237. /**
  9238. * Prepares the list of attributes required for morph targets according to the effect defines.
  9239. * @param attribs The current list of supported attribs
  9240. * @param mesh The mesh to prepare the morph targets attributes for
  9241. * @param defines The current Defines of the effect
  9242. */
  9243. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9244. /**
  9245. * Prepares the list of attributes required for bones according to the effect defines.
  9246. * @param attribs The current list of supported attribs
  9247. * @param mesh The mesh to prepare the bones attributes for
  9248. * @param defines The current Defines of the effect
  9249. * @param fallbacks The current efffect fallback strategy
  9250. */
  9251. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9252. /**
  9253. * Prepares the list of attributes required for instances according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param defines The current Defines of the effect
  9256. */
  9257. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9258. /**
  9259. * Binds the light shadow information to the effect for the given mesh.
  9260. * @param light The light containing the generator
  9261. * @param scene The scene the lights belongs to
  9262. * @param mesh The mesh we are binding the information to render
  9263. * @param lightIndex The light index in the effect used to render the mesh
  9264. * @param effect The effect we are binding the data to
  9265. */
  9266. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9267. /**
  9268. * Binds the light information to the effect.
  9269. * @param light The light containing the generator
  9270. * @param effect The effect we are binding the data to
  9271. * @param lightIndex The light index in the effect used to render
  9272. */
  9273. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9274. /**
  9275. * Binds the lights information from the scene to the effect for the given mesh.
  9276. * @param scene The scene the lights belongs to
  9277. * @param mesh The mesh we are binding the information to render
  9278. * @param effect The effect we are binding the data to
  9279. * @param defines The generated defines for the effect
  9280. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9281. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9282. */
  9283. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9284. private static _tempFogColor;
  9285. /**
  9286. * Binds the fog information from the scene to the effect for the given mesh.
  9287. * @param scene The scene the lights belongs to
  9288. * @param mesh The mesh we are binding the information to render
  9289. * @param effect The effect we are binding the data to
  9290. * @param linearSpace Defines if the fog effect is applied in linear space
  9291. */
  9292. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9293. /**
  9294. * Binds the bones information from the mesh to the effect.
  9295. * @param mesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. */
  9298. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9299. /**
  9300. * Binds the morph targets information from the mesh to the effect.
  9301. * @param abstractMesh The mesh we are binding the information to render
  9302. * @param effect The effect we are binding the data to
  9303. */
  9304. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9305. /**
  9306. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9307. * @param defines The generated defines used in the effect
  9308. * @param effect The effect we are binding the data to
  9309. * @param scene The scene we are willing to render with logarithmic scale for
  9310. */
  9311. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9312. /**
  9313. * Binds the clip plane information from the scene to the effect.
  9314. * @param scene The scene the clip plane information are extracted from
  9315. * @param effect The effect we are binding the data to
  9316. */
  9317. static BindClipPlane(effect: Effect, scene: Scene): void;
  9318. }
  9319. }
  9320. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9321. /** @hidden */
  9322. export var kernelBlurVaryingDeclaration: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9328. /** @hidden */
  9329. export var kernelBlurFragment: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9335. /** @hidden */
  9336. export var kernelBlurFragment2: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9342. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9343. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9344. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9345. /** @hidden */
  9346. export var kernelBlurPixelShader: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9352. /** @hidden */
  9353. export var kernelBlurVertex: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9359. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9360. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9361. /** @hidden */
  9362. export var kernelBlurVertexShader: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9368. import { Vector2 } from "babylonjs/Maths/math";
  9369. import { Nullable } from "babylonjs/types";
  9370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9371. import { Camera } from "babylonjs/Cameras/camera";
  9372. import { Effect } from "babylonjs/Materials/effect";
  9373. import { Engine } from "babylonjs/Engines/engine";
  9374. import "babylonjs/Shaders/kernelBlur.fragment";
  9375. import "babylonjs/Shaders/kernelBlur.vertex";
  9376. /**
  9377. * The Blur Post Process which blurs an image based on a kernel and direction.
  9378. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9379. */
  9380. export class BlurPostProcess extends PostProcess {
  9381. /** The direction in which to blur the image. */
  9382. direction: Vector2;
  9383. private blockCompilation;
  9384. protected _kernel: number;
  9385. protected _idealKernel: number;
  9386. protected _packedFloat: boolean;
  9387. private _staticDefines;
  9388. /**
  9389. * Sets the length in pixels of the blur sample region
  9390. */
  9391. /**
  9392. * Gets the length in pixels of the blur sample region
  9393. */
  9394. kernel: number;
  9395. /**
  9396. * Sets wether or not the blur needs to unpack/repack floats
  9397. */
  9398. /**
  9399. * Gets wether or not the blur is unpacking/repacking floats
  9400. */
  9401. packedFloat: boolean;
  9402. /**
  9403. * Creates a new instance BlurPostProcess
  9404. * @param name The name of the effect.
  9405. * @param direction The direction in which to blur the image.
  9406. * @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.
  9407. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9408. * @param camera The camera to apply the render pass to.
  9409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9410. * @param engine The engine which the post process will be applied. (default: current engine)
  9411. * @param reusable If the post process can be reused on the same frame. (default: false)
  9412. * @param textureType Type of textures used when performing the post process. (default: 0)
  9413. * @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)
  9414. */
  9415. constructor(name: string,
  9416. /** The direction in which to blur the image. */
  9417. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9418. /**
  9419. * Updates the effect with the current post process compile time values and recompiles the shader.
  9420. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9421. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9422. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9423. * @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
  9424. * @param onCompiled Called when the shader has been compiled.
  9425. * @param onError Called if there is an error when compiling a shader.
  9426. */
  9427. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9428. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9429. /**
  9430. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9431. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9432. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9433. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9434. * The gaps between physical kernels are compensated for in the weighting of the samples
  9435. * @param idealKernel Ideal blur kernel.
  9436. * @return Nearest best kernel.
  9437. */
  9438. protected _nearestBestKernel(idealKernel: number): number;
  9439. /**
  9440. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9441. * @param x The point on the Gaussian distribution to sample.
  9442. * @return the value of the Gaussian function at x.
  9443. */
  9444. protected _gaussianWeight(x: number): number;
  9445. /**
  9446. * Generates a string that can be used as a floating point number in GLSL.
  9447. * @param x Value to print.
  9448. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9449. * @return GLSL float string.
  9450. */
  9451. protected _glslFloat(x: number, decimalFigures?: number): string;
  9452. }
  9453. }
  9454. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9455. /** @hidden */
  9456. export var shadowMapPixelShader: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9462. /** @hidden */
  9463. export var bonesDeclaration: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9469. /** @hidden */
  9470. export var morphTargetsVertexGlobalDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9476. /** @hidden */
  9477. export var morphTargetsVertexDeclaration: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9483. /** @hidden */
  9484. export var instancesDeclaration: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9490. /** @hidden */
  9491. export var helperFunctions: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9497. /** @hidden */
  9498. export var morphTargetsVertex: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9504. /** @hidden */
  9505. export var instancesVertex: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9511. /** @hidden */
  9512. export var bonesVertex: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9518. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9519. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9520. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9521. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9522. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9523. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9524. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9525. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9526. /** @hidden */
  9527. export var shadowMapVertexShader: {
  9528. name: string;
  9529. shader: string;
  9530. };
  9531. }
  9532. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9533. /** @hidden */
  9534. export var depthBoxBlurPixelShader: {
  9535. name: string;
  9536. shader: string;
  9537. };
  9538. }
  9539. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9540. import { Nullable } from "babylonjs/types";
  9541. import { Scene } from "babylonjs/scene";
  9542. import { Matrix } from "babylonjs/Maths/math";
  9543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9545. import { Mesh } from "babylonjs/Meshes/mesh";
  9546. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9547. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9548. import { Effect } from "babylonjs/Materials/effect";
  9549. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9550. import "babylonjs/Shaders/shadowMap.fragment";
  9551. import "babylonjs/Shaders/shadowMap.vertex";
  9552. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9553. import { Observable } from "babylonjs/Misc/observable";
  9554. /**
  9555. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9556. */
  9557. export interface ICustomShaderOptions {
  9558. /**
  9559. * Gets or sets the custom shader name to use
  9560. */
  9561. shaderName: string;
  9562. /**
  9563. * The list of attribute names used in the shader
  9564. */
  9565. attributes?: string[];
  9566. /**
  9567. * The list of unifrom names used in the shader
  9568. */
  9569. uniforms?: string[];
  9570. /**
  9571. * The list of sampler names used in the shader
  9572. */
  9573. samplers?: string[];
  9574. /**
  9575. * The list of defines used in the shader
  9576. */
  9577. defines?: string[];
  9578. }
  9579. /**
  9580. * Interface to implement to create a shadow generator compatible with BJS.
  9581. */
  9582. export interface IShadowGenerator {
  9583. /**
  9584. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9585. * @returns The render target texture if present otherwise, null
  9586. */
  9587. getShadowMap(): Nullable<RenderTargetTexture>;
  9588. /**
  9589. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9590. * @returns The render target texture if the shadow map is present otherwise, null
  9591. */
  9592. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9593. /**
  9594. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9595. * @param subMesh The submesh we want to render in the shadow map
  9596. * @param useInstances Defines wether will draw in the map using instances
  9597. * @returns true if ready otherwise, false
  9598. */
  9599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9600. /**
  9601. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9602. * @param defines Defines of the material we want to update
  9603. * @param lightIndex Index of the light in the enabled light list of the material
  9604. */
  9605. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9606. /**
  9607. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9608. * defined in the generator but impacting the effect).
  9609. * It implies the unifroms available on the materials are the standard BJS ones.
  9610. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9611. * @param effect The effect we are binfing the information for
  9612. */
  9613. bindShadowLight(lightIndex: string, effect: Effect): void;
  9614. /**
  9615. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9616. * (eq to shadow prjection matrix * light transform matrix)
  9617. * @returns The transform matrix used to create the shadow map
  9618. */
  9619. getTransformMatrix(): Matrix;
  9620. /**
  9621. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9622. * Cube and 2D textures for instance.
  9623. */
  9624. recreateShadowMap(): void;
  9625. /**
  9626. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9627. * @param onCompiled Callback triggered at the and of the effects compilation
  9628. * @param options Sets of optional options forcing the compilation with different modes
  9629. */
  9630. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9631. useInstances: boolean;
  9632. }>): void;
  9633. /**
  9634. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9635. * @param options Sets of optional options forcing the compilation with different modes
  9636. * @returns A promise that resolves when the compilation completes
  9637. */
  9638. forceCompilationAsync(options?: Partial<{
  9639. useInstances: boolean;
  9640. }>): Promise<void>;
  9641. /**
  9642. * Serializes the shadow generator setup to a json object.
  9643. * @returns The serialized JSON object
  9644. */
  9645. serialize(): any;
  9646. /**
  9647. * Disposes the Shadow map and related Textures and effects.
  9648. */
  9649. dispose(): void;
  9650. }
  9651. /**
  9652. * Default implementation IShadowGenerator.
  9653. * This is the main object responsible of generating shadows in the framework.
  9654. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9655. */
  9656. export class ShadowGenerator implements IShadowGenerator {
  9657. /**
  9658. * Shadow generator mode None: no filtering applied.
  9659. */
  9660. static readonly FILTER_NONE: number;
  9661. /**
  9662. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9664. */
  9665. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9666. /**
  9667. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9668. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9669. */
  9670. static readonly FILTER_POISSONSAMPLING: number;
  9671. /**
  9672. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9673. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9674. */
  9675. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9676. /**
  9677. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9678. * edge artifacts on steep falloff.
  9679. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9680. */
  9681. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9682. /**
  9683. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9684. * edge artifacts on steep falloff.
  9685. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9686. */
  9687. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9688. /**
  9689. * Shadow generator mode PCF: Percentage Closer Filtering
  9690. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9691. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9692. */
  9693. static readonly FILTER_PCF: number;
  9694. /**
  9695. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9696. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9697. * Contact Hardening
  9698. */
  9699. static readonly FILTER_PCSS: number;
  9700. /**
  9701. * Reserved for PCF and PCSS
  9702. * Highest Quality.
  9703. *
  9704. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9705. *
  9706. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9707. */
  9708. static readonly QUALITY_HIGH: number;
  9709. /**
  9710. * Reserved for PCF and PCSS
  9711. * Good tradeoff for quality/perf cross devices
  9712. *
  9713. * Execute PCF on a 3*3 kernel.
  9714. *
  9715. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9716. */
  9717. static readonly QUALITY_MEDIUM: number;
  9718. /**
  9719. * Reserved for PCF and PCSS
  9720. * The lowest quality but the fastest.
  9721. *
  9722. * Execute PCF on a 1*1 kernel.
  9723. *
  9724. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9725. */
  9726. static readonly QUALITY_LOW: number;
  9727. /** Gets or sets the custom shader name to use */
  9728. customShaderOptions: ICustomShaderOptions;
  9729. /**
  9730. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9731. */
  9732. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9733. /**
  9734. * Observable triggered before a mesh is rendered in the shadow map.
  9735. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9736. */
  9737. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9738. private _bias;
  9739. /**
  9740. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9741. */
  9742. /**
  9743. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9744. */
  9745. bias: number;
  9746. private _normalBias;
  9747. /**
  9748. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9749. */
  9750. /**
  9751. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9752. */
  9753. normalBias: number;
  9754. private _blurBoxOffset;
  9755. /**
  9756. * Gets the blur box offset: offset applied during the blur pass.
  9757. * Only useful if useKernelBlur = false
  9758. */
  9759. /**
  9760. * Sets the blur box offset: offset applied during the blur pass.
  9761. * Only useful if useKernelBlur = false
  9762. */
  9763. blurBoxOffset: number;
  9764. private _blurScale;
  9765. /**
  9766. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9767. * 2 means half of the size.
  9768. */
  9769. /**
  9770. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9771. * 2 means half of the size.
  9772. */
  9773. blurScale: number;
  9774. private _blurKernel;
  9775. /**
  9776. * Gets the blur kernel: kernel size of the blur pass.
  9777. * Only useful if useKernelBlur = true
  9778. */
  9779. /**
  9780. * Sets the blur kernel: kernel size of the blur pass.
  9781. * Only useful if useKernelBlur = true
  9782. */
  9783. blurKernel: number;
  9784. private _useKernelBlur;
  9785. /**
  9786. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9788. */
  9789. /**
  9790. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9791. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9792. */
  9793. useKernelBlur: boolean;
  9794. private _depthScale;
  9795. /**
  9796. * Gets the depth scale used in ESM mode.
  9797. */
  9798. /**
  9799. * Sets the depth scale used in ESM mode.
  9800. * This can override the scale stored on the light.
  9801. */
  9802. depthScale: number;
  9803. private _filter;
  9804. /**
  9805. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9806. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9807. */
  9808. /**
  9809. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9810. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9811. */
  9812. filter: number;
  9813. /**
  9814. * Gets if the current filter is set to Poisson Sampling.
  9815. */
  9816. /**
  9817. * Sets the current filter to Poisson Sampling.
  9818. */
  9819. usePoissonSampling: boolean;
  9820. /**
  9821. * Gets if the current filter is set to ESM.
  9822. */
  9823. /**
  9824. * Sets the current filter is to ESM.
  9825. */
  9826. useExponentialShadowMap: boolean;
  9827. /**
  9828. * Gets if the current filter is set to filtered ESM.
  9829. */
  9830. /**
  9831. * Gets if the current filter is set to filtered ESM.
  9832. */
  9833. useBlurExponentialShadowMap: boolean;
  9834. /**
  9835. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9836. * exponential to prevent steep falloff artifacts).
  9837. */
  9838. /**
  9839. * Sets the current filter to "close ESM" (using the inverse of the
  9840. * exponential to prevent steep falloff artifacts).
  9841. */
  9842. useCloseExponentialShadowMap: boolean;
  9843. /**
  9844. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9845. * exponential to prevent steep falloff artifacts).
  9846. */
  9847. /**
  9848. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9849. * exponential to prevent steep falloff artifacts).
  9850. */
  9851. useBlurCloseExponentialShadowMap: boolean;
  9852. /**
  9853. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9854. */
  9855. /**
  9856. * Sets the current filter to "PCF" (percentage closer filtering).
  9857. */
  9858. usePercentageCloserFiltering: boolean;
  9859. private _filteringQuality;
  9860. /**
  9861. * Gets the PCF or PCSS Quality.
  9862. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9863. */
  9864. /**
  9865. * Sets the PCF or PCSS Quality.
  9866. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9867. */
  9868. filteringQuality: number;
  9869. /**
  9870. * Gets if the current filter is set to "PCSS" (contact hardening).
  9871. */
  9872. /**
  9873. * Sets the current filter to "PCSS" (contact hardening).
  9874. */
  9875. useContactHardeningShadow: boolean;
  9876. private _contactHardeningLightSizeUVRatio;
  9877. /**
  9878. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9879. * Using a ratio helps keeping shape stability independently of the map size.
  9880. *
  9881. * It does not account for the light projection as it was having too much
  9882. * instability during the light setup or during light position changes.
  9883. *
  9884. * Only valid if useContactHardeningShadow is true.
  9885. */
  9886. /**
  9887. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9888. * Using a ratio helps keeping shape stability independently of the map size.
  9889. *
  9890. * It does not account for the light projection as it was having too much
  9891. * instability during the light setup or during light position changes.
  9892. *
  9893. * Only valid if useContactHardeningShadow is true.
  9894. */
  9895. contactHardeningLightSizeUVRatio: number;
  9896. private _darkness;
  9897. /**
  9898. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9899. * 0 means strongest and 1 would means no shadow.
  9900. * @returns the darkness.
  9901. */
  9902. getDarkness(): number;
  9903. /**
  9904. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9905. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9906. * @returns the shadow generator allowing fluent coding.
  9907. */
  9908. setDarkness(darkness: number): ShadowGenerator;
  9909. private _transparencyShadow;
  9910. /**
  9911. * Sets the ability to have transparent shadow (boolean).
  9912. * @param transparent True if transparent else False
  9913. * @returns the shadow generator allowing fluent coding
  9914. */
  9915. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9916. private _shadowMap;
  9917. private _shadowMap2;
  9918. /**
  9919. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9920. * @returns The render target texture if present otherwise, null
  9921. */
  9922. getShadowMap(): Nullable<RenderTargetTexture>;
  9923. /**
  9924. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9925. * @returns The render target texture if the shadow map is present otherwise, null
  9926. */
  9927. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9928. /**
  9929. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9930. * @param mesh Mesh to add
  9931. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9932. * @returns the Shadow Generator itself
  9933. */
  9934. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9935. /**
  9936. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9937. * @param mesh Mesh to remove
  9938. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9939. * @returns the Shadow Generator itself
  9940. */
  9941. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9942. /**
  9943. * Controls the extent to which the shadows fade out at the edge of the frustum
  9944. * Used only by directionals and spots
  9945. */
  9946. frustumEdgeFalloff: number;
  9947. private _light;
  9948. /**
  9949. * Returns the associated light object.
  9950. * @returns the light generating the shadow
  9951. */
  9952. getLight(): IShadowLight;
  9953. /**
  9954. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9955. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9956. * It might on the other hand introduce peter panning.
  9957. */
  9958. forceBackFacesOnly: boolean;
  9959. private _scene;
  9960. private _lightDirection;
  9961. private _effect;
  9962. private _viewMatrix;
  9963. private _projectionMatrix;
  9964. private _transformMatrix;
  9965. private _cachedPosition;
  9966. private _cachedDirection;
  9967. private _cachedDefines;
  9968. private _currentRenderID;
  9969. private _boxBlurPostprocess;
  9970. private _kernelBlurXPostprocess;
  9971. private _kernelBlurYPostprocess;
  9972. private _blurPostProcesses;
  9973. private _mapSize;
  9974. private _currentFaceIndex;
  9975. private _currentFaceIndexCache;
  9976. private _textureType;
  9977. private _defaultTextureMatrix;
  9978. /** @hidden */
  9979. static _SceneComponentInitialization: (scene: Scene) => void;
  9980. /**
  9981. * Creates a ShadowGenerator object.
  9982. * A ShadowGenerator is the required tool to use the shadows.
  9983. * Each light casting shadows needs to use its own ShadowGenerator.
  9984. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9985. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9986. * @param light The light object generating the shadows.
  9987. * @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.
  9988. */
  9989. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9990. private _initializeGenerator;
  9991. private _initializeShadowMap;
  9992. private _initializeBlurRTTAndPostProcesses;
  9993. private _renderForShadowMap;
  9994. private _renderSubMeshForShadowMap;
  9995. private _applyFilterValues;
  9996. /**
  9997. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9998. * @param onCompiled Callback triggered at the and of the effects compilation
  9999. * @param options Sets of optional options forcing the compilation with different modes
  10000. */
  10001. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10002. useInstances: boolean;
  10003. }>): void;
  10004. /**
  10005. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10006. * @param options Sets of optional options forcing the compilation with different modes
  10007. * @returns A promise that resolves when the compilation completes
  10008. */
  10009. forceCompilationAsync(options?: Partial<{
  10010. useInstances: boolean;
  10011. }>): Promise<void>;
  10012. /**
  10013. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10014. * @param subMesh The submesh we want to render in the shadow map
  10015. * @param useInstances Defines wether will draw in the map using instances
  10016. * @returns true if ready otherwise, false
  10017. */
  10018. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10019. /**
  10020. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10021. * @param defines Defines of the material we want to update
  10022. * @param lightIndex Index of the light in the enabled light list of the material
  10023. */
  10024. prepareDefines(defines: any, lightIndex: number): void;
  10025. /**
  10026. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10027. * defined in the generator but impacting the effect).
  10028. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10029. * @param effect The effect we are binfing the information for
  10030. */
  10031. bindShadowLight(lightIndex: string, effect: Effect): void;
  10032. /**
  10033. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10034. * (eq to shadow prjection matrix * light transform matrix)
  10035. * @returns The transform matrix used to create the shadow map
  10036. */
  10037. getTransformMatrix(): Matrix;
  10038. /**
  10039. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10040. * Cube and 2D textures for instance.
  10041. */
  10042. recreateShadowMap(): void;
  10043. private _disposeBlurPostProcesses;
  10044. private _disposeRTTandPostProcesses;
  10045. /**
  10046. * Disposes the ShadowGenerator.
  10047. * Returns nothing.
  10048. */
  10049. dispose(): void;
  10050. /**
  10051. * Serializes the shadow generator setup to a json object.
  10052. * @returns The serialized JSON object
  10053. */
  10054. serialize(): any;
  10055. /**
  10056. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10057. * @param parsedShadowGenerator The JSON object to parse
  10058. * @param scene The scene to create the shadow map for
  10059. * @returns The parsed shadow generator
  10060. */
  10061. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10062. }
  10063. }
  10064. declare module "babylonjs/Lights/light" {
  10065. import { Nullable } from "babylonjs/types";
  10066. import { Scene } from "babylonjs/scene";
  10067. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10068. import { Node } from "babylonjs/node";
  10069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10070. import { Effect } from "babylonjs/Materials/effect";
  10071. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10072. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10073. /**
  10074. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10075. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10076. * 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.
  10077. */
  10078. export abstract class Light extends Node {
  10079. /**
  10080. * Falloff Default: light is falling off following the material specification:
  10081. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10082. */
  10083. static readonly FALLOFF_DEFAULT: number;
  10084. /**
  10085. * Falloff Physical: light is falling off following the inverse squared distance law.
  10086. */
  10087. static readonly FALLOFF_PHYSICAL: number;
  10088. /**
  10089. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10090. * to enhance interoperability with other engines.
  10091. */
  10092. static readonly FALLOFF_GLTF: number;
  10093. /**
  10094. * Falloff Standard: light is falling off like in the standard material
  10095. * to enhance interoperability with other materials.
  10096. */
  10097. static readonly FALLOFF_STANDARD: number;
  10098. /**
  10099. * If every light affecting the material is in this lightmapMode,
  10100. * material.lightmapTexture adds or multiplies
  10101. * (depends on material.useLightmapAsShadowmap)
  10102. * after every other light calculations.
  10103. */
  10104. static readonly LIGHTMAP_DEFAULT: number;
  10105. /**
  10106. * material.lightmapTexture as only diffuse lighting from this light
  10107. * adds only specular lighting from this light
  10108. * adds dynamic shadows
  10109. */
  10110. static readonly LIGHTMAP_SPECULAR: number;
  10111. /**
  10112. * material.lightmapTexture as only lighting
  10113. * no light calculation from this light
  10114. * only adds dynamic shadows from this light
  10115. */
  10116. static readonly LIGHTMAP_SHADOWSONLY: number;
  10117. /**
  10118. * Each light type uses the default quantity according to its type:
  10119. * point/spot lights use luminous intensity
  10120. * directional lights use illuminance
  10121. */
  10122. static readonly INTENSITYMODE_AUTOMATIC: number;
  10123. /**
  10124. * lumen (lm)
  10125. */
  10126. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10127. /**
  10128. * candela (lm/sr)
  10129. */
  10130. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10131. /**
  10132. * lux (lm/m^2)
  10133. */
  10134. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10135. /**
  10136. * nit (cd/m^2)
  10137. */
  10138. static readonly INTENSITYMODE_LUMINANCE: number;
  10139. /**
  10140. * Light type const id of the point light.
  10141. */
  10142. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10143. /**
  10144. * Light type const id of the directional light.
  10145. */
  10146. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10147. /**
  10148. * Light type const id of the spot light.
  10149. */
  10150. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10151. /**
  10152. * Light type const id of the hemispheric light.
  10153. */
  10154. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10155. /**
  10156. * Diffuse gives the basic color to an object.
  10157. */
  10158. diffuse: Color3;
  10159. /**
  10160. * Specular produces a highlight color on an object.
  10161. * Note: This is note affecting PBR materials.
  10162. */
  10163. specular: Color3;
  10164. /**
  10165. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10166. * falling off base on range or angle.
  10167. * This can be set to any values in Light.FALLOFF_x.
  10168. *
  10169. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10170. * other types of materials.
  10171. */
  10172. falloffType: number;
  10173. /**
  10174. * Strength of the light.
  10175. * Note: By default it is define in the framework own unit.
  10176. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10177. */
  10178. intensity: number;
  10179. private _range;
  10180. protected _inverseSquaredRange: number;
  10181. /**
  10182. * Defines how far from the source the light is impacting in scene units.
  10183. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10184. */
  10185. /**
  10186. * Defines how far from the source the light is impacting in scene units.
  10187. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10188. */
  10189. range: number;
  10190. /**
  10191. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10192. * of light.
  10193. */
  10194. private _photometricScale;
  10195. private _intensityMode;
  10196. /**
  10197. * Gets the photometric scale used to interpret the intensity.
  10198. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10199. */
  10200. /**
  10201. * Sets the photometric scale used to interpret the intensity.
  10202. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10203. */
  10204. intensityMode: number;
  10205. private _radius;
  10206. /**
  10207. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10208. */
  10209. /**
  10210. * sets the light radius used by PBR Materials to simulate soft area lights.
  10211. */
  10212. radius: number;
  10213. private _renderPriority;
  10214. /**
  10215. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10216. * exceeding the number allowed of the materials.
  10217. */
  10218. renderPriority: number;
  10219. private _shadowEnabled;
  10220. /**
  10221. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10222. * the current shadow generator.
  10223. */
  10224. /**
  10225. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10226. * the current shadow generator.
  10227. */
  10228. shadowEnabled: boolean;
  10229. private _includedOnlyMeshes;
  10230. /**
  10231. * Gets the only meshes impacted by this light.
  10232. */
  10233. /**
  10234. * Sets the only meshes impacted by this light.
  10235. */
  10236. includedOnlyMeshes: AbstractMesh[];
  10237. private _excludedMeshes;
  10238. /**
  10239. * Gets the meshes not impacted by this light.
  10240. */
  10241. /**
  10242. * Sets the meshes not impacted by this light.
  10243. */
  10244. excludedMeshes: AbstractMesh[];
  10245. private _excludeWithLayerMask;
  10246. /**
  10247. * Gets the layer id use to find what meshes are not impacted by the light.
  10248. * Inactive if 0
  10249. */
  10250. /**
  10251. * Sets the layer id use to find what meshes are not impacted by the light.
  10252. * Inactive if 0
  10253. */
  10254. excludeWithLayerMask: number;
  10255. private _includeOnlyWithLayerMask;
  10256. /**
  10257. * Gets the layer id use to find what meshes are impacted by the light.
  10258. * Inactive if 0
  10259. */
  10260. /**
  10261. * Sets the layer id use to find what meshes are impacted by the light.
  10262. * Inactive if 0
  10263. */
  10264. includeOnlyWithLayerMask: number;
  10265. private _lightmapMode;
  10266. /**
  10267. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10268. */
  10269. /**
  10270. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10271. */
  10272. lightmapMode: number;
  10273. /**
  10274. * Shadow generator associted to the light.
  10275. * @hidden Internal use only.
  10276. */
  10277. _shadowGenerator: Nullable<IShadowGenerator>;
  10278. /**
  10279. * @hidden Internal use only.
  10280. */
  10281. _excludedMeshesIds: string[];
  10282. /**
  10283. * @hidden Internal use only.
  10284. */
  10285. _includedOnlyMeshesIds: string[];
  10286. /**
  10287. * The current light unifom buffer.
  10288. * @hidden Internal use only.
  10289. */
  10290. _uniformBuffer: UniformBuffer;
  10291. /**
  10292. * Creates a Light object in the scene.
  10293. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10294. * @param name The firendly name of the light
  10295. * @param scene The scene the light belongs too
  10296. */
  10297. constructor(name: string, scene: Scene);
  10298. protected abstract _buildUniformLayout(): void;
  10299. /**
  10300. * Sets the passed Effect "effect" with the Light information.
  10301. * @param effect The effect to update
  10302. * @param lightIndex The index of the light in the effect to update
  10303. * @returns The light
  10304. */
  10305. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10306. /**
  10307. * Returns the string "Light".
  10308. * @returns the class name
  10309. */
  10310. getClassName(): string;
  10311. /** @hidden */
  10312. readonly _isLight: boolean;
  10313. /**
  10314. * Converts the light information to a readable string for debug purpose.
  10315. * @param fullDetails Supports for multiple levels of logging within scene loading
  10316. * @returns the human readable light info
  10317. */
  10318. toString(fullDetails?: boolean): string;
  10319. /** @hidden */
  10320. protected _syncParentEnabledState(): void;
  10321. /**
  10322. * Set the enabled state of this node.
  10323. * @param value - the new enabled state
  10324. */
  10325. setEnabled(value: boolean): void;
  10326. /**
  10327. * Returns the Light associated shadow generator if any.
  10328. * @return the associated shadow generator.
  10329. */
  10330. getShadowGenerator(): Nullable<IShadowGenerator>;
  10331. /**
  10332. * Returns a Vector3, the absolute light position in the World.
  10333. * @returns the world space position of the light
  10334. */
  10335. getAbsolutePosition(): Vector3;
  10336. /**
  10337. * Specifies if the light will affect the passed mesh.
  10338. * @param mesh The mesh to test against the light
  10339. * @return true the mesh is affected otherwise, false.
  10340. */
  10341. canAffectMesh(mesh: AbstractMesh): boolean;
  10342. /**
  10343. * Sort function to order lights for rendering.
  10344. * @param a First Light object to compare to second.
  10345. * @param b Second Light object to compare first.
  10346. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10347. */
  10348. static CompareLightsPriority(a: Light, b: Light): number;
  10349. /**
  10350. * Releases resources associated with this node.
  10351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10353. */
  10354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10355. /**
  10356. * Returns the light type ID (integer).
  10357. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10358. */
  10359. getTypeID(): number;
  10360. /**
  10361. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10362. * @returns the scaled intensity in intensity mode unit
  10363. */
  10364. getScaledIntensity(): number;
  10365. /**
  10366. * Returns a new Light object, named "name", from the current one.
  10367. * @param name The name of the cloned light
  10368. * @returns the new created light
  10369. */
  10370. clone(name: string): Nullable<Light>;
  10371. /**
  10372. * Serializes the current light into a Serialization object.
  10373. * @returns the serialized object.
  10374. */
  10375. serialize(): any;
  10376. /**
  10377. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10378. * This new light is named "name" and added to the passed scene.
  10379. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10380. * @param name The friendly name of the light
  10381. * @param scene The scene the new light will belong to
  10382. * @returns the constructor function
  10383. */
  10384. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10385. /**
  10386. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10387. * @param parsedLight The JSON representation of the light
  10388. * @param scene The scene to create the parsed light in
  10389. * @returns the created light after parsing
  10390. */
  10391. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10392. private _hookArrayForExcluded;
  10393. private _hookArrayForIncludedOnly;
  10394. private _resyncMeshes;
  10395. /**
  10396. * Forces the meshes to update their light related information in their rendering used effects
  10397. * @hidden Internal Use Only
  10398. */
  10399. _markMeshesAsLightDirty(): void;
  10400. /**
  10401. * Recomputes the cached photometric scale if needed.
  10402. */
  10403. private _computePhotometricScale;
  10404. /**
  10405. * Returns the Photometric Scale according to the light type and intensity mode.
  10406. */
  10407. private _getPhotometricScale;
  10408. /**
  10409. * Reorder the light in the scene according to their defined priority.
  10410. * @hidden Internal Use Only
  10411. */
  10412. _reorderLightsInScene(): void;
  10413. /**
  10414. * Prepares the list of defines specific to the light type.
  10415. * @param defines the list of defines
  10416. * @param lightIndex defines the index of the light for the effect
  10417. */
  10418. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10419. }
  10420. }
  10421. declare module "babylonjs/Actions/action" {
  10422. import { Observable } from "babylonjs/Misc/observable";
  10423. import { Condition } from "babylonjs/Actions/condition";
  10424. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10425. import { ActionManager } from "babylonjs/Actions/actionManager";
  10426. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10427. /**
  10428. * Interface used to define Action
  10429. */
  10430. export interface IAction {
  10431. /**
  10432. * Trigger for the action
  10433. */
  10434. trigger: number;
  10435. /** Options of the trigger */
  10436. triggerOptions: any;
  10437. /**
  10438. * Gets the trigger parameters
  10439. * @returns the trigger parameters
  10440. */
  10441. getTriggerParameter(): any;
  10442. /**
  10443. * Internal only - executes current action event
  10444. * @hidden
  10445. */
  10446. _executeCurrent(evt?: ActionEvent): void;
  10447. /**
  10448. * Serialize placeholder for child classes
  10449. * @param parent of child
  10450. * @returns the serialized object
  10451. */
  10452. serialize(parent: any): any;
  10453. /**
  10454. * Internal only
  10455. * @hidden
  10456. */
  10457. _prepare(): void;
  10458. /**
  10459. * Internal only - manager for action
  10460. * @hidden
  10461. */
  10462. _actionManager: AbstractActionManager;
  10463. }
  10464. /**
  10465. * The action to be carried out following a trigger
  10466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10467. */
  10468. export class Action implements IAction {
  10469. /** the trigger, with or without parameters, for the action */
  10470. triggerOptions: any;
  10471. /**
  10472. * Trigger for the action
  10473. */
  10474. trigger: number;
  10475. /**
  10476. * Internal only - manager for action
  10477. * @hidden
  10478. */
  10479. _actionManager: ActionManager;
  10480. private _nextActiveAction;
  10481. private _child;
  10482. private _condition?;
  10483. private _triggerParameter;
  10484. /**
  10485. * An event triggered prior to action being executed.
  10486. */
  10487. onBeforeExecuteObservable: Observable<Action>;
  10488. /**
  10489. * Creates a new Action
  10490. * @param triggerOptions the trigger, with or without parameters, for the action
  10491. * @param condition an optional determinant of action
  10492. */
  10493. constructor(
  10494. /** the trigger, with or without parameters, for the action */
  10495. triggerOptions: any, condition?: Condition);
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. _prepare(): void;
  10501. /**
  10502. * Gets the trigger parameters
  10503. * @returns the trigger parameters
  10504. */
  10505. getTriggerParameter(): any;
  10506. /**
  10507. * Internal only - executes current action event
  10508. * @hidden
  10509. */
  10510. _executeCurrent(evt?: ActionEvent): void;
  10511. /**
  10512. * Execute placeholder for child classes
  10513. * @param evt optional action event
  10514. */
  10515. execute(evt?: ActionEvent): void;
  10516. /**
  10517. * Skips to next active action
  10518. */
  10519. skipToNextActiveAction(): void;
  10520. /**
  10521. * Adds action to chain of actions, may be a DoNothingAction
  10522. * @param action defines the next action to execute
  10523. * @returns The action passed in
  10524. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10525. */
  10526. then(action: Action): Action;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. _getProperty(propertyPath: string): string;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. _getEffectiveTarget(target: any, propertyPath: string): any;
  10537. /**
  10538. * Serialize placeholder for child classes
  10539. * @param parent of child
  10540. * @returns the serialized object
  10541. */
  10542. serialize(parent: any): any;
  10543. /**
  10544. * Internal only called by serialize
  10545. * @hidden
  10546. */
  10547. protected _serialize(serializedAction: any, parent?: any): any;
  10548. /**
  10549. * Internal only
  10550. * @hidden
  10551. */
  10552. static _SerializeValueAsString: (value: any) => string;
  10553. /**
  10554. * Internal only
  10555. * @hidden
  10556. */
  10557. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10558. name: string;
  10559. targetType: string;
  10560. value: string;
  10561. };
  10562. }
  10563. }
  10564. declare module "babylonjs/Actions/condition" {
  10565. import { ActionManager } from "babylonjs/Actions/actionManager";
  10566. /**
  10567. * A Condition applied to an Action
  10568. */
  10569. export class Condition {
  10570. /**
  10571. * Internal only - manager for action
  10572. * @hidden
  10573. */
  10574. _actionManager: ActionManager;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. _evaluationId: number;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. _currentResult: boolean;
  10585. /**
  10586. * Creates a new Condition
  10587. * @param actionManager the manager of the action the condition is applied to
  10588. */
  10589. constructor(actionManager: ActionManager);
  10590. /**
  10591. * Check if the current condition is valid
  10592. * @returns a boolean
  10593. */
  10594. isValid(): boolean;
  10595. /**
  10596. * Internal only
  10597. * @hidden
  10598. */
  10599. _getProperty(propertyPath: string): string;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. _getEffectiveTarget(target: any, propertyPath: string): any;
  10605. /**
  10606. * Serialize placeholder for child classes
  10607. * @returns the serialized object
  10608. */
  10609. serialize(): any;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. protected _serialize(serializedCondition: any): any;
  10615. }
  10616. /**
  10617. * Defines specific conditional operators as extensions of Condition
  10618. */
  10619. export class ValueCondition extends Condition {
  10620. /** path to specify the property of the target the conditional operator uses */
  10621. propertyPath: string;
  10622. /** the value compared by the conditional operator against the current value of the property */
  10623. value: any;
  10624. /** the conditional operator, default ValueCondition.IsEqual */
  10625. operator: number;
  10626. /**
  10627. * Internal only
  10628. * @hidden
  10629. */
  10630. private static _IsEqual;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. private static _IsDifferent;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. private static _IsGreater;
  10641. /**
  10642. * Internal only
  10643. * @hidden
  10644. */
  10645. private static _IsLesser;
  10646. /**
  10647. * returns the number for IsEqual
  10648. */
  10649. static readonly IsEqual: number;
  10650. /**
  10651. * Returns the number for IsDifferent
  10652. */
  10653. static readonly IsDifferent: number;
  10654. /**
  10655. * Returns the number for IsGreater
  10656. */
  10657. static readonly IsGreater: number;
  10658. /**
  10659. * Returns the number for IsLesser
  10660. */
  10661. static readonly IsLesser: number;
  10662. /**
  10663. * Internal only The action manager for the condition
  10664. * @hidden
  10665. */
  10666. _actionManager: ActionManager;
  10667. /**
  10668. * Internal only
  10669. * @hidden
  10670. */
  10671. private _target;
  10672. /**
  10673. * Internal only
  10674. * @hidden
  10675. */
  10676. private _effectiveTarget;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. private _property;
  10682. /**
  10683. * Creates a new ValueCondition
  10684. * @param actionManager manager for the action the condition applies to
  10685. * @param target for the action
  10686. * @param propertyPath path to specify the property of the target the conditional operator uses
  10687. * @param value the value compared by the conditional operator against the current value of the property
  10688. * @param operator the conditional operator, default ValueCondition.IsEqual
  10689. */
  10690. constructor(actionManager: ActionManager, target: any,
  10691. /** path to specify the property of the target the conditional operator uses */
  10692. propertyPath: string,
  10693. /** the value compared by the conditional operator against the current value of the property */
  10694. value: any,
  10695. /** the conditional operator, default ValueCondition.IsEqual */
  10696. operator?: number);
  10697. /**
  10698. * Compares the given value with the property value for the specified conditional operator
  10699. * @returns the result of the comparison
  10700. */
  10701. isValid(): boolean;
  10702. /**
  10703. * Serialize the ValueCondition into a JSON compatible object
  10704. * @returns serialization object
  10705. */
  10706. serialize(): any;
  10707. /**
  10708. * Gets the name of the conditional operator for the ValueCondition
  10709. * @param operator the conditional operator
  10710. * @returns the name
  10711. */
  10712. static GetOperatorName(operator: number): string;
  10713. }
  10714. /**
  10715. * Defines a predicate condition as an extension of Condition
  10716. */
  10717. export class PredicateCondition extends Condition {
  10718. /** defines the predicate function used to validate the condition */
  10719. predicate: () => boolean;
  10720. /**
  10721. * Internal only - manager for action
  10722. * @hidden
  10723. */
  10724. _actionManager: ActionManager;
  10725. /**
  10726. * Creates a new PredicateCondition
  10727. * @param actionManager manager for the action the condition applies to
  10728. * @param predicate defines the predicate function used to validate the condition
  10729. */
  10730. constructor(actionManager: ActionManager,
  10731. /** defines the predicate function used to validate the condition */
  10732. predicate: () => boolean);
  10733. /**
  10734. * @returns the validity of the predicate condition
  10735. */
  10736. isValid(): boolean;
  10737. }
  10738. /**
  10739. * Defines a state condition as an extension of Condition
  10740. */
  10741. export class StateCondition extends Condition {
  10742. /** Value to compare with target state */
  10743. value: string;
  10744. /**
  10745. * Internal only - manager for action
  10746. * @hidden
  10747. */
  10748. _actionManager: ActionManager;
  10749. /**
  10750. * Internal only
  10751. * @hidden
  10752. */
  10753. private _target;
  10754. /**
  10755. * Creates a new StateCondition
  10756. * @param actionManager manager for the action the condition applies to
  10757. * @param target of the condition
  10758. * @param value to compare with target state
  10759. */
  10760. constructor(actionManager: ActionManager, target: any,
  10761. /** Value to compare with target state */
  10762. value: string);
  10763. /**
  10764. * Gets a boolean indicating if the current condition is met
  10765. * @returns the validity of the state
  10766. */
  10767. isValid(): boolean;
  10768. /**
  10769. * Serialize the StateCondition into a JSON compatible object
  10770. * @returns serialization object
  10771. */
  10772. serialize(): any;
  10773. }
  10774. }
  10775. declare module "babylonjs/Actions/directActions" {
  10776. import { Action } from "babylonjs/Actions/action";
  10777. import { Condition } from "babylonjs/Actions/condition";
  10778. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10779. /**
  10780. * This defines an action responsible to toggle a boolean once triggered.
  10781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10782. */
  10783. export class SwitchBooleanAction extends Action {
  10784. /**
  10785. * The path to the boolean property in the target object
  10786. */
  10787. propertyPath: string;
  10788. private _target;
  10789. private _effectiveTarget;
  10790. private _property;
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param target defines the object containing the boolean
  10795. * @param propertyPath defines the path to the boolean property in the target object
  10796. * @param condition defines the trigger related conditions
  10797. */
  10798. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10799. /** @hidden */
  10800. _prepare(): void;
  10801. /**
  10802. * Execute the action toggle the boolean value.
  10803. */
  10804. execute(): void;
  10805. /**
  10806. * Serializes the actions and its related information.
  10807. * @param parent defines the object to serialize in
  10808. * @returns the serialized object
  10809. */
  10810. serialize(parent: any): any;
  10811. }
  10812. /**
  10813. * This defines an action responsible to set a the state field of the target
  10814. * to a desired value once triggered.
  10815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10816. */
  10817. export class SetStateAction extends Action {
  10818. /**
  10819. * The value to store in the state field.
  10820. */
  10821. value: string;
  10822. private _target;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the object containing the state property
  10827. * @param value defines the value to store in the state field
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10831. /**
  10832. * Execute the action and store the value on the target state property.
  10833. */
  10834. execute(): void;
  10835. /**
  10836. * Serializes the actions and its related information.
  10837. * @param parent defines the object to serialize in
  10838. * @returns the serialized object
  10839. */
  10840. serialize(parent: any): any;
  10841. }
  10842. /**
  10843. * This defines an action responsible to set a property of the target
  10844. * to a desired value once triggered.
  10845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10846. */
  10847. export class SetValueAction extends Action {
  10848. /**
  10849. * The path of the property to set in the target.
  10850. */
  10851. propertyPath: string;
  10852. /**
  10853. * The value to set in the property
  10854. */
  10855. value: any;
  10856. private _target;
  10857. private _effectiveTarget;
  10858. private _property;
  10859. /**
  10860. * Instantiate the action
  10861. * @param triggerOptions defines the trigger options
  10862. * @param target defines the object containing the property
  10863. * @param propertyPath defines the path of the property to set in the target
  10864. * @param value defines the value to set in the property
  10865. * @param condition defines the trigger related conditions
  10866. */
  10867. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10868. /** @hidden */
  10869. _prepare(): void;
  10870. /**
  10871. * Execute the action and set the targetted property to the desired value.
  10872. */
  10873. execute(): void;
  10874. /**
  10875. * Serializes the actions and its related information.
  10876. * @param parent defines the object to serialize in
  10877. * @returns the serialized object
  10878. */
  10879. serialize(parent: any): any;
  10880. }
  10881. /**
  10882. * This defines an action responsible to increment the target value
  10883. * to a desired value once triggered.
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10885. */
  10886. export class IncrementValueAction extends Action {
  10887. /**
  10888. * The path of the property to increment in the target.
  10889. */
  10890. propertyPath: string;
  10891. /**
  10892. * The value we should increment the property by.
  10893. */
  10894. value: any;
  10895. private _target;
  10896. private _effectiveTarget;
  10897. private _property;
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param target defines the object containing the property
  10902. * @param propertyPath defines the path of the property to increment in the target
  10903. * @param value defines the value value we should increment the property by
  10904. * @param condition defines the trigger related conditions
  10905. */
  10906. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10907. /** @hidden */
  10908. _prepare(): void;
  10909. /**
  10910. * Execute the action and increment the target of the value amount.
  10911. */
  10912. execute(): void;
  10913. /**
  10914. * Serializes the actions and its related information.
  10915. * @param parent defines the object to serialize in
  10916. * @returns the serialized object
  10917. */
  10918. serialize(parent: any): any;
  10919. }
  10920. /**
  10921. * This defines an action responsible to start an animation once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class PlayAnimationAction extends Action {
  10925. /**
  10926. * Where the animation should start (animation frame)
  10927. */
  10928. from: number;
  10929. /**
  10930. * Where the animation should stop (animation frame)
  10931. */
  10932. to: number;
  10933. /**
  10934. * Define if the animation should loop or stop after the first play.
  10935. */
  10936. loop?: boolean;
  10937. private _target;
  10938. /**
  10939. * Instantiate the action
  10940. * @param triggerOptions defines the trigger options
  10941. * @param target defines the target animation or animation name
  10942. * @param from defines from where the animation should start (animation frame)
  10943. * @param end defines where the animation should stop (animation frame)
  10944. * @param loop defines if the animation should loop or stop after the first play
  10945. * @param condition defines the trigger related conditions
  10946. */
  10947. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10948. /** @hidden */
  10949. _prepare(): void;
  10950. /**
  10951. * Execute the action and play the animation.
  10952. */
  10953. execute(): void;
  10954. /**
  10955. * Serializes the actions and its related information.
  10956. * @param parent defines the object to serialize in
  10957. * @returns the serialized object
  10958. */
  10959. serialize(parent: any): any;
  10960. }
  10961. /**
  10962. * This defines an action responsible to stop an animation once triggered.
  10963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10964. */
  10965. export class StopAnimationAction extends Action {
  10966. private _target;
  10967. /**
  10968. * Instantiate the action
  10969. * @param triggerOptions defines the trigger options
  10970. * @param target defines the target animation or animation name
  10971. * @param condition defines the trigger related conditions
  10972. */
  10973. constructor(triggerOptions: any, target: any, condition?: Condition);
  10974. /** @hidden */
  10975. _prepare(): void;
  10976. /**
  10977. * Execute the action and stop the animation.
  10978. */
  10979. execute(): void;
  10980. /**
  10981. * Serializes the actions and its related information.
  10982. * @param parent defines the object to serialize in
  10983. * @returns the serialized object
  10984. */
  10985. serialize(parent: any): any;
  10986. }
  10987. /**
  10988. * This defines an action responsible that does nothing once triggered.
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10990. */
  10991. export class DoNothingAction extends Action {
  10992. /**
  10993. * Instantiate the action
  10994. * @param triggerOptions defines the trigger options
  10995. * @param condition defines the trigger related conditions
  10996. */
  10997. constructor(triggerOptions?: any, condition?: Condition);
  10998. /**
  10999. * Execute the action and do nothing.
  11000. */
  11001. execute(): void;
  11002. /**
  11003. * Serializes the actions and its related information.
  11004. * @param parent defines the object to serialize in
  11005. * @returns the serialized object
  11006. */
  11007. serialize(parent: any): any;
  11008. }
  11009. /**
  11010. * This defines an action responsible to trigger several actions once triggered.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class CombineAction extends Action {
  11014. /**
  11015. * The list of aggregated animations to run.
  11016. */
  11017. children: Action[];
  11018. /**
  11019. * Instantiate the action
  11020. * @param triggerOptions defines the trigger options
  11021. * @param children defines the list of aggregated animations to run
  11022. * @param condition defines the trigger related conditions
  11023. */
  11024. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11025. /** @hidden */
  11026. _prepare(): void;
  11027. /**
  11028. * Execute the action and executes all the aggregated actions.
  11029. */
  11030. execute(evt: ActionEvent): void;
  11031. /**
  11032. * Serializes the actions and its related information.
  11033. * @param parent defines the object to serialize in
  11034. * @returns the serialized object
  11035. */
  11036. serialize(parent: any): any;
  11037. }
  11038. /**
  11039. * This defines an action responsible to run code (external event) once triggered.
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11041. */
  11042. export class ExecuteCodeAction extends Action {
  11043. /**
  11044. * The callback function to run.
  11045. */
  11046. func: (evt: ActionEvent) => void;
  11047. /**
  11048. * Instantiate the action
  11049. * @param triggerOptions defines the trigger options
  11050. * @param func defines the callback function to run
  11051. * @param condition defines the trigger related conditions
  11052. */
  11053. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11054. /**
  11055. * Execute the action and run the attached code.
  11056. */
  11057. execute(evt: ActionEvent): void;
  11058. }
  11059. /**
  11060. * This defines an action responsible to set the parent property of the target once triggered.
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11062. */
  11063. export class SetParentAction extends Action {
  11064. private _parent;
  11065. private _target;
  11066. /**
  11067. * Instantiate the action
  11068. * @param triggerOptions defines the trigger options
  11069. * @param target defines the target containing the parent property
  11070. * @param parent defines from where the animation should start (animation frame)
  11071. * @param condition defines the trigger related conditions
  11072. */
  11073. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11074. /** @hidden */
  11075. _prepare(): void;
  11076. /**
  11077. * Execute the action and set the parent property.
  11078. */
  11079. execute(): void;
  11080. /**
  11081. * Serializes the actions and its related information.
  11082. * @param parent defines the object to serialize in
  11083. * @returns the serialized object
  11084. */
  11085. serialize(parent: any): any;
  11086. }
  11087. }
  11088. declare module "babylonjs/Actions/actionManager" {
  11089. import { Nullable } from "babylonjs/types";
  11090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11091. import { Scene } from "babylonjs/scene";
  11092. import { IAction } from "babylonjs/Actions/action";
  11093. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11094. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11095. /**
  11096. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11097. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11099. */
  11100. export class ActionManager extends AbstractActionManager {
  11101. /**
  11102. * Nothing
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly NothingTrigger: number;
  11106. /**
  11107. * On pick
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnPickTrigger: number;
  11111. /**
  11112. * On left pick
  11113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11114. */
  11115. static readonly OnLeftPickTrigger: number;
  11116. /**
  11117. * On right pick
  11118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11119. */
  11120. static readonly OnRightPickTrigger: number;
  11121. /**
  11122. * On center pick
  11123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11124. */
  11125. static readonly OnCenterPickTrigger: number;
  11126. /**
  11127. * On pick down
  11128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11129. */
  11130. static readonly OnPickDownTrigger: number;
  11131. /**
  11132. * On double pick
  11133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11134. */
  11135. static readonly OnDoublePickTrigger: number;
  11136. /**
  11137. * On pick up
  11138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11139. */
  11140. static readonly OnPickUpTrigger: number;
  11141. /**
  11142. * On pick out.
  11143. * This trigger will only be raised if you also declared a OnPickDown
  11144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11145. */
  11146. static readonly OnPickOutTrigger: number;
  11147. /**
  11148. * On long press
  11149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11150. */
  11151. static readonly OnLongPressTrigger: number;
  11152. /**
  11153. * On pointer over
  11154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11155. */
  11156. static readonly OnPointerOverTrigger: number;
  11157. /**
  11158. * On pointer out
  11159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11160. */
  11161. static readonly OnPointerOutTrigger: number;
  11162. /**
  11163. * On every frame
  11164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11165. */
  11166. static readonly OnEveryFrameTrigger: number;
  11167. /**
  11168. * On intersection enter
  11169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11170. */
  11171. static readonly OnIntersectionEnterTrigger: number;
  11172. /**
  11173. * On intersection exit
  11174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11175. */
  11176. static readonly OnIntersectionExitTrigger: number;
  11177. /**
  11178. * On key down
  11179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11180. */
  11181. static readonly OnKeyDownTrigger: number;
  11182. /**
  11183. * On key up
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11185. */
  11186. static readonly OnKeyUpTrigger: number;
  11187. private _scene;
  11188. /**
  11189. * Creates a new action manager
  11190. * @param scene defines the hosting scene
  11191. */
  11192. constructor(scene: Scene);
  11193. /**
  11194. * Releases all associated resources
  11195. */
  11196. dispose(): void;
  11197. /**
  11198. * Gets hosting scene
  11199. * @returns the hosting scene
  11200. */
  11201. getScene(): Scene;
  11202. /**
  11203. * Does this action manager handles actions of any of the given triggers
  11204. * @param triggers defines the triggers to be tested
  11205. * @return a boolean indicating whether one (or more) of the triggers is handled
  11206. */
  11207. hasSpecificTriggers(triggers: number[]): boolean;
  11208. /**
  11209. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11210. * speed.
  11211. * @param triggerA defines the trigger to be tested
  11212. * @param triggerB defines the trigger to be tested
  11213. * @return a boolean indicating whether one (or more) of the triggers is handled
  11214. */
  11215. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11216. /**
  11217. * Does this action manager handles actions of a given trigger
  11218. * @param trigger defines the trigger to be tested
  11219. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11220. * @return whether the trigger is handled
  11221. */
  11222. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11223. /**
  11224. * Does this action manager has pointer triggers
  11225. */
  11226. readonly hasPointerTriggers: boolean;
  11227. /**
  11228. * Does this action manager has pick triggers
  11229. */
  11230. readonly hasPickTriggers: boolean;
  11231. /**
  11232. * Registers an action to this action manager
  11233. * @param action defines the action to be registered
  11234. * @return the action amended (prepared) after registration
  11235. */
  11236. registerAction(action: IAction): Nullable<IAction>;
  11237. /**
  11238. * Unregisters an action to this action manager
  11239. * @param action defines the action to be unregistered
  11240. * @return a boolean indicating whether the action has been unregistered
  11241. */
  11242. unregisterAction(action: IAction): Boolean;
  11243. /**
  11244. * Process a specific trigger
  11245. * @param trigger defines the trigger to process
  11246. * @param evt defines the event details to be processed
  11247. */
  11248. processTrigger(trigger: number, evt?: IActionEvent): void;
  11249. /** @hidden */
  11250. _getEffectiveTarget(target: any, propertyPath: string): any;
  11251. /** @hidden */
  11252. _getProperty(propertyPath: string): string;
  11253. /**
  11254. * Serialize this manager to a JSON object
  11255. * @param name defines the property name to store this manager
  11256. * @returns a JSON representation of this manager
  11257. */
  11258. serialize(name: string): any;
  11259. /**
  11260. * Creates a new ActionManager from a JSON data
  11261. * @param parsedActions defines the JSON data to read from
  11262. * @param object defines the hosting mesh
  11263. * @param scene defines the hosting scene
  11264. */
  11265. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11266. /**
  11267. * Get a trigger name by index
  11268. * @param trigger defines the trigger index
  11269. * @returns a trigger name
  11270. */
  11271. static GetTriggerName(trigger: number): string;
  11272. }
  11273. }
  11274. declare module "babylonjs/Culling/ray" {
  11275. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11276. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11278. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11279. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11280. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11281. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11282. /**
  11283. * Class representing a ray with position and direction
  11284. */
  11285. export class Ray {
  11286. /** origin point */
  11287. origin: Vector3;
  11288. /** direction */
  11289. direction: Vector3;
  11290. /** length of the ray */
  11291. length: number;
  11292. private static readonly TmpVector3;
  11293. private _tmpRay;
  11294. /**
  11295. * Creates a new ray
  11296. * @param origin origin point
  11297. * @param direction direction
  11298. * @param length length of the ray
  11299. */
  11300. constructor(
  11301. /** origin point */
  11302. origin: Vector3,
  11303. /** direction */
  11304. direction: Vector3,
  11305. /** length of the ray */
  11306. length?: number);
  11307. /**
  11308. * Checks if the ray intersects a box
  11309. * @param minimum bound of the box
  11310. * @param maximum bound of the box
  11311. * @param intersectionTreshold extra extend to be added to the box in all direction
  11312. * @returns if the box was hit
  11313. */
  11314. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11315. /**
  11316. * Checks if the ray intersects a box
  11317. * @param box the bounding box to check
  11318. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11319. * @returns if the box was hit
  11320. */
  11321. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11322. /**
  11323. * If the ray hits a sphere
  11324. * @param sphere the bounding sphere to check
  11325. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11326. * @returns true if it hits the sphere
  11327. */
  11328. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11329. /**
  11330. * If the ray hits a triange
  11331. * @param vertex0 triangle vertex
  11332. * @param vertex1 triangle vertex
  11333. * @param vertex2 triangle vertex
  11334. * @returns intersection information if hit
  11335. */
  11336. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11337. /**
  11338. * Checks if ray intersects a plane
  11339. * @param plane the plane to check
  11340. * @returns the distance away it was hit
  11341. */
  11342. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11343. /**
  11344. * Checks if ray intersects a mesh
  11345. * @param mesh the mesh to check
  11346. * @param fastCheck if only the bounding box should checked
  11347. * @returns picking info of the intersecton
  11348. */
  11349. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11350. /**
  11351. * Checks if ray intersects a mesh
  11352. * @param meshes the meshes to check
  11353. * @param fastCheck if only the bounding box should checked
  11354. * @param results array to store result in
  11355. * @returns Array of picking infos
  11356. */
  11357. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11358. private _comparePickingInfo;
  11359. private static smallnum;
  11360. private static rayl;
  11361. /**
  11362. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11363. * @param sega the first point of the segment to test the intersection against
  11364. * @param segb the second point of the segment to test the intersection against
  11365. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11366. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11367. */
  11368. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11369. /**
  11370. * Update the ray from viewport position
  11371. * @param x position
  11372. * @param y y position
  11373. * @param viewportWidth viewport width
  11374. * @param viewportHeight viewport height
  11375. * @param world world matrix
  11376. * @param view view matrix
  11377. * @param projection projection matrix
  11378. * @returns this ray updated
  11379. */
  11380. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11381. /**
  11382. * Creates a ray with origin and direction of 0,0,0
  11383. * @returns the new ray
  11384. */
  11385. static Zero(): Ray;
  11386. /**
  11387. * Creates a new ray from screen space and viewport
  11388. * @param x position
  11389. * @param y y position
  11390. * @param viewportWidth viewport width
  11391. * @param viewportHeight viewport height
  11392. * @param world world matrix
  11393. * @param view view matrix
  11394. * @param projection projection matrix
  11395. * @returns new ray
  11396. */
  11397. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11398. /**
  11399. * 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
  11400. * transformed to the given world matrix.
  11401. * @param origin The origin point
  11402. * @param end The end point
  11403. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11404. * @returns the new ray
  11405. */
  11406. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11407. /**
  11408. * Transforms a ray by a matrix
  11409. * @param ray ray to transform
  11410. * @param matrix matrix to apply
  11411. * @returns the resulting new ray
  11412. */
  11413. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11414. /**
  11415. * Transforms a ray by a matrix
  11416. * @param ray ray to transform
  11417. * @param matrix matrix to apply
  11418. * @param result ray to store result in
  11419. */
  11420. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11421. /**
  11422. * Unproject a ray from screen space to object space
  11423. * @param sourceX defines the screen space x coordinate to use
  11424. * @param sourceY defines the screen space y coordinate to use
  11425. * @param viewportWidth defines the current width of the viewport
  11426. * @param viewportHeight defines the current height of the viewport
  11427. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11428. * @param view defines the view matrix to use
  11429. * @param projection defines the projection matrix to use
  11430. */
  11431. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11432. }
  11433. /**
  11434. * Type used to define predicate used to select faces when a mesh intersection is detected
  11435. */
  11436. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11437. module "babylonjs/scene" {
  11438. interface Scene {
  11439. /** @hidden */
  11440. _tempPickingRay: Nullable<Ray>;
  11441. /** @hidden */
  11442. _cachedRayForTransform: Ray;
  11443. /** @hidden */
  11444. _pickWithRayInverseMatrix: Matrix;
  11445. /** @hidden */
  11446. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11447. /** @hidden */
  11448. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11449. }
  11450. }
  11451. }
  11452. declare module "babylonjs/sceneComponent" {
  11453. import { Scene } from "babylonjs/scene";
  11454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11455. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11456. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11457. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11458. import { Nullable } from "babylonjs/types";
  11459. import { Camera } from "babylonjs/Cameras/camera";
  11460. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11461. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11462. import { AbstractScene } from "babylonjs/abstractScene";
  11463. /**
  11464. * Groups all the scene component constants in one place to ease maintenance.
  11465. * @hidden
  11466. */
  11467. export class SceneComponentConstants {
  11468. static readonly NAME_EFFECTLAYER: string;
  11469. static readonly NAME_LAYER: string;
  11470. static readonly NAME_LENSFLARESYSTEM: string;
  11471. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11472. static readonly NAME_PARTICLESYSTEM: string;
  11473. static readonly NAME_GAMEPAD: string;
  11474. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11475. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11476. static readonly NAME_DEPTHRENDERER: string;
  11477. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11478. static readonly NAME_SPRITE: string;
  11479. static readonly NAME_OUTLINERENDERER: string;
  11480. static readonly NAME_PROCEDURALTEXTURE: string;
  11481. static readonly NAME_SHADOWGENERATOR: string;
  11482. static readonly NAME_OCTREE: string;
  11483. static readonly NAME_PHYSICSENGINE: string;
  11484. static readonly NAME_AUDIO: string;
  11485. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11486. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11487. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11488. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11489. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11490. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11491. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11492. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11493. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11494. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11495. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11496. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11497. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11498. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11499. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11500. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11501. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11502. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11503. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11504. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11505. static readonly STEP_AFTERRENDER_AUDIO: number;
  11506. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11507. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11508. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11509. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11510. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11511. static readonly STEP_POINTERMOVE_SPRITE: number;
  11512. static readonly STEP_POINTERDOWN_SPRITE: number;
  11513. static readonly STEP_POINTERUP_SPRITE: number;
  11514. }
  11515. /**
  11516. * This represents a scene component.
  11517. *
  11518. * This is used to decouple the dependency the scene is having on the different workloads like
  11519. * layers, post processes...
  11520. */
  11521. export interface ISceneComponent {
  11522. /**
  11523. * The name of the component. Each component must have a unique name.
  11524. */
  11525. name: string;
  11526. /**
  11527. * The scene the component belongs to.
  11528. */
  11529. scene: Scene;
  11530. /**
  11531. * Register the component to one instance of a scene.
  11532. */
  11533. register(): void;
  11534. /**
  11535. * Rebuilds the elements related to this component in case of
  11536. * context lost for instance.
  11537. */
  11538. rebuild(): void;
  11539. /**
  11540. * Disposes the component and the associated ressources.
  11541. */
  11542. dispose(): void;
  11543. }
  11544. /**
  11545. * This represents a SERIALIZABLE scene component.
  11546. *
  11547. * This extends Scene Component to add Serialization methods on top.
  11548. */
  11549. export interface ISceneSerializableComponent extends ISceneComponent {
  11550. /**
  11551. * Adds all the element from the container to the scene
  11552. * @param container the container holding the elements
  11553. */
  11554. addFromContainer(container: AbstractScene): void;
  11555. /**
  11556. * Removes all the elements in the container from the scene
  11557. * @param container contains the elements to remove
  11558. */
  11559. removeFromContainer(container: AbstractScene): void;
  11560. /**
  11561. * Serializes the component data to the specified json object
  11562. * @param serializationObject The object to serialize to
  11563. */
  11564. serialize(serializationObject: any): void;
  11565. }
  11566. /**
  11567. * Strong typing of a Mesh related stage step action
  11568. */
  11569. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11570. /**
  11571. * Strong typing of a Evaluate Sub Mesh related stage step action
  11572. */
  11573. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11574. /**
  11575. * Strong typing of a Active Mesh related stage step action
  11576. */
  11577. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11578. /**
  11579. * Strong typing of a Camera related stage step action
  11580. */
  11581. export type CameraStageAction = (camera: Camera) => void;
  11582. /**
  11583. * Strong typing of a Render Target related stage step action
  11584. */
  11585. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11586. /**
  11587. * Strong typing of a RenderingGroup related stage step action
  11588. */
  11589. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11590. /**
  11591. * Strong typing of a Mesh Render related stage step action
  11592. */
  11593. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11594. /**
  11595. * Strong typing of a simple stage step action
  11596. */
  11597. export type SimpleStageAction = () => void;
  11598. /**
  11599. * Strong typing of a render target action.
  11600. */
  11601. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11602. /**
  11603. * Strong typing of a pointer move action.
  11604. */
  11605. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11606. /**
  11607. * Strong typing of a pointer up/down action.
  11608. */
  11609. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11610. /**
  11611. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11612. * @hidden
  11613. */
  11614. export class Stage<T extends Function> extends Array<{
  11615. index: number;
  11616. component: ISceneComponent;
  11617. action: T;
  11618. }> {
  11619. /**
  11620. * Hide ctor from the rest of the world.
  11621. * @param items The items to add.
  11622. */
  11623. private constructor();
  11624. /**
  11625. * Creates a new Stage.
  11626. * @returns A new instance of a Stage
  11627. */
  11628. static Create<T extends Function>(): Stage<T>;
  11629. /**
  11630. * Registers a step in an ordered way in the targeted stage.
  11631. * @param index Defines the position to register the step in
  11632. * @param component Defines the component attached to the step
  11633. * @param action Defines the action to launch during the step
  11634. */
  11635. registerStep(index: number, component: ISceneComponent, action: T): void;
  11636. /**
  11637. * Clears all the steps from the stage.
  11638. */
  11639. clear(): void;
  11640. }
  11641. }
  11642. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11643. import { Nullable } from "babylonjs/types";
  11644. import { Observable } from "babylonjs/Misc/observable";
  11645. import { Scene } from "babylonjs/scene";
  11646. import { Sprite } from "babylonjs/Sprites/sprite";
  11647. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11648. import { Ray } from "babylonjs/Culling/ray";
  11649. import { Camera } from "babylonjs/Cameras/camera";
  11650. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11651. import { ISceneComponent } from "babylonjs/sceneComponent";
  11652. module "babylonjs/scene" {
  11653. interface Scene {
  11654. /** @hidden */
  11655. _pointerOverSprite: Nullable<Sprite>;
  11656. /** @hidden */
  11657. _pickedDownSprite: Nullable<Sprite>;
  11658. /** @hidden */
  11659. _tempSpritePickingRay: Nullable<Ray>;
  11660. /**
  11661. * All of the sprite managers added to this scene
  11662. * @see http://doc.babylonjs.com/babylon101/sprites
  11663. */
  11664. spriteManagers: Array<ISpriteManager>;
  11665. /**
  11666. * An event triggered when sprites rendering is about to start
  11667. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11668. */
  11669. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11670. /**
  11671. * An event triggered when sprites rendering is done
  11672. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11673. */
  11674. onAfterSpritesRenderingObservable: Observable<Scene>;
  11675. /** @hidden */
  11676. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11677. /** Launch a ray to try to pick a sprite in the scene
  11678. * @param x position on screen
  11679. * @param y position on screen
  11680. * @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
  11681. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11682. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11683. * @returns a PickingInfo
  11684. */
  11685. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11686. /** Use the given ray to pick a sprite in the scene
  11687. * @param ray The ray (in world space) to use to pick meshes
  11688. * @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
  11689. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11690. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11691. * @returns a PickingInfo
  11692. */
  11693. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11694. /**
  11695. * Force the sprite under the pointer
  11696. * @param sprite defines the sprite to use
  11697. */
  11698. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11699. /**
  11700. * Gets the sprite under the pointer
  11701. * @returns a Sprite or null if no sprite is under the pointer
  11702. */
  11703. getPointerOverSprite(): Nullable<Sprite>;
  11704. }
  11705. }
  11706. /**
  11707. * Defines the sprite scene component responsible to manage sprites
  11708. * in a given scene.
  11709. */
  11710. export class SpriteSceneComponent implements ISceneComponent {
  11711. /**
  11712. * The component name helpfull to identify the component in the list of scene components.
  11713. */
  11714. readonly name: string;
  11715. /**
  11716. * The scene the component belongs to.
  11717. */
  11718. scene: Scene;
  11719. /** @hidden */
  11720. private _spritePredicate;
  11721. /**
  11722. * Creates a new instance of the component for the given scene
  11723. * @param scene Defines the scene to register the component in
  11724. */
  11725. constructor(scene: Scene);
  11726. /**
  11727. * Registers the component in a given scene
  11728. */
  11729. register(): void;
  11730. /**
  11731. * Rebuilds the elements related to this component in case of
  11732. * context lost for instance.
  11733. */
  11734. rebuild(): void;
  11735. /**
  11736. * Disposes the component and the associated ressources.
  11737. */
  11738. dispose(): void;
  11739. private _pickSpriteButKeepRay;
  11740. private _pointerMove;
  11741. private _pointerDown;
  11742. private _pointerUp;
  11743. }
  11744. }
  11745. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11746. /** @hidden */
  11747. export var fogFragmentDeclaration: {
  11748. name: string;
  11749. shader: string;
  11750. };
  11751. }
  11752. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11753. /** @hidden */
  11754. export var fogFragment: {
  11755. name: string;
  11756. shader: string;
  11757. };
  11758. }
  11759. declare module "babylonjs/Shaders/sprites.fragment" {
  11760. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11761. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11762. /** @hidden */
  11763. export var spritesPixelShader: {
  11764. name: string;
  11765. shader: string;
  11766. };
  11767. }
  11768. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11769. /** @hidden */
  11770. export var fogVertexDeclaration: {
  11771. name: string;
  11772. shader: string;
  11773. };
  11774. }
  11775. declare module "babylonjs/Shaders/sprites.vertex" {
  11776. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11777. /** @hidden */
  11778. export var spritesVertexShader: {
  11779. name: string;
  11780. shader: string;
  11781. };
  11782. }
  11783. declare module "babylonjs/Sprites/spriteManager" {
  11784. import { IDisposable, Scene } from "babylonjs/scene";
  11785. import { Nullable } from "babylonjs/types";
  11786. import { Observable } from "babylonjs/Misc/observable";
  11787. import { Sprite } from "babylonjs/Sprites/sprite";
  11788. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11789. import { Camera } from "babylonjs/Cameras/camera";
  11790. import { Texture } from "babylonjs/Materials/Textures/texture";
  11791. import "babylonjs/Shaders/sprites.fragment";
  11792. import "babylonjs/Shaders/sprites.vertex";
  11793. import { Ray } from "babylonjs/Culling/ray";
  11794. /**
  11795. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11796. */
  11797. export interface ISpriteManager extends IDisposable {
  11798. /**
  11799. * Restricts the camera to viewing objects with the same layerMask.
  11800. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11801. */
  11802. layerMask: number;
  11803. /**
  11804. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11805. */
  11806. isPickable: boolean;
  11807. /**
  11808. * Specifies the rendering group id for this mesh (0 by default)
  11809. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11810. */
  11811. renderingGroupId: number;
  11812. /**
  11813. * Defines the list of sprites managed by the manager.
  11814. */
  11815. sprites: Array<Sprite>;
  11816. /**
  11817. * Tests the intersection of a sprite with a specific ray.
  11818. * @param ray The ray we are sending to test the collision
  11819. * @param camera The camera space we are sending rays in
  11820. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11821. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11822. * @returns picking info or null.
  11823. */
  11824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11825. /**
  11826. * Renders the list of sprites on screen.
  11827. */
  11828. render(): void;
  11829. }
  11830. /**
  11831. * Class used to manage multiple sprites on the same spritesheet
  11832. * @see http://doc.babylonjs.com/babylon101/sprites
  11833. */
  11834. export class SpriteManager implements ISpriteManager {
  11835. /** defines the manager's name */
  11836. name: string;
  11837. /** Gets the list of sprites */
  11838. sprites: Sprite[];
  11839. /** Gets or sets the rendering group id (0 by default) */
  11840. renderingGroupId: number;
  11841. /** Gets or sets camera layer mask */
  11842. layerMask: number;
  11843. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11844. fogEnabled: boolean;
  11845. /** Gets or sets a boolean indicating if the sprites are pickable */
  11846. isPickable: boolean;
  11847. /** Defines the default width of a cell in the spritesheet */
  11848. cellWidth: number;
  11849. /** Defines the default height of a cell in the spritesheet */
  11850. cellHeight: number;
  11851. /**
  11852. * An event triggered when the manager is disposed.
  11853. */
  11854. onDisposeObservable: Observable<SpriteManager>;
  11855. private _onDisposeObserver;
  11856. /**
  11857. * Callback called when the manager is disposed
  11858. */
  11859. onDispose: () => void;
  11860. private _capacity;
  11861. private _spriteTexture;
  11862. private _epsilon;
  11863. private _scene;
  11864. private _vertexData;
  11865. private _buffer;
  11866. private _vertexBuffers;
  11867. private _indexBuffer;
  11868. private _effectBase;
  11869. private _effectFog;
  11870. /**
  11871. * Gets or sets the spritesheet texture
  11872. */
  11873. texture: Texture;
  11874. /**
  11875. * Creates a new sprite manager
  11876. * @param name defines the manager's name
  11877. * @param imgUrl defines the sprite sheet url
  11878. * @param capacity defines the maximum allowed number of sprites
  11879. * @param cellSize defines the size of a sprite cell
  11880. * @param scene defines the hosting scene
  11881. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11882. * @param samplingMode defines the smapling mode to use with spritesheet
  11883. */
  11884. constructor(
  11885. /** defines the manager's name */
  11886. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11887. private _appendSpriteVertex;
  11888. /**
  11889. * Intersects the sprites with a ray
  11890. * @param ray defines the ray to intersect with
  11891. * @param camera defines the current active camera
  11892. * @param predicate defines a predicate used to select candidate sprites
  11893. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11894. * @returns null if no hit or a PickingInfo
  11895. */
  11896. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11897. /**
  11898. * Render all child sprites
  11899. */
  11900. render(): void;
  11901. /**
  11902. * Release associated resources
  11903. */
  11904. dispose(): void;
  11905. }
  11906. }
  11907. declare module "babylonjs/Sprites/sprite" {
  11908. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11909. import { Nullable } from "babylonjs/types";
  11910. import { ActionManager } from "babylonjs/Actions/actionManager";
  11911. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11912. /**
  11913. * Class used to represent a sprite
  11914. * @see http://doc.babylonjs.com/babylon101/sprites
  11915. */
  11916. export class Sprite {
  11917. /** defines the name */
  11918. name: string;
  11919. /** Gets or sets the current world position */
  11920. position: Vector3;
  11921. /** Gets or sets the main color */
  11922. color: Color4;
  11923. /** Gets or sets the width */
  11924. width: number;
  11925. /** Gets or sets the height */
  11926. height: number;
  11927. /** Gets or sets rotation angle */
  11928. angle: number;
  11929. /** Gets or sets the cell index in the sprite sheet */
  11930. cellIndex: number;
  11931. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11932. invertU: number;
  11933. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11934. invertV: number;
  11935. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11936. disposeWhenFinishedAnimating: boolean;
  11937. /** Gets the list of attached animations */
  11938. animations: Animation[];
  11939. /** Gets or sets a boolean indicating if the sprite can be picked */
  11940. isPickable: boolean;
  11941. /**
  11942. * Gets or sets the associated action manager
  11943. */
  11944. actionManager: Nullable<ActionManager>;
  11945. private _animationStarted;
  11946. private _loopAnimation;
  11947. private _fromIndex;
  11948. private _toIndex;
  11949. private _delay;
  11950. private _direction;
  11951. private _manager;
  11952. private _time;
  11953. private _onAnimationEnd;
  11954. /**
  11955. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11956. */
  11957. isVisible: boolean;
  11958. /**
  11959. * Gets or sets the sprite size
  11960. */
  11961. size: number;
  11962. /**
  11963. * Creates a new Sprite
  11964. * @param name defines the name
  11965. * @param manager defines the manager
  11966. */
  11967. constructor(
  11968. /** defines the name */
  11969. name: string, manager: ISpriteManager);
  11970. /**
  11971. * Starts an animation
  11972. * @param from defines the initial key
  11973. * @param to defines the end key
  11974. * @param loop defines if the animation must loop
  11975. * @param delay defines the start delay (in ms)
  11976. * @param onAnimationEnd defines a callback to call when animation ends
  11977. */
  11978. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11979. /** Stops current animation (if any) */
  11980. stopAnimation(): void;
  11981. /** @hidden */
  11982. _animate(deltaTime: number): void;
  11983. /** Release associated resources */
  11984. dispose(): void;
  11985. }
  11986. }
  11987. declare module "babylonjs/Collisions/pickingInfo" {
  11988. import { Nullable } from "babylonjs/types";
  11989. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11991. import { Sprite } from "babylonjs/Sprites/sprite";
  11992. import { Ray } from "babylonjs/Culling/ray";
  11993. /**
  11994. * Information about the result of picking within a scene
  11995. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11996. */
  11997. export class PickingInfo {
  11998. /** @hidden */
  11999. _pickingUnavailable: boolean;
  12000. /**
  12001. * If the pick collided with an object
  12002. */
  12003. hit: boolean;
  12004. /**
  12005. * Distance away where the pick collided
  12006. */
  12007. distance: number;
  12008. /**
  12009. * The location of pick collision
  12010. */
  12011. pickedPoint: Nullable<Vector3>;
  12012. /**
  12013. * The mesh corresponding the the pick collision
  12014. */
  12015. pickedMesh: Nullable<AbstractMesh>;
  12016. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12017. bu: number;
  12018. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12019. bv: number;
  12020. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12021. faceId: number;
  12022. /** Id of the the submesh that was picked */
  12023. subMeshId: number;
  12024. /** If a sprite was picked, this will be the sprite the pick collided with */
  12025. pickedSprite: Nullable<Sprite>;
  12026. /**
  12027. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12028. */
  12029. originMesh: Nullable<AbstractMesh>;
  12030. /**
  12031. * The ray that was used to perform the picking.
  12032. */
  12033. ray: Nullable<Ray>;
  12034. /**
  12035. * Gets the normal correspodning to the face the pick collided with
  12036. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12037. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12038. * @returns The normal correspodning to the face the pick collided with
  12039. */
  12040. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12041. /**
  12042. * Gets the texture coordinates of where the pick occured
  12043. * @returns the vector containing the coordnates of the texture
  12044. */
  12045. getTextureCoordinates(): Nullable<Vector2>;
  12046. }
  12047. }
  12048. declare module "babylonjs/Events/pointerEvents" {
  12049. import { Nullable } from "babylonjs/types";
  12050. import { Vector2 } from "babylonjs/Maths/math";
  12051. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12052. import { Ray } from "babylonjs/Culling/ray";
  12053. /**
  12054. * Gather the list of pointer event types as constants.
  12055. */
  12056. export class PointerEventTypes {
  12057. /**
  12058. * 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.
  12059. */
  12060. static readonly POINTERDOWN: number;
  12061. /**
  12062. * The pointerup event is fired when a pointer is no longer active.
  12063. */
  12064. static readonly POINTERUP: number;
  12065. /**
  12066. * The pointermove event is fired when a pointer changes coordinates.
  12067. */
  12068. static readonly POINTERMOVE: number;
  12069. /**
  12070. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12071. */
  12072. static readonly POINTERWHEEL: number;
  12073. /**
  12074. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12075. */
  12076. static readonly POINTERPICK: number;
  12077. /**
  12078. * The pointertap event is fired when a the object has been touched and released without drag.
  12079. */
  12080. static readonly POINTERTAP: number;
  12081. /**
  12082. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12083. */
  12084. static readonly POINTERDOUBLETAP: number;
  12085. }
  12086. /**
  12087. * Base class of pointer info types.
  12088. */
  12089. export class PointerInfoBase {
  12090. /**
  12091. * Defines the type of event (PointerEventTypes)
  12092. */
  12093. type: number;
  12094. /**
  12095. * Defines the related dom event
  12096. */
  12097. event: PointerEvent | MouseWheelEvent;
  12098. /**
  12099. * Instantiates the base class of pointers info.
  12100. * @param type Defines the type of event (PointerEventTypes)
  12101. * @param event Defines the related dom event
  12102. */
  12103. constructor(
  12104. /**
  12105. * Defines the type of event (PointerEventTypes)
  12106. */
  12107. type: number,
  12108. /**
  12109. * Defines the related dom event
  12110. */
  12111. event: PointerEvent | MouseWheelEvent);
  12112. }
  12113. /**
  12114. * This class is used to store pointer related info for the onPrePointerObservable event.
  12115. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12116. */
  12117. export class PointerInfoPre extends PointerInfoBase {
  12118. /**
  12119. * Ray from a pointer if availible (eg. 6dof controller)
  12120. */
  12121. ray: Nullable<Ray>;
  12122. /**
  12123. * Defines the local position of the pointer on the canvas.
  12124. */
  12125. localPosition: Vector2;
  12126. /**
  12127. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12128. */
  12129. skipOnPointerObservable: boolean;
  12130. /**
  12131. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12132. * @param type Defines the type of event (PointerEventTypes)
  12133. * @param event Defines the related dom event
  12134. * @param localX Defines the local x coordinates of the pointer when the event occured
  12135. * @param localY Defines the local y coordinates of the pointer when the event occured
  12136. */
  12137. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12138. }
  12139. /**
  12140. * This type contains all the data related to a pointer event in Babylon.js.
  12141. * 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.
  12142. */
  12143. export class PointerInfo extends PointerInfoBase {
  12144. /**
  12145. * Defines the picking info associated to the info (if any)\
  12146. */
  12147. pickInfo: Nullable<PickingInfo>;
  12148. /**
  12149. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12150. * @param type Defines the type of event (PointerEventTypes)
  12151. * @param event Defines the related dom event
  12152. * @param pickInfo Defines the picking info associated to the info (if any)\
  12153. */
  12154. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12155. /**
  12156. * Defines the picking info associated to the info (if any)\
  12157. */
  12158. pickInfo: Nullable<PickingInfo>);
  12159. }
  12160. /**
  12161. * Data relating to a touch event on the screen.
  12162. */
  12163. export interface PointerTouch {
  12164. /**
  12165. * X coordinate of touch.
  12166. */
  12167. x: number;
  12168. /**
  12169. * Y coordinate of touch.
  12170. */
  12171. y: number;
  12172. /**
  12173. * Id of touch. Unique for each finger.
  12174. */
  12175. pointerId: number;
  12176. /**
  12177. * Event type passed from DOM.
  12178. */
  12179. type: any;
  12180. }
  12181. }
  12182. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12183. import { Nullable } from "babylonjs/types";
  12184. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12185. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12186. /**
  12187. * Manage the mouse inputs to control the movement of a free camera.
  12188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12189. */
  12190. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12191. /**
  12192. * Define if touch is enabled in the mouse input
  12193. */
  12194. touchEnabled: boolean;
  12195. /**
  12196. * Defines the camera the input is attached to.
  12197. */
  12198. camera: FreeCamera;
  12199. /**
  12200. * Defines the buttons associated with the input to handle camera move.
  12201. */
  12202. buttons: number[];
  12203. /**
  12204. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12205. */
  12206. angularSensibility: number;
  12207. private _pointerInput;
  12208. private _onMouseMove;
  12209. private _observer;
  12210. private previousPosition;
  12211. /**
  12212. * Manage the mouse inputs to control the movement of a free camera.
  12213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12214. * @param touchEnabled Defines if touch is enabled or not
  12215. */
  12216. constructor(
  12217. /**
  12218. * Define if touch is enabled in the mouse input
  12219. */
  12220. touchEnabled?: boolean);
  12221. /**
  12222. * Attach the input controls to a specific dom element to get the input from.
  12223. * @param element Defines the element the controls should be listened from
  12224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12225. */
  12226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12227. /**
  12228. * Called on JS contextmenu event.
  12229. * Override this method to provide functionality.
  12230. */
  12231. protected onContextMenu(evt: PointerEvent): void;
  12232. /**
  12233. * Detach the current controls from the specified dom element.
  12234. * @param element Defines the element to stop listening the inputs from
  12235. */
  12236. detachControl(element: Nullable<HTMLElement>): void;
  12237. /**
  12238. * Gets the class name of the current intput.
  12239. * @returns the class name
  12240. */
  12241. getClassName(): string;
  12242. /**
  12243. * Get the friendly name associated with the input class.
  12244. * @returns the input friendly name
  12245. */
  12246. getSimpleName(): string;
  12247. }
  12248. }
  12249. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12250. import { Nullable } from "babylonjs/types";
  12251. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12252. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12253. /**
  12254. * Manage the touch inputs to control the movement of a free camera.
  12255. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12256. */
  12257. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12258. /**
  12259. * Defines the camera the input is attached to.
  12260. */
  12261. camera: FreeCamera;
  12262. /**
  12263. * Defines the touch sensibility for rotation.
  12264. * The higher the faster.
  12265. */
  12266. touchAngularSensibility: number;
  12267. /**
  12268. * Defines the touch sensibility for move.
  12269. * The higher the faster.
  12270. */
  12271. touchMoveSensibility: number;
  12272. private _offsetX;
  12273. private _offsetY;
  12274. private _pointerPressed;
  12275. private _pointerInput;
  12276. private _observer;
  12277. private _onLostFocus;
  12278. /**
  12279. * Attach the input controls to a specific dom element to get the input from.
  12280. * @param element Defines the element the controls should be listened from
  12281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12282. */
  12283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12284. /**
  12285. * Detach the current controls from the specified dom element.
  12286. * @param element Defines the element to stop listening the inputs from
  12287. */
  12288. detachControl(element: Nullable<HTMLElement>): void;
  12289. /**
  12290. * Update the current camera state depending on the inputs that have been used this frame.
  12291. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12292. */
  12293. checkInputs(): void;
  12294. /**
  12295. * Gets the class name of the current intput.
  12296. * @returns the class name
  12297. */
  12298. getClassName(): string;
  12299. /**
  12300. * Get the friendly name associated with the input class.
  12301. * @returns the input friendly name
  12302. */
  12303. getSimpleName(): string;
  12304. }
  12305. }
  12306. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12307. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12308. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12309. /**
  12310. * Default Inputs manager for the FreeCamera.
  12311. * It groups all the default supported inputs for ease of use.
  12312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12313. */
  12314. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12315. /**
  12316. * Instantiates a new FreeCameraInputsManager.
  12317. * @param camera Defines the camera the inputs belong to
  12318. */
  12319. constructor(camera: FreeCamera);
  12320. /**
  12321. * Add keyboard input support to the input manager.
  12322. * @returns the current input manager
  12323. */
  12324. addKeyboard(): FreeCameraInputsManager;
  12325. /**
  12326. * Add mouse input support to the input manager.
  12327. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12328. * @returns the current input manager
  12329. */
  12330. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12331. /**
  12332. * Add touch input support to the input manager.
  12333. * @returns the current input manager
  12334. */
  12335. addTouch(): FreeCameraInputsManager;
  12336. }
  12337. }
  12338. declare module "babylonjs/Cameras/freeCamera" {
  12339. import { Vector3 } from "babylonjs/Maths/math";
  12340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12341. import { Scene } from "babylonjs/scene";
  12342. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12343. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12344. /**
  12345. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12346. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12347. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12348. */
  12349. export class FreeCamera extends TargetCamera {
  12350. /**
  12351. * Define the collision ellipsoid of the camera.
  12352. * This is helpful to simulate a camera body like the player body around the camera
  12353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12354. */
  12355. ellipsoid: Vector3;
  12356. /**
  12357. * Define an offset for the position of the ellipsoid around the camera.
  12358. * This can be helpful to determine the center of the body near the gravity center of the body
  12359. * instead of its head.
  12360. */
  12361. ellipsoidOffset: Vector3;
  12362. /**
  12363. * Enable or disable collisions of the camera with the rest of the scene objects.
  12364. */
  12365. checkCollisions: boolean;
  12366. /**
  12367. * Enable or disable gravity on the camera.
  12368. */
  12369. applyGravity: boolean;
  12370. /**
  12371. * Define the input manager associated to the camera.
  12372. */
  12373. inputs: FreeCameraInputsManager;
  12374. /**
  12375. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12376. * Higher values reduce sensitivity.
  12377. */
  12378. /**
  12379. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12380. * Higher values reduce sensitivity.
  12381. */
  12382. angularSensibility: number;
  12383. /**
  12384. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12385. */
  12386. keysUp: number[];
  12387. /**
  12388. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12389. */
  12390. keysDown: number[];
  12391. /**
  12392. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12393. */
  12394. keysLeft: number[];
  12395. /**
  12396. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12397. */
  12398. keysRight: number[];
  12399. /**
  12400. * Event raised when the camera collide with a mesh in the scene.
  12401. */
  12402. onCollide: (collidedMesh: AbstractMesh) => void;
  12403. private _collider;
  12404. private _needMoveForGravity;
  12405. private _oldPosition;
  12406. private _diffPosition;
  12407. private _newPosition;
  12408. /** @hidden */
  12409. _localDirection: Vector3;
  12410. /** @hidden */
  12411. _transformedDirection: Vector3;
  12412. /**
  12413. * Instantiates a Free Camera.
  12414. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12415. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12416. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12417. * @param name Define the name of the camera in the scene
  12418. * @param position Define the start position of the camera in the scene
  12419. * @param scene Define the scene the camera belongs to
  12420. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12421. */
  12422. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12423. /**
  12424. * Attached controls to the current camera.
  12425. * @param element Defines the element the controls should be listened from
  12426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12427. */
  12428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12429. /**
  12430. * Detach the current controls from the camera.
  12431. * The camera will stop reacting to inputs.
  12432. * @param element Defines the element to stop listening the inputs from
  12433. */
  12434. detachControl(element: HTMLElement): void;
  12435. private _collisionMask;
  12436. /**
  12437. * Define a collision mask to limit the list of object the camera can collide with
  12438. */
  12439. collisionMask: number;
  12440. /** @hidden */
  12441. _collideWithWorld(displacement: Vector3): void;
  12442. private _onCollisionPositionChange;
  12443. /** @hidden */
  12444. _checkInputs(): void;
  12445. /** @hidden */
  12446. _decideIfNeedsToMove(): boolean;
  12447. /** @hidden */
  12448. _updatePosition(): void;
  12449. /**
  12450. * Destroy the camera and release the current resources hold by it.
  12451. */
  12452. dispose(): void;
  12453. /**
  12454. * Gets the current object class name.
  12455. * @return the class name
  12456. */
  12457. getClassName(): string;
  12458. }
  12459. }
  12460. declare module "babylonjs/Gamepads/gamepad" {
  12461. import { Observable } from "babylonjs/Misc/observable";
  12462. /**
  12463. * Represents a gamepad control stick position
  12464. */
  12465. export class StickValues {
  12466. /**
  12467. * The x component of the control stick
  12468. */
  12469. x: number;
  12470. /**
  12471. * The y component of the control stick
  12472. */
  12473. y: number;
  12474. /**
  12475. * Initializes the gamepad x and y control stick values
  12476. * @param x The x component of the gamepad control stick value
  12477. * @param y The y component of the gamepad control stick value
  12478. */
  12479. constructor(
  12480. /**
  12481. * The x component of the control stick
  12482. */
  12483. x: number,
  12484. /**
  12485. * The y component of the control stick
  12486. */
  12487. y: number);
  12488. }
  12489. /**
  12490. * An interface which manages callbacks for gamepad button changes
  12491. */
  12492. export interface GamepadButtonChanges {
  12493. /**
  12494. * Called when a gamepad has been changed
  12495. */
  12496. changed: boolean;
  12497. /**
  12498. * Called when a gamepad press event has been triggered
  12499. */
  12500. pressChanged: boolean;
  12501. /**
  12502. * Called when a touch event has been triggered
  12503. */
  12504. touchChanged: boolean;
  12505. /**
  12506. * Called when a value has changed
  12507. */
  12508. valueChanged: boolean;
  12509. }
  12510. /**
  12511. * Represents a gamepad
  12512. */
  12513. export class Gamepad {
  12514. /**
  12515. * The id of the gamepad
  12516. */
  12517. id: string;
  12518. /**
  12519. * The index of the gamepad
  12520. */
  12521. index: number;
  12522. /**
  12523. * The browser gamepad
  12524. */
  12525. browserGamepad: any;
  12526. /**
  12527. * Specifies what type of gamepad this represents
  12528. */
  12529. type: number;
  12530. private _leftStick;
  12531. private _rightStick;
  12532. /** @hidden */
  12533. _isConnected: boolean;
  12534. private _leftStickAxisX;
  12535. private _leftStickAxisY;
  12536. private _rightStickAxisX;
  12537. private _rightStickAxisY;
  12538. /**
  12539. * Triggered when the left control stick has been changed
  12540. */
  12541. private _onleftstickchanged;
  12542. /**
  12543. * Triggered when the right control stick has been changed
  12544. */
  12545. private _onrightstickchanged;
  12546. /**
  12547. * Represents a gamepad controller
  12548. */
  12549. static GAMEPAD: number;
  12550. /**
  12551. * Represents a generic controller
  12552. */
  12553. static GENERIC: number;
  12554. /**
  12555. * Represents an XBox controller
  12556. */
  12557. static XBOX: number;
  12558. /**
  12559. * Represents a pose-enabled controller
  12560. */
  12561. static POSE_ENABLED: number;
  12562. /**
  12563. * Specifies whether the left control stick should be Y-inverted
  12564. */
  12565. protected _invertLeftStickY: boolean;
  12566. /**
  12567. * Specifies if the gamepad has been connected
  12568. */
  12569. readonly isConnected: boolean;
  12570. /**
  12571. * Initializes the gamepad
  12572. * @param id The id of the gamepad
  12573. * @param index The index of the gamepad
  12574. * @param browserGamepad The browser gamepad
  12575. * @param leftStickX The x component of the left joystick
  12576. * @param leftStickY The y component of the left joystick
  12577. * @param rightStickX The x component of the right joystick
  12578. * @param rightStickY The y component of the right joystick
  12579. */
  12580. constructor(
  12581. /**
  12582. * The id of the gamepad
  12583. */
  12584. id: string,
  12585. /**
  12586. * The index of the gamepad
  12587. */
  12588. index: number,
  12589. /**
  12590. * The browser gamepad
  12591. */
  12592. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12593. /**
  12594. * Callback triggered when the left joystick has changed
  12595. * @param callback
  12596. */
  12597. onleftstickchanged(callback: (values: StickValues) => void): void;
  12598. /**
  12599. * Callback triggered when the right joystick has changed
  12600. * @param callback
  12601. */
  12602. onrightstickchanged(callback: (values: StickValues) => void): void;
  12603. /**
  12604. * Gets the left joystick
  12605. */
  12606. /**
  12607. * Sets the left joystick values
  12608. */
  12609. leftStick: StickValues;
  12610. /**
  12611. * Gets the right joystick
  12612. */
  12613. /**
  12614. * Sets the right joystick value
  12615. */
  12616. rightStick: StickValues;
  12617. /**
  12618. * Updates the gamepad joystick positions
  12619. */
  12620. update(): void;
  12621. /**
  12622. * Disposes the gamepad
  12623. */
  12624. dispose(): void;
  12625. }
  12626. /**
  12627. * Represents a generic gamepad
  12628. */
  12629. export class GenericPad extends Gamepad {
  12630. private _buttons;
  12631. private _onbuttondown;
  12632. private _onbuttonup;
  12633. /**
  12634. * Observable triggered when a button has been pressed
  12635. */
  12636. onButtonDownObservable: Observable<number>;
  12637. /**
  12638. * Observable triggered when a button has been released
  12639. */
  12640. onButtonUpObservable: Observable<number>;
  12641. /**
  12642. * Callback triggered when a button has been pressed
  12643. * @param callback Called when a button has been pressed
  12644. */
  12645. onbuttondown(callback: (buttonPressed: number) => void): void;
  12646. /**
  12647. * Callback triggered when a button has been released
  12648. * @param callback Called when a button has been released
  12649. */
  12650. onbuttonup(callback: (buttonReleased: number) => void): void;
  12651. /**
  12652. * Initializes the generic gamepad
  12653. * @param id The id of the generic gamepad
  12654. * @param index The index of the generic gamepad
  12655. * @param browserGamepad The browser gamepad
  12656. */
  12657. constructor(id: string, index: number, browserGamepad: any);
  12658. private _setButtonValue;
  12659. /**
  12660. * Updates the generic gamepad
  12661. */
  12662. update(): void;
  12663. /**
  12664. * Disposes the generic gamepad
  12665. */
  12666. dispose(): void;
  12667. }
  12668. }
  12669. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12670. import { Observable } from "babylonjs/Misc/observable";
  12671. import { Nullable } from "babylonjs/types";
  12672. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12673. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12675. import { Ray } from "babylonjs/Culling/ray";
  12676. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12677. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12678. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12679. /**
  12680. * Defines the types of pose enabled controllers that are supported
  12681. */
  12682. export enum PoseEnabledControllerType {
  12683. /**
  12684. * HTC Vive
  12685. */
  12686. VIVE = 0,
  12687. /**
  12688. * Oculus Rift
  12689. */
  12690. OCULUS = 1,
  12691. /**
  12692. * Windows mixed reality
  12693. */
  12694. WINDOWS = 2,
  12695. /**
  12696. * Samsung gear VR
  12697. */
  12698. GEAR_VR = 3,
  12699. /**
  12700. * Google Daydream
  12701. */
  12702. DAYDREAM = 4,
  12703. /**
  12704. * Generic
  12705. */
  12706. GENERIC = 5
  12707. }
  12708. /**
  12709. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12710. */
  12711. export interface MutableGamepadButton {
  12712. /**
  12713. * Value of the button/trigger
  12714. */
  12715. value: number;
  12716. /**
  12717. * If the button/trigger is currently touched
  12718. */
  12719. touched: boolean;
  12720. /**
  12721. * If the button/trigger is currently pressed
  12722. */
  12723. pressed: boolean;
  12724. }
  12725. /**
  12726. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12727. * @hidden
  12728. */
  12729. export interface ExtendedGamepadButton extends GamepadButton {
  12730. /**
  12731. * If the button/trigger is currently pressed
  12732. */
  12733. readonly pressed: boolean;
  12734. /**
  12735. * If the button/trigger is currently touched
  12736. */
  12737. readonly touched: boolean;
  12738. /**
  12739. * Value of the button/trigger
  12740. */
  12741. readonly value: number;
  12742. }
  12743. /** @hidden */
  12744. export interface _GamePadFactory {
  12745. /**
  12746. * Returns wether or not the current gamepad can be created for this type of controller.
  12747. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12748. * @returns true if it can be created, otherwise false
  12749. */
  12750. canCreate(gamepadInfo: any): boolean;
  12751. /**
  12752. * Creates a new instance of the Gamepad.
  12753. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12754. * @returns the new gamepad instance
  12755. */
  12756. create(gamepadInfo: any): Gamepad;
  12757. }
  12758. /**
  12759. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12760. */
  12761. export class PoseEnabledControllerHelper {
  12762. /** @hidden */
  12763. static _ControllerFactories: _GamePadFactory[];
  12764. /** @hidden */
  12765. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12766. /**
  12767. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12768. * @param vrGamepad the gamepad to initialized
  12769. * @returns a vr controller of the type the gamepad identified as
  12770. */
  12771. static InitiateController(vrGamepad: any): Gamepad;
  12772. }
  12773. /**
  12774. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12775. */
  12776. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12777. private _deviceRoomPosition;
  12778. private _deviceRoomRotationQuaternion;
  12779. /**
  12780. * The device position in babylon space
  12781. */
  12782. devicePosition: Vector3;
  12783. /**
  12784. * The device rotation in babylon space
  12785. */
  12786. deviceRotationQuaternion: Quaternion;
  12787. /**
  12788. * The scale factor of the device in babylon space
  12789. */
  12790. deviceScaleFactor: number;
  12791. /**
  12792. * (Likely devicePosition should be used instead) The device position in its room space
  12793. */
  12794. position: Vector3;
  12795. /**
  12796. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12797. */
  12798. rotationQuaternion: Quaternion;
  12799. /**
  12800. * The type of controller (Eg. Windows mixed reality)
  12801. */
  12802. controllerType: PoseEnabledControllerType;
  12803. protected _calculatedPosition: Vector3;
  12804. private _calculatedRotation;
  12805. /**
  12806. * The raw pose from the device
  12807. */
  12808. rawPose: DevicePose;
  12809. private _trackPosition;
  12810. private _maxRotationDistFromHeadset;
  12811. private _draggedRoomRotation;
  12812. /**
  12813. * @hidden
  12814. */
  12815. _disableTrackPosition(fixedPosition: Vector3): void;
  12816. /**
  12817. * Internal, the mesh attached to the controller
  12818. * @hidden
  12819. */
  12820. _mesh: Nullable<AbstractMesh>;
  12821. private _poseControlledCamera;
  12822. private _leftHandSystemQuaternion;
  12823. /**
  12824. * Internal, matrix used to convert room space to babylon space
  12825. * @hidden
  12826. */
  12827. _deviceToWorld: Matrix;
  12828. /**
  12829. * Node to be used when casting a ray from the controller
  12830. * @hidden
  12831. */
  12832. _pointingPoseNode: Nullable<TransformNode>;
  12833. /**
  12834. * Name of the child mesh that can be used to cast a ray from the controller
  12835. */
  12836. static readonly POINTING_POSE: string;
  12837. /**
  12838. * Creates a new PoseEnabledController from a gamepad
  12839. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12840. */
  12841. constructor(browserGamepad: any);
  12842. private _workingMatrix;
  12843. /**
  12844. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12845. */
  12846. update(): void;
  12847. /**
  12848. * Updates only the pose device and mesh without doing any button event checking
  12849. */
  12850. protected _updatePoseAndMesh(): void;
  12851. /**
  12852. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12853. * @param poseData raw pose fromthe device
  12854. */
  12855. updateFromDevice(poseData: DevicePose): void;
  12856. /**
  12857. * @hidden
  12858. */
  12859. _meshAttachedObservable: Observable<AbstractMesh>;
  12860. /**
  12861. * Attaches a mesh to the controller
  12862. * @param mesh the mesh to be attached
  12863. */
  12864. attachToMesh(mesh: AbstractMesh): void;
  12865. /**
  12866. * Attaches the controllers mesh to a camera
  12867. * @param camera the camera the mesh should be attached to
  12868. */
  12869. attachToPoseControlledCamera(camera: TargetCamera): void;
  12870. /**
  12871. * Disposes of the controller
  12872. */
  12873. dispose(): void;
  12874. /**
  12875. * The mesh that is attached to the controller
  12876. */
  12877. readonly mesh: Nullable<AbstractMesh>;
  12878. /**
  12879. * Gets the ray of the controller in the direction the controller is pointing
  12880. * @param length the length the resulting ray should be
  12881. * @returns a ray in the direction the controller is pointing
  12882. */
  12883. getForwardRay(length?: number): Ray;
  12884. }
  12885. }
  12886. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12887. import { Observable } from "babylonjs/Misc/observable";
  12888. import { Scene } from "babylonjs/scene";
  12889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12890. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12891. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12892. /**
  12893. * Defines the WebVRController object that represents controllers tracked in 3D space
  12894. */
  12895. export abstract class WebVRController extends PoseEnabledController {
  12896. /**
  12897. * Internal, the default controller model for the controller
  12898. */
  12899. protected _defaultModel: AbstractMesh;
  12900. /**
  12901. * Fired when the trigger state has changed
  12902. */
  12903. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12904. /**
  12905. * Fired when the main button state has changed
  12906. */
  12907. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12908. /**
  12909. * Fired when the secondary button state has changed
  12910. */
  12911. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12912. /**
  12913. * Fired when the pad state has changed
  12914. */
  12915. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12916. /**
  12917. * Fired when controllers stick values have changed
  12918. */
  12919. onPadValuesChangedObservable: Observable<StickValues>;
  12920. /**
  12921. * Array of button availible on the controller
  12922. */
  12923. protected _buttons: Array<MutableGamepadButton>;
  12924. private _onButtonStateChange;
  12925. /**
  12926. * Fired when a controller button's state has changed
  12927. * @param callback the callback containing the button that was modified
  12928. */
  12929. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12930. /**
  12931. * X and Y axis corrisponding to the controllers joystick
  12932. */
  12933. pad: StickValues;
  12934. /**
  12935. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12936. */
  12937. hand: string;
  12938. /**
  12939. * The default controller model for the controller
  12940. */
  12941. readonly defaultModel: AbstractMesh;
  12942. /**
  12943. * Creates a new WebVRController from a gamepad
  12944. * @param vrGamepad the gamepad that the WebVRController should be created from
  12945. */
  12946. constructor(vrGamepad: any);
  12947. /**
  12948. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12949. */
  12950. update(): void;
  12951. /**
  12952. * Function to be called when a button is modified
  12953. */
  12954. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12955. /**
  12956. * Loads a mesh and attaches it to the controller
  12957. * @param scene the scene the mesh should be added to
  12958. * @param meshLoaded callback for when the mesh has been loaded
  12959. */
  12960. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12961. private _setButtonValue;
  12962. private _changes;
  12963. private _checkChanges;
  12964. /**
  12965. * Disposes of th webVRCOntroller
  12966. */
  12967. dispose(): void;
  12968. }
  12969. }
  12970. declare module "babylonjs/Lights/hemisphericLight" {
  12971. import { Nullable } from "babylonjs/types";
  12972. import { Scene } from "babylonjs/scene";
  12973. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12974. import { Effect } from "babylonjs/Materials/effect";
  12975. import { Light } from "babylonjs/Lights/light";
  12976. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12977. /**
  12978. * The HemisphericLight simulates the ambient environment light,
  12979. * so the passed direction is the light reflection direction, not the incoming direction.
  12980. */
  12981. export class HemisphericLight extends Light {
  12982. /**
  12983. * The groundColor is the light in the opposite direction to the one specified during creation.
  12984. * 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.
  12985. */
  12986. groundColor: Color3;
  12987. /**
  12988. * The light reflection direction, not the incoming direction.
  12989. */
  12990. direction: Vector3;
  12991. /**
  12992. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12993. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12994. * The HemisphericLight can't cast shadows.
  12995. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12996. * @param name The friendly name of the light
  12997. * @param direction The direction of the light reflection
  12998. * @param scene The scene the light belongs to
  12999. */
  13000. constructor(name: string, direction: Vector3, scene: Scene);
  13001. protected _buildUniformLayout(): void;
  13002. /**
  13003. * Returns the string "HemisphericLight".
  13004. * @return The class name
  13005. */
  13006. getClassName(): string;
  13007. /**
  13008. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13009. * Returns the updated direction.
  13010. * @param target The target the direction should point to
  13011. * @return The computed direction
  13012. */
  13013. setDirectionToTarget(target: Vector3): Vector3;
  13014. /**
  13015. * Returns the shadow generator associated to the light.
  13016. * @returns Always null for hemispheric lights because it does not support shadows.
  13017. */
  13018. getShadowGenerator(): Nullable<IShadowGenerator>;
  13019. /**
  13020. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13021. * @param effect The effect to update
  13022. * @param lightIndex The index of the light in the effect to update
  13023. * @returns The hemispheric light
  13024. */
  13025. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13026. /**
  13027. * Computes the world matrix of the node
  13028. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13029. * @param useWasUpdatedFlag defines a reserved property
  13030. * @returns the world matrix
  13031. */
  13032. computeWorldMatrix(): Matrix;
  13033. /**
  13034. * Returns the integer 3.
  13035. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13036. */
  13037. getTypeID(): number;
  13038. /**
  13039. * Prepares the list of defines specific to the light type.
  13040. * @param defines the list of defines
  13041. * @param lightIndex defines the index of the light for the effect
  13042. */
  13043. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13044. }
  13045. }
  13046. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13047. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13048. import { Nullable } from "babylonjs/types";
  13049. import { Observable } from "babylonjs/Misc/observable";
  13050. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13051. import { Scene } from "babylonjs/scene";
  13052. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13053. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13054. import { Node } from "babylonjs/node";
  13055. import { Ray } from "babylonjs/Culling/ray";
  13056. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13057. /**
  13058. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13059. * IMPORTANT!! The data is right-hand data.
  13060. * @export
  13061. * @interface DevicePose
  13062. */
  13063. export interface DevicePose {
  13064. /**
  13065. * The position of the device, values in array are [x,y,z].
  13066. */
  13067. readonly position: Nullable<Float32Array>;
  13068. /**
  13069. * The linearVelocity of the device, values in array are [x,y,z].
  13070. */
  13071. readonly linearVelocity: Nullable<Float32Array>;
  13072. /**
  13073. * The linearAcceleration of the device, values in array are [x,y,z].
  13074. */
  13075. readonly linearAcceleration: Nullable<Float32Array>;
  13076. /**
  13077. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13078. */
  13079. readonly orientation: Nullable<Float32Array>;
  13080. /**
  13081. * The angularVelocity of the device, values in array are [x,y,z].
  13082. */
  13083. readonly angularVelocity: Nullable<Float32Array>;
  13084. /**
  13085. * The angularAcceleration of the device, values in array are [x,y,z].
  13086. */
  13087. readonly angularAcceleration: Nullable<Float32Array>;
  13088. }
  13089. /**
  13090. * Interface representing a pose controlled object in Babylon.
  13091. * A pose controlled object has both regular pose values as well as pose values
  13092. * from an external device such as a VR head mounted display
  13093. */
  13094. export interface PoseControlled {
  13095. /**
  13096. * The position of the object in babylon space.
  13097. */
  13098. position: Vector3;
  13099. /**
  13100. * The rotation quaternion of the object in babylon space.
  13101. */
  13102. rotationQuaternion: Quaternion;
  13103. /**
  13104. * The position of the device in babylon space.
  13105. */
  13106. devicePosition?: Vector3;
  13107. /**
  13108. * The rotation quaternion of the device in babylon space.
  13109. */
  13110. deviceRotationQuaternion: Quaternion;
  13111. /**
  13112. * The raw pose coming from the device.
  13113. */
  13114. rawPose: Nullable<DevicePose>;
  13115. /**
  13116. * The scale of the device to be used when translating from device space to babylon space.
  13117. */
  13118. deviceScaleFactor: number;
  13119. /**
  13120. * Updates the poseControlled values based on the input device pose.
  13121. * @param poseData the pose data to update the object with
  13122. */
  13123. updateFromDevice(poseData: DevicePose): void;
  13124. }
  13125. /**
  13126. * Set of options to customize the webVRCamera
  13127. */
  13128. export interface WebVROptions {
  13129. /**
  13130. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13131. */
  13132. trackPosition?: boolean;
  13133. /**
  13134. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13135. */
  13136. positionScale?: number;
  13137. /**
  13138. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13139. */
  13140. displayName?: string;
  13141. /**
  13142. * Should the native controller meshes be initialized. (default: true)
  13143. */
  13144. controllerMeshes?: boolean;
  13145. /**
  13146. * Creating a default HemiLight only on controllers. (default: true)
  13147. */
  13148. defaultLightingOnControllers?: boolean;
  13149. /**
  13150. * If you don't want to use the default VR button of the helper. (default: false)
  13151. */
  13152. useCustomVRButton?: boolean;
  13153. /**
  13154. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13155. */
  13156. customVRButton?: HTMLButtonElement;
  13157. /**
  13158. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13159. */
  13160. rayLength?: number;
  13161. /**
  13162. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13163. */
  13164. defaultHeight?: number;
  13165. }
  13166. /**
  13167. * This represents a WebVR camera.
  13168. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13169. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13170. */
  13171. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13172. private webVROptions;
  13173. /**
  13174. * @hidden
  13175. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13176. */
  13177. _vrDevice: any;
  13178. /**
  13179. * The rawPose of the vrDevice.
  13180. */
  13181. rawPose: Nullable<DevicePose>;
  13182. private _onVREnabled;
  13183. private _specsVersion;
  13184. private _attached;
  13185. private _frameData;
  13186. protected _descendants: Array<Node>;
  13187. private _deviceRoomPosition;
  13188. /** @hidden */
  13189. _deviceRoomRotationQuaternion: Quaternion;
  13190. private _standingMatrix;
  13191. /**
  13192. * Represents device position in babylon space.
  13193. */
  13194. devicePosition: Vector3;
  13195. /**
  13196. * Represents device rotation in babylon space.
  13197. */
  13198. deviceRotationQuaternion: Quaternion;
  13199. /**
  13200. * The scale of the device to be used when translating from device space to babylon space.
  13201. */
  13202. deviceScaleFactor: number;
  13203. private _deviceToWorld;
  13204. private _worldToDevice;
  13205. /**
  13206. * References to the webVR controllers for the vrDevice.
  13207. */
  13208. controllers: Array<WebVRController>;
  13209. /**
  13210. * Emits an event when a controller is attached.
  13211. */
  13212. onControllersAttachedObservable: Observable<WebVRController[]>;
  13213. /**
  13214. * Emits an event when a controller's mesh has been loaded;
  13215. */
  13216. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13217. /**
  13218. * Emits an event when the HMD's pose has been updated.
  13219. */
  13220. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13221. private _poseSet;
  13222. /**
  13223. * If the rig cameras be used as parent instead of this camera.
  13224. */
  13225. rigParenting: boolean;
  13226. private _lightOnControllers;
  13227. private _defaultHeight?;
  13228. /**
  13229. * Instantiates a WebVRFreeCamera.
  13230. * @param name The name of the WebVRFreeCamera
  13231. * @param position The starting anchor position for the camera
  13232. * @param scene The scene the camera belongs to
  13233. * @param webVROptions a set of customizable options for the webVRCamera
  13234. */
  13235. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13236. /**
  13237. * Gets the device distance from the ground in meters.
  13238. * @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.
  13239. */
  13240. deviceDistanceToRoomGround(): number;
  13241. /**
  13242. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13243. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13244. */
  13245. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13246. /**
  13247. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13248. * @returns A promise with a boolean set to if the standing matrix is supported.
  13249. */
  13250. useStandingMatrixAsync(): Promise<boolean>;
  13251. /**
  13252. * Disposes the camera
  13253. */
  13254. dispose(): void;
  13255. /**
  13256. * Gets a vrController by name.
  13257. * @param name The name of the controller to retreive
  13258. * @returns the controller matching the name specified or null if not found
  13259. */
  13260. getControllerByName(name: string): Nullable<WebVRController>;
  13261. private _leftController;
  13262. /**
  13263. * The controller corrisponding to the users left hand.
  13264. */
  13265. readonly leftController: Nullable<WebVRController>;
  13266. private _rightController;
  13267. /**
  13268. * The controller corrisponding to the users right hand.
  13269. */
  13270. readonly rightController: Nullable<WebVRController>;
  13271. /**
  13272. * Casts a ray forward from the vrCamera's gaze.
  13273. * @param length Length of the ray (default: 100)
  13274. * @returns the ray corrisponding to the gaze
  13275. */
  13276. getForwardRay(length?: number): Ray;
  13277. /**
  13278. * @hidden
  13279. * Updates the camera based on device's frame data
  13280. */
  13281. _checkInputs(): void;
  13282. /**
  13283. * Updates the poseControlled values based on the input device pose.
  13284. * @param poseData Pose coming from the device
  13285. */
  13286. updateFromDevice(poseData: DevicePose): void;
  13287. private _htmlElementAttached;
  13288. private _detachIfAttached;
  13289. /**
  13290. * WebVR's attach control will start broadcasting frames to the device.
  13291. * Note that in certain browsers (chrome for example) this function must be called
  13292. * within a user-interaction callback. Example:
  13293. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13294. *
  13295. * @param element html element to attach the vrDevice to
  13296. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13297. */
  13298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13299. /**
  13300. * Detaches the camera from the html element and disables VR
  13301. *
  13302. * @param element html element to detach from
  13303. */
  13304. detachControl(element: HTMLElement): void;
  13305. /**
  13306. * @returns the name of this class
  13307. */
  13308. getClassName(): string;
  13309. /**
  13310. * Calls resetPose on the vrDisplay
  13311. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13312. */
  13313. resetToCurrentRotation(): void;
  13314. /**
  13315. * @hidden
  13316. * Updates the rig cameras (left and right eye)
  13317. */
  13318. _updateRigCameras(): void;
  13319. private _workingVector;
  13320. private _oneVector;
  13321. private _workingMatrix;
  13322. private updateCacheCalled;
  13323. private _correctPositionIfNotTrackPosition;
  13324. /**
  13325. * @hidden
  13326. * Updates the cached values of the camera
  13327. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13328. */
  13329. _updateCache(ignoreParentClass?: boolean): void;
  13330. /**
  13331. * @hidden
  13332. * Get current device position in babylon world
  13333. */
  13334. _computeDevicePosition(): void;
  13335. /**
  13336. * Updates the current device position and rotation in the babylon world
  13337. */
  13338. update(): void;
  13339. /**
  13340. * @hidden
  13341. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13342. * @returns an identity matrix
  13343. */
  13344. _getViewMatrix(): Matrix;
  13345. private _tmpMatrix;
  13346. /**
  13347. * This function is called by the two RIG cameras.
  13348. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13349. * @hidden
  13350. */
  13351. _getWebVRViewMatrix(): Matrix;
  13352. /** @hidden */
  13353. _getWebVRProjectionMatrix(): Matrix;
  13354. private _onGamepadConnectedObserver;
  13355. private _onGamepadDisconnectedObserver;
  13356. private _updateCacheWhenTrackingDisabledObserver;
  13357. /**
  13358. * Initializes the controllers and their meshes
  13359. */
  13360. initControllers(): void;
  13361. }
  13362. }
  13363. declare module "babylonjs/PostProcesses/postProcess" {
  13364. import { Nullable } from "babylonjs/types";
  13365. import { SmartArray } from "babylonjs/Misc/smartArray";
  13366. import { Observable } from "babylonjs/Misc/observable";
  13367. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13368. import { Camera } from "babylonjs/Cameras/camera";
  13369. import { Effect } from "babylonjs/Materials/effect";
  13370. import "babylonjs/Shaders/postprocess.vertex";
  13371. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13372. import { Engine } from "babylonjs/Engines/engine";
  13373. /**
  13374. * Size options for a post process
  13375. */
  13376. export type PostProcessOptions = {
  13377. width: number;
  13378. height: number;
  13379. };
  13380. /**
  13381. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13382. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13383. */
  13384. export class PostProcess {
  13385. /** Name of the PostProcess. */
  13386. name: string;
  13387. /**
  13388. * Gets or sets the unique id of the post process
  13389. */
  13390. uniqueId: number;
  13391. /**
  13392. * Width of the texture to apply the post process on
  13393. */
  13394. width: number;
  13395. /**
  13396. * Height of the texture to apply the post process on
  13397. */
  13398. height: number;
  13399. /**
  13400. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13401. * @hidden
  13402. */
  13403. _outputTexture: Nullable<InternalTexture>;
  13404. /**
  13405. * Sampling mode used by the shader
  13406. * See https://doc.babylonjs.com/classes/3.1/texture
  13407. */
  13408. renderTargetSamplingMode: number;
  13409. /**
  13410. * Clear color to use when screen clearing
  13411. */
  13412. clearColor: Color4;
  13413. /**
  13414. * If the buffer needs to be cleared before applying the post process. (default: true)
  13415. * Should be set to false if shader will overwrite all previous pixels.
  13416. */
  13417. autoClear: boolean;
  13418. /**
  13419. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13420. */
  13421. alphaMode: number;
  13422. /**
  13423. * Sets the setAlphaBlendConstants of the babylon engine
  13424. */
  13425. alphaConstants: Color4;
  13426. /**
  13427. * Animations to be used for the post processing
  13428. */
  13429. animations: import("babylonjs/Animations/animation").Animation[];
  13430. /**
  13431. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13432. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13433. */
  13434. enablePixelPerfectMode: boolean;
  13435. /**
  13436. * Force the postprocess to be applied without taking in account viewport
  13437. */
  13438. forceFullscreenViewport: boolean;
  13439. /**
  13440. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13441. *
  13442. * | Value | Type | Description |
  13443. * | ----- | ----------------------------------- | ----------- |
  13444. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13445. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13446. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13447. *
  13448. */
  13449. scaleMode: number;
  13450. /**
  13451. * Force textures to be a power of two (default: false)
  13452. */
  13453. alwaysForcePOT: boolean;
  13454. private _samples;
  13455. /**
  13456. * Number of sample textures (default: 1)
  13457. */
  13458. samples: number;
  13459. /**
  13460. * Modify the scale of the post process to be the same as the viewport (default: false)
  13461. */
  13462. adaptScaleToCurrentViewport: boolean;
  13463. private _camera;
  13464. private _scene;
  13465. private _engine;
  13466. private _options;
  13467. private _reusable;
  13468. private _textureType;
  13469. /**
  13470. * Smart array of input and output textures for the post process.
  13471. * @hidden
  13472. */
  13473. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13474. /**
  13475. * The index in _textures that corresponds to the output texture.
  13476. * @hidden
  13477. */
  13478. _currentRenderTextureInd: number;
  13479. private _effect;
  13480. private _samplers;
  13481. private _fragmentUrl;
  13482. private _vertexUrl;
  13483. private _parameters;
  13484. private _scaleRatio;
  13485. protected _indexParameters: any;
  13486. private _shareOutputWithPostProcess;
  13487. private _texelSize;
  13488. private _forcedOutputTexture;
  13489. /**
  13490. * Returns the fragment url or shader name used in the post process.
  13491. * @returns the fragment url or name in the shader store.
  13492. */
  13493. getEffectName(): string;
  13494. /**
  13495. * An event triggered when the postprocess is activated.
  13496. */
  13497. onActivateObservable: Observable<Camera>;
  13498. private _onActivateObserver;
  13499. /**
  13500. * A function that is added to the onActivateObservable
  13501. */
  13502. onActivate: Nullable<(camera: Camera) => void>;
  13503. /**
  13504. * An event triggered when the postprocess changes its size.
  13505. */
  13506. onSizeChangedObservable: Observable<PostProcess>;
  13507. private _onSizeChangedObserver;
  13508. /**
  13509. * A function that is added to the onSizeChangedObservable
  13510. */
  13511. onSizeChanged: (postProcess: PostProcess) => void;
  13512. /**
  13513. * An event triggered when the postprocess applies its effect.
  13514. */
  13515. onApplyObservable: Observable<Effect>;
  13516. private _onApplyObserver;
  13517. /**
  13518. * A function that is added to the onApplyObservable
  13519. */
  13520. onApply: (effect: Effect) => void;
  13521. /**
  13522. * An event triggered before rendering the postprocess
  13523. */
  13524. onBeforeRenderObservable: Observable<Effect>;
  13525. private _onBeforeRenderObserver;
  13526. /**
  13527. * A function that is added to the onBeforeRenderObservable
  13528. */
  13529. onBeforeRender: (effect: Effect) => void;
  13530. /**
  13531. * An event triggered after rendering the postprocess
  13532. */
  13533. onAfterRenderObservable: Observable<Effect>;
  13534. private _onAfterRenderObserver;
  13535. /**
  13536. * A function that is added to the onAfterRenderObservable
  13537. */
  13538. onAfterRender: (efect: Effect) => void;
  13539. /**
  13540. * 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
  13541. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13542. */
  13543. inputTexture: InternalTexture;
  13544. /**
  13545. * Gets the camera which post process is applied to.
  13546. * @returns The camera the post process is applied to.
  13547. */
  13548. getCamera(): Camera;
  13549. /**
  13550. * Gets the texel size of the postprocess.
  13551. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13552. */
  13553. readonly texelSize: Vector2;
  13554. /**
  13555. * Creates a new instance PostProcess
  13556. * @param name The name of the PostProcess.
  13557. * @param fragmentUrl The url of the fragment shader to be used.
  13558. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13559. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13560. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13561. * @param camera The camera to apply the render pass to.
  13562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13563. * @param engine The engine which the post process will be applied. (default: current engine)
  13564. * @param reusable If the post process can be reused on the same frame. (default: false)
  13565. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13566. * @param textureType Type of textures used when performing the post process. (default: 0)
  13567. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13568. * @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
  13569. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13570. */
  13571. constructor(
  13572. /** Name of the PostProcess. */
  13573. 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);
  13574. /**
  13575. * Gets a string idenfifying the name of the class
  13576. * @returns "PostProcess" string
  13577. */
  13578. getClassName(): string;
  13579. /**
  13580. * Gets the engine which this post process belongs to.
  13581. * @returns The engine the post process was enabled with.
  13582. */
  13583. getEngine(): Engine;
  13584. /**
  13585. * The effect that is created when initializing the post process.
  13586. * @returns The created effect corrisponding the the postprocess.
  13587. */
  13588. getEffect(): Effect;
  13589. /**
  13590. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13591. * @param postProcess The post process to share the output with.
  13592. * @returns This post process.
  13593. */
  13594. shareOutputWith(postProcess: PostProcess): PostProcess;
  13595. /**
  13596. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13597. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13598. */
  13599. useOwnOutput(): void;
  13600. /**
  13601. * Updates the effect with the current post process compile time values and recompiles the shader.
  13602. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13603. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13604. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13605. * @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
  13606. * @param onCompiled Called when the shader has been compiled.
  13607. * @param onError Called if there is an error when compiling a shader.
  13608. */
  13609. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13610. /**
  13611. * The post process is reusable if it can be used multiple times within one frame.
  13612. * @returns If the post process is reusable
  13613. */
  13614. isReusable(): boolean;
  13615. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13616. markTextureDirty(): void;
  13617. /**
  13618. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13619. * 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.
  13620. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13621. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13622. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13623. * @returns The target texture that was bound to be written to.
  13624. */
  13625. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13626. /**
  13627. * If the post process is supported.
  13628. */
  13629. readonly isSupported: boolean;
  13630. /**
  13631. * The aspect ratio of the output texture.
  13632. */
  13633. readonly aspectRatio: number;
  13634. /**
  13635. * Get a value indicating if the post-process is ready to be used
  13636. * @returns true if the post-process is ready (shader is compiled)
  13637. */
  13638. isReady(): boolean;
  13639. /**
  13640. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13641. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13642. */
  13643. apply(): Nullable<Effect>;
  13644. private _disposeTextures;
  13645. /**
  13646. * Disposes the post process.
  13647. * @param camera The camera to dispose the post process on.
  13648. */
  13649. dispose(camera?: Camera): void;
  13650. }
  13651. }
  13652. declare module "babylonjs/PostProcesses/postProcessManager" {
  13653. import { Nullable } from "babylonjs/types";
  13654. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13655. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13656. import { Scene } from "babylonjs/scene";
  13657. /**
  13658. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13659. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13660. */
  13661. export class PostProcessManager {
  13662. private _scene;
  13663. private _indexBuffer;
  13664. private _vertexBuffers;
  13665. /**
  13666. * Creates a new instance PostProcess
  13667. * @param scene The scene that the post process is associated with.
  13668. */
  13669. constructor(scene: Scene);
  13670. private _prepareBuffers;
  13671. private _buildIndexBuffer;
  13672. /**
  13673. * Rebuilds the vertex buffers of the manager.
  13674. * @hidden
  13675. */
  13676. _rebuild(): void;
  13677. /**
  13678. * Prepares a frame to be run through a post process.
  13679. * @param sourceTexture The input texture to the post procesess. (default: null)
  13680. * @param postProcesses An array of post processes to be run. (default: null)
  13681. * @returns True if the post processes were able to be run.
  13682. * @hidden
  13683. */
  13684. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13685. /**
  13686. * Manually render a set of post processes to a texture.
  13687. * @param postProcesses An array of post processes to be run.
  13688. * @param targetTexture The target texture to render to.
  13689. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13690. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13691. * @param lodLevel defines which lod of the texture to render to
  13692. */
  13693. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13694. /**
  13695. * Finalize the result of the output of the postprocesses.
  13696. * @param doNotPresent If true the result will not be displayed to the screen.
  13697. * @param targetTexture The target texture to render to.
  13698. * @param faceIndex The index of the face to bind the target texture to.
  13699. * @param postProcesses The array of post processes to render.
  13700. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13701. * @hidden
  13702. */
  13703. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13704. /**
  13705. * Disposes of the post process manager.
  13706. */
  13707. dispose(): void;
  13708. }
  13709. }
  13710. declare module "babylonjs/Layers/layerSceneComponent" {
  13711. import { Scene } from "babylonjs/scene";
  13712. import { ISceneComponent } from "babylonjs/sceneComponent";
  13713. import { Layer } from "babylonjs/Layers/layer";
  13714. module "babylonjs/abstractScene" {
  13715. interface AbstractScene {
  13716. /**
  13717. * The list of layers (background and foreground) of the scene
  13718. */
  13719. layers: Array<Layer>;
  13720. }
  13721. }
  13722. /**
  13723. * Defines the layer scene component responsible to manage any layers
  13724. * in a given scene.
  13725. */
  13726. export class LayerSceneComponent implements ISceneComponent {
  13727. /**
  13728. * The component name helpfull to identify the component in the list of scene components.
  13729. */
  13730. readonly name: string;
  13731. /**
  13732. * The scene the component belongs to.
  13733. */
  13734. scene: Scene;
  13735. private _engine;
  13736. /**
  13737. * Creates a new instance of the component for the given scene
  13738. * @param scene Defines the scene to register the component in
  13739. */
  13740. constructor(scene: Scene);
  13741. /**
  13742. * Registers the component in a given scene
  13743. */
  13744. register(): void;
  13745. /**
  13746. * Rebuilds the elements related to this component in case of
  13747. * context lost for instance.
  13748. */
  13749. rebuild(): void;
  13750. /**
  13751. * Disposes the component and the associated ressources.
  13752. */
  13753. dispose(): void;
  13754. private _draw;
  13755. private _drawCameraPredicate;
  13756. private _drawCameraBackground;
  13757. private _drawCameraForeground;
  13758. private _drawRenderTargetPredicate;
  13759. private _drawRenderTargetBackground;
  13760. private _drawRenderTargetForeground;
  13761. }
  13762. }
  13763. declare module "babylonjs/Shaders/layer.fragment" {
  13764. /** @hidden */
  13765. export var layerPixelShader: {
  13766. name: string;
  13767. shader: string;
  13768. };
  13769. }
  13770. declare module "babylonjs/Shaders/layer.vertex" {
  13771. /** @hidden */
  13772. export var layerVertexShader: {
  13773. name: string;
  13774. shader: string;
  13775. };
  13776. }
  13777. declare module "babylonjs/Layers/layer" {
  13778. import { Observable } from "babylonjs/Misc/observable";
  13779. import { Nullable } from "babylonjs/types";
  13780. import { Scene } from "babylonjs/scene";
  13781. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13782. import { Texture } from "babylonjs/Materials/Textures/texture";
  13783. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13784. import "babylonjs/Shaders/layer.fragment";
  13785. import "babylonjs/Shaders/layer.vertex";
  13786. /**
  13787. * This represents a full screen 2d layer.
  13788. * This can be useful to display a picture in the background of your scene for instance.
  13789. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13790. */
  13791. export class Layer {
  13792. /**
  13793. * Define the name of the layer.
  13794. */
  13795. name: string;
  13796. /**
  13797. * Define the texture the layer should display.
  13798. */
  13799. texture: Nullable<Texture>;
  13800. /**
  13801. * Is the layer in background or foreground.
  13802. */
  13803. isBackground: boolean;
  13804. /**
  13805. * Define the color of the layer (instead of texture).
  13806. */
  13807. color: Color4;
  13808. /**
  13809. * Define the scale of the layer in order to zoom in out of the texture.
  13810. */
  13811. scale: Vector2;
  13812. /**
  13813. * Define an offset for the layer in order to shift the texture.
  13814. */
  13815. offset: Vector2;
  13816. /**
  13817. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13818. */
  13819. alphaBlendingMode: number;
  13820. /**
  13821. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13822. * Alpha test will not mix with the background color in case of transparency.
  13823. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13824. */
  13825. alphaTest: boolean;
  13826. /**
  13827. * Define a mask to restrict the layer to only some of the scene cameras.
  13828. */
  13829. layerMask: number;
  13830. /**
  13831. * Define the list of render target the layer is visible into.
  13832. */
  13833. renderTargetTextures: RenderTargetTexture[];
  13834. /**
  13835. * Define if the layer is only used in renderTarget or if it also
  13836. * renders in the main frame buffer of the canvas.
  13837. */
  13838. renderOnlyInRenderTargetTextures: boolean;
  13839. private _scene;
  13840. private _vertexBuffers;
  13841. private _indexBuffer;
  13842. private _effect;
  13843. private _alphaTestEffect;
  13844. /**
  13845. * An event triggered when the layer is disposed.
  13846. */
  13847. onDisposeObservable: Observable<Layer>;
  13848. private _onDisposeObserver;
  13849. /**
  13850. * Back compatibility with callback before the onDisposeObservable existed.
  13851. * The set callback will be triggered when the layer has been disposed.
  13852. */
  13853. onDispose: () => void;
  13854. /**
  13855. * An event triggered before rendering the scene
  13856. */
  13857. onBeforeRenderObservable: Observable<Layer>;
  13858. private _onBeforeRenderObserver;
  13859. /**
  13860. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13861. * The set callback will be triggered just before rendering the layer.
  13862. */
  13863. onBeforeRender: () => void;
  13864. /**
  13865. * An event triggered after rendering the scene
  13866. */
  13867. onAfterRenderObservable: Observable<Layer>;
  13868. private _onAfterRenderObserver;
  13869. /**
  13870. * Back compatibility with callback before the onAfterRenderObservable existed.
  13871. * The set callback will be triggered just after rendering the layer.
  13872. */
  13873. onAfterRender: () => void;
  13874. /**
  13875. * Instantiates a new layer.
  13876. * This represents a full screen 2d layer.
  13877. * This can be useful to display a picture in the background of your scene for instance.
  13878. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13879. * @param name Define the name of the layer in the scene
  13880. * @param imgUrl Define the url of the texture to display in the layer
  13881. * @param scene Define the scene the layer belongs to
  13882. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13883. * @param color Defines a color for the layer
  13884. */
  13885. constructor(
  13886. /**
  13887. * Define the name of the layer.
  13888. */
  13889. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13890. private _createIndexBuffer;
  13891. /** @hidden */
  13892. _rebuild(): void;
  13893. /**
  13894. * Renders the layer in the scene.
  13895. */
  13896. render(): void;
  13897. /**
  13898. * Disposes and releases the associated ressources.
  13899. */
  13900. dispose(): void;
  13901. }
  13902. }
  13903. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13904. import { Scene } from "babylonjs/scene";
  13905. import { ISceneComponent } from "babylonjs/sceneComponent";
  13906. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13907. module "babylonjs/abstractScene" {
  13908. interface AbstractScene {
  13909. /**
  13910. * The list of procedural textures added to the scene
  13911. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13912. */
  13913. proceduralTextures: Array<ProceduralTexture>;
  13914. }
  13915. }
  13916. /**
  13917. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13918. * in a given scene.
  13919. */
  13920. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13921. /**
  13922. * The component name helpfull to identify the component in the list of scene components.
  13923. */
  13924. readonly name: string;
  13925. /**
  13926. * The scene the component belongs to.
  13927. */
  13928. scene: Scene;
  13929. /**
  13930. * Creates a new instance of the component for the given scene
  13931. * @param scene Defines the scene to register the component in
  13932. */
  13933. constructor(scene: Scene);
  13934. /**
  13935. * Registers the component in a given scene
  13936. */
  13937. register(): void;
  13938. /**
  13939. * Rebuilds the elements related to this component in case of
  13940. * context lost for instance.
  13941. */
  13942. rebuild(): void;
  13943. /**
  13944. * Disposes the component and the associated ressources.
  13945. */
  13946. dispose(): void;
  13947. private _beforeClear;
  13948. }
  13949. }
  13950. declare module "babylonjs/Shaders/procedural.vertex" {
  13951. /** @hidden */
  13952. export var proceduralVertexShader: {
  13953. name: string;
  13954. shader: string;
  13955. };
  13956. }
  13957. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13958. import { Observable } from "babylonjs/Misc/observable";
  13959. import { Nullable } from "babylonjs/types";
  13960. import { Scene } from "babylonjs/scene";
  13961. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13962. import { Effect } from "babylonjs/Materials/effect";
  13963. import { Texture } from "babylonjs/Materials/Textures/texture";
  13964. import "babylonjs/Shaders/procedural.vertex";
  13965. /**
  13966. * 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.
  13967. * This is the base class of any Procedural texture and contains most of the shareable code.
  13968. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13969. */
  13970. export class ProceduralTexture extends Texture {
  13971. isCube: boolean;
  13972. /**
  13973. * Define if the texture is enabled or not (disabled texture will not render)
  13974. */
  13975. isEnabled: boolean;
  13976. /**
  13977. * Define if the texture must be cleared before rendering (default is true)
  13978. */
  13979. autoClear: boolean;
  13980. /**
  13981. * Callback called when the texture is generated
  13982. */
  13983. onGenerated: () => void;
  13984. /**
  13985. * Event raised when the texture is generated
  13986. */
  13987. onGeneratedObservable: Observable<ProceduralTexture>;
  13988. /** @hidden */
  13989. _generateMipMaps: boolean;
  13990. /** @hidden **/
  13991. _effect: Effect;
  13992. /** @hidden */
  13993. _textures: {
  13994. [key: string]: Texture;
  13995. };
  13996. private _size;
  13997. private _currentRefreshId;
  13998. private _refreshRate;
  13999. private _vertexBuffers;
  14000. private _indexBuffer;
  14001. private _uniforms;
  14002. private _samplers;
  14003. private _fragment;
  14004. private _floats;
  14005. private _ints;
  14006. private _floatsArrays;
  14007. private _colors3;
  14008. private _colors4;
  14009. private _vectors2;
  14010. private _vectors3;
  14011. private _matrices;
  14012. private _fallbackTexture;
  14013. private _fallbackTextureUsed;
  14014. private _engine;
  14015. private _cachedDefines;
  14016. private _contentUpdateId;
  14017. private _contentData;
  14018. /**
  14019. * Instantiates a new procedural texture.
  14020. * 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.
  14021. * This is the base class of any Procedural texture and contains most of the shareable code.
  14022. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14023. * @param name Define the name of the texture
  14024. * @param size Define the size of the texture to create
  14025. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14026. * @param scene Define the scene the texture belongs to
  14027. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14028. * @param generateMipMaps Define if the texture should creates mip maps or not
  14029. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14030. */
  14031. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14032. /**
  14033. * The effect that is created when initializing the post process.
  14034. * @returns The created effect corrisponding the the postprocess.
  14035. */
  14036. getEffect(): Effect;
  14037. /**
  14038. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14039. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14040. */
  14041. getContent(): Nullable<ArrayBufferView>;
  14042. private _createIndexBuffer;
  14043. /** @hidden */
  14044. _rebuild(): void;
  14045. /**
  14046. * Resets the texture in order to recreate its associated resources.
  14047. * This can be called in case of context loss
  14048. */
  14049. reset(): void;
  14050. protected _getDefines(): string;
  14051. /**
  14052. * Is the texture ready to be used ? (rendered at least once)
  14053. * @returns true if ready, otherwise, false.
  14054. */
  14055. isReady(): boolean;
  14056. /**
  14057. * Resets the refresh counter of the texture and start bak from scratch.
  14058. * Could be useful to regenerate the texture if it is setup to render only once.
  14059. */
  14060. resetRefreshCounter(): void;
  14061. /**
  14062. * Set the fragment shader to use in order to render the texture.
  14063. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14064. */
  14065. setFragment(fragment: any): void;
  14066. /**
  14067. * Define the refresh rate of the texture or the rendering frequency.
  14068. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14069. */
  14070. refreshRate: number;
  14071. /** @hidden */
  14072. _shouldRender(): boolean;
  14073. /**
  14074. * Get the size the texture is rendering at.
  14075. * @returns the size (texture is always squared)
  14076. */
  14077. getRenderSize(): number;
  14078. /**
  14079. * Resize the texture to new value.
  14080. * @param size Define the new size the texture should have
  14081. * @param generateMipMaps Define whether the new texture should create mip maps
  14082. */
  14083. resize(size: number, generateMipMaps: boolean): void;
  14084. private _checkUniform;
  14085. /**
  14086. * Set a texture in the shader program used to render.
  14087. * @param name Define the name of the uniform samplers as defined in the shader
  14088. * @param texture Define the texture to bind to this sampler
  14089. * @return the texture itself allowing "fluent" like uniform updates
  14090. */
  14091. setTexture(name: string, texture: Texture): ProceduralTexture;
  14092. /**
  14093. * Set a float in the shader.
  14094. * @param name Define the name of the uniform as defined in the shader
  14095. * @param value Define the value to give to the uniform
  14096. * @return the texture itself allowing "fluent" like uniform updates
  14097. */
  14098. setFloat(name: string, value: number): ProceduralTexture;
  14099. /**
  14100. * Set a int in the shader.
  14101. * @param name Define the name of the uniform as defined in the shader
  14102. * @param value Define the value to give to the uniform
  14103. * @return the texture itself allowing "fluent" like uniform updates
  14104. */
  14105. setInt(name: string, value: number): ProceduralTexture;
  14106. /**
  14107. * Set an array of floats in the shader.
  14108. * @param name Define the name of the uniform as defined in the shader
  14109. * @param value Define the value to give to the uniform
  14110. * @return the texture itself allowing "fluent" like uniform updates
  14111. */
  14112. setFloats(name: string, value: number[]): ProceduralTexture;
  14113. /**
  14114. * Set a vec3 in the shader from a Color3.
  14115. * @param name Define the name of the uniform as defined in the shader
  14116. * @param value Define the value to give to the uniform
  14117. * @return the texture itself allowing "fluent" like uniform updates
  14118. */
  14119. setColor3(name: string, value: Color3): ProceduralTexture;
  14120. /**
  14121. * Set a vec4 in the shader from a Color4.
  14122. * @param name Define the name of the uniform as defined in the shader
  14123. * @param value Define the value to give to the uniform
  14124. * @return the texture itself allowing "fluent" like uniform updates
  14125. */
  14126. setColor4(name: string, value: Color4): ProceduralTexture;
  14127. /**
  14128. * Set a vec2 in the shader from a Vector2.
  14129. * @param name Define the name of the uniform as defined in the shader
  14130. * @param value Define the value to give to the uniform
  14131. * @return the texture itself allowing "fluent" like uniform updates
  14132. */
  14133. setVector2(name: string, value: Vector2): ProceduralTexture;
  14134. /**
  14135. * Set a vec3 in the shader from a Vector3.
  14136. * @param name Define the name of the uniform as defined in the shader
  14137. * @param value Define the value to give to the uniform
  14138. * @return the texture itself allowing "fluent" like uniform updates
  14139. */
  14140. setVector3(name: string, value: Vector3): ProceduralTexture;
  14141. /**
  14142. * Set a mat4 in the shader from a MAtrix.
  14143. * @param name Define the name of the uniform as defined in the shader
  14144. * @param value Define the value to give to the uniform
  14145. * @return the texture itself allowing "fluent" like uniform updates
  14146. */
  14147. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14148. /**
  14149. * Render the texture to its associated render target.
  14150. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14151. */
  14152. render(useCameraPostProcess?: boolean): void;
  14153. /**
  14154. * Clone the texture.
  14155. * @returns the cloned texture
  14156. */
  14157. clone(): ProceduralTexture;
  14158. /**
  14159. * Dispose the texture and release its asoociated resources.
  14160. */
  14161. dispose(): void;
  14162. }
  14163. }
  14164. declare module "babylonjs/Particles/baseParticleSystem" {
  14165. import { Nullable } from "babylonjs/types";
  14166. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14168. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14169. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14170. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14171. import { Scene } from "babylonjs/scene";
  14172. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14173. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14174. import { Texture } from "babylonjs/Materials/Textures/texture";
  14175. import { Animation } from "babylonjs/Animations/animation";
  14176. /**
  14177. * This represents the base class for particle system in Babylon.
  14178. * 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.
  14179. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14180. * @example https://doc.babylonjs.com/babylon101/particles
  14181. */
  14182. export class BaseParticleSystem {
  14183. /**
  14184. * Source color is added to the destination color without alpha affecting the result
  14185. */
  14186. static BLENDMODE_ONEONE: number;
  14187. /**
  14188. * Blend current color and particle color using particle’s alpha
  14189. */
  14190. static BLENDMODE_STANDARD: number;
  14191. /**
  14192. * Add current color and particle color multiplied by particle’s alpha
  14193. */
  14194. static BLENDMODE_ADD: number;
  14195. /**
  14196. * Multiply current color with particle color
  14197. */
  14198. static BLENDMODE_MULTIPLY: number;
  14199. /**
  14200. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14201. */
  14202. static BLENDMODE_MULTIPLYADD: number;
  14203. /**
  14204. * List of animations used by the particle system.
  14205. */
  14206. animations: Animation[];
  14207. /**
  14208. * The id of the Particle system.
  14209. */
  14210. id: string;
  14211. /**
  14212. * The friendly name of the Particle system.
  14213. */
  14214. name: string;
  14215. /**
  14216. * The rendering group used by the Particle system to chose when to render.
  14217. */
  14218. renderingGroupId: number;
  14219. /**
  14220. * The emitter represents the Mesh or position we are attaching the particle system to.
  14221. */
  14222. emitter: Nullable<AbstractMesh | Vector3>;
  14223. /**
  14224. * The maximum number of particles to emit per frame
  14225. */
  14226. emitRate: number;
  14227. /**
  14228. * If you want to launch only a few particles at once, that can be done, as well.
  14229. */
  14230. manualEmitCount: number;
  14231. /**
  14232. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14233. */
  14234. updateSpeed: number;
  14235. /**
  14236. * The amount of time the particle system is running (depends of the overall update speed).
  14237. */
  14238. targetStopDuration: number;
  14239. /**
  14240. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14241. */
  14242. disposeOnStop: boolean;
  14243. /**
  14244. * Minimum power of emitting particles.
  14245. */
  14246. minEmitPower: number;
  14247. /**
  14248. * Maximum power of emitting particles.
  14249. */
  14250. maxEmitPower: number;
  14251. /**
  14252. * Minimum life time of emitting particles.
  14253. */
  14254. minLifeTime: number;
  14255. /**
  14256. * Maximum life time of emitting particles.
  14257. */
  14258. maxLifeTime: number;
  14259. /**
  14260. * Minimum Size of emitting particles.
  14261. */
  14262. minSize: number;
  14263. /**
  14264. * Maximum Size of emitting particles.
  14265. */
  14266. maxSize: number;
  14267. /**
  14268. * Minimum scale of emitting particles on X axis.
  14269. */
  14270. minScaleX: number;
  14271. /**
  14272. * Maximum scale of emitting particles on X axis.
  14273. */
  14274. maxScaleX: number;
  14275. /**
  14276. * Minimum scale of emitting particles on Y axis.
  14277. */
  14278. minScaleY: number;
  14279. /**
  14280. * Maximum scale of emitting particles on Y axis.
  14281. */
  14282. maxScaleY: number;
  14283. /**
  14284. * Gets or sets the minimal initial rotation in radians.
  14285. */
  14286. minInitialRotation: number;
  14287. /**
  14288. * Gets or sets the maximal initial rotation in radians.
  14289. */
  14290. maxInitialRotation: number;
  14291. /**
  14292. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14293. */
  14294. minAngularSpeed: number;
  14295. /**
  14296. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14297. */
  14298. maxAngularSpeed: number;
  14299. /**
  14300. * The texture used to render each particle. (this can be a spritesheet)
  14301. */
  14302. particleTexture: Nullable<Texture>;
  14303. /**
  14304. * The layer mask we are rendering the particles through.
  14305. */
  14306. layerMask: number;
  14307. /**
  14308. * This can help using your own shader to render the particle system.
  14309. * The according effect will be created
  14310. */
  14311. customShader: any;
  14312. /**
  14313. * By default particle system starts as soon as they are created. This prevents the
  14314. * automatic start to happen and let you decide when to start emitting particles.
  14315. */
  14316. preventAutoStart: boolean;
  14317. private _noiseTexture;
  14318. /**
  14319. * Gets or sets a texture used to add random noise to particle positions
  14320. */
  14321. noiseTexture: Nullable<ProceduralTexture>;
  14322. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14323. noiseStrength: Vector3;
  14324. /**
  14325. * Callback triggered when the particle animation is ending.
  14326. */
  14327. onAnimationEnd: Nullable<() => void>;
  14328. /**
  14329. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14330. */
  14331. blendMode: number;
  14332. /**
  14333. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14334. * to override the particles.
  14335. */
  14336. forceDepthWrite: boolean;
  14337. /** 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 */
  14338. preWarmCycles: number;
  14339. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14340. preWarmStepOffset: number;
  14341. /**
  14342. * 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)
  14343. */
  14344. spriteCellChangeSpeed: number;
  14345. /**
  14346. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14347. */
  14348. startSpriteCellID: number;
  14349. /**
  14350. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14351. */
  14352. endSpriteCellID: number;
  14353. /**
  14354. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14355. */
  14356. spriteCellWidth: number;
  14357. /**
  14358. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14359. */
  14360. spriteCellHeight: number;
  14361. /**
  14362. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14363. */
  14364. spriteRandomStartCell: boolean;
  14365. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14366. translationPivot: Vector2;
  14367. /** @hidden */
  14368. protected _isAnimationSheetEnabled: boolean;
  14369. /**
  14370. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14371. */
  14372. beginAnimationOnStart: boolean;
  14373. /**
  14374. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14375. */
  14376. beginAnimationFrom: number;
  14377. /**
  14378. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14379. */
  14380. beginAnimationTo: number;
  14381. /**
  14382. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14383. */
  14384. beginAnimationLoop: boolean;
  14385. /**
  14386. * Gets or sets a world offset applied to all particles
  14387. */
  14388. worldOffset: Vector3;
  14389. /**
  14390. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14391. */
  14392. isAnimationSheetEnabled: boolean;
  14393. /**
  14394. * Get hosting scene
  14395. * @returns the scene
  14396. */
  14397. getScene(): Scene;
  14398. /**
  14399. * You can use gravity if you want to give an orientation to your particles.
  14400. */
  14401. gravity: Vector3;
  14402. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14403. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14404. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14405. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14406. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14407. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14408. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14409. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14410. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14411. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14412. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14413. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14414. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14415. /**
  14416. * Defines the delay in milliseconds before starting the system (0 by default)
  14417. */
  14418. startDelay: number;
  14419. /**
  14420. * Gets the current list of drag gradients.
  14421. * You must use addDragGradient and removeDragGradient to udpate this list
  14422. * @returns the list of drag gradients
  14423. */
  14424. getDragGradients(): Nullable<Array<FactorGradient>>;
  14425. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14426. limitVelocityDamping: number;
  14427. /**
  14428. * Gets the current list of limit velocity gradients.
  14429. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14430. * @returns the list of limit velocity gradients
  14431. */
  14432. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14433. /**
  14434. * Gets the current list of color gradients.
  14435. * You must use addColorGradient and removeColorGradient to udpate this list
  14436. * @returns the list of color gradients
  14437. */
  14438. getColorGradients(): Nullable<Array<ColorGradient>>;
  14439. /**
  14440. * Gets the current list of size gradients.
  14441. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14442. * @returns the list of size gradients
  14443. */
  14444. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14445. /**
  14446. * Gets the current list of color remap gradients.
  14447. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14448. * @returns the list of color remap gradients
  14449. */
  14450. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14451. /**
  14452. * Gets the current list of alpha remap gradients.
  14453. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14454. * @returns the list of alpha remap gradients
  14455. */
  14456. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14457. /**
  14458. * Gets the current list of life time gradients.
  14459. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14460. * @returns the list of life time gradients
  14461. */
  14462. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14463. /**
  14464. * Gets the current list of angular speed gradients.
  14465. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14466. * @returns the list of angular speed gradients
  14467. */
  14468. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14469. /**
  14470. * Gets the current list of velocity gradients.
  14471. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14472. * @returns the list of velocity gradients
  14473. */
  14474. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14475. /**
  14476. * Gets the current list of start size gradients.
  14477. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14478. * @returns the list of start size gradients
  14479. */
  14480. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14481. /**
  14482. * Gets the current list of emit rate gradients.
  14483. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14484. * @returns the list of emit rate gradients
  14485. */
  14486. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14487. /**
  14488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14490. */
  14491. direction1: Vector3;
  14492. /**
  14493. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14495. */
  14496. direction2: Vector3;
  14497. /**
  14498. * 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.
  14499. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14500. */
  14501. minEmitBox: Vector3;
  14502. /**
  14503. * 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.
  14504. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14505. */
  14506. maxEmitBox: Vector3;
  14507. /**
  14508. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14509. */
  14510. color1: Color4;
  14511. /**
  14512. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14513. */
  14514. color2: Color4;
  14515. /**
  14516. * Color the particle will have at the end of its lifetime
  14517. */
  14518. colorDead: Color4;
  14519. /**
  14520. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14521. */
  14522. textureMask: Color4;
  14523. /**
  14524. * The particle emitter type defines the emitter used by the particle system.
  14525. * It can be for example box, sphere, or cone...
  14526. */
  14527. particleEmitterType: IParticleEmitterType;
  14528. /** @hidden */
  14529. _isSubEmitter: boolean;
  14530. /**
  14531. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14532. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14533. */
  14534. billboardMode: number;
  14535. protected _isBillboardBased: boolean;
  14536. /**
  14537. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14538. */
  14539. isBillboardBased: boolean;
  14540. /**
  14541. * The scene the particle system belongs to.
  14542. */
  14543. protected _scene: Scene;
  14544. /**
  14545. * Local cache of defines for image processing.
  14546. */
  14547. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14548. /**
  14549. * Default configuration related to image processing available in the standard Material.
  14550. */
  14551. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14552. /**
  14553. * Gets the image processing configuration used either in this material.
  14554. */
  14555. /**
  14556. * Sets the Default image processing configuration used either in the this material.
  14557. *
  14558. * If sets to null, the scene one is in use.
  14559. */
  14560. imageProcessingConfiguration: ImageProcessingConfiguration;
  14561. /**
  14562. * Attaches a new image processing configuration to the Standard Material.
  14563. * @param configuration
  14564. */
  14565. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14566. /** @hidden */
  14567. protected _reset(): void;
  14568. /** @hidden */
  14569. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14570. /**
  14571. * Instantiates a particle system.
  14572. * 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.
  14573. * @param name The name of the particle system
  14574. */
  14575. constructor(name: string);
  14576. /**
  14577. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14580. * @returns the emitter
  14581. */
  14582. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14583. /**
  14584. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14585. * @param radius The radius of the hemisphere to emit from
  14586. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14587. * @returns the emitter
  14588. */
  14589. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14590. /**
  14591. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14592. * @param radius The radius of the sphere to emit from
  14593. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14594. * @returns the emitter
  14595. */
  14596. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14597. /**
  14598. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14599. * @param radius The radius of the sphere to emit from
  14600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14602. * @returns the emitter
  14603. */
  14604. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14605. /**
  14606. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14607. * @param radius The radius of the emission cylinder
  14608. * @param height The height of the emission cylinder
  14609. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14610. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14611. * @returns the emitter
  14612. */
  14613. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14614. /**
  14615. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14616. * @param radius The radius of the cylinder to emit from
  14617. * @param height The height of the emission cylinder
  14618. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14621. * @returns the emitter
  14622. */
  14623. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14624. /**
  14625. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14626. * @param radius The radius of the cone to emit from
  14627. * @param angle The base angle of the cone
  14628. * @returns the emitter
  14629. */
  14630. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14631. /**
  14632. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14635. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14636. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14637. * @returns the emitter
  14638. */
  14639. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14640. }
  14641. }
  14642. declare module "babylonjs/Particles/subEmitter" {
  14643. import { Scene } from "babylonjs/scene";
  14644. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14645. /**
  14646. * Type of sub emitter
  14647. */
  14648. export enum SubEmitterType {
  14649. /**
  14650. * Attached to the particle over it's lifetime
  14651. */
  14652. ATTACHED = 0,
  14653. /**
  14654. * Created when the particle dies
  14655. */
  14656. END = 1
  14657. }
  14658. /**
  14659. * Sub emitter class used to emit particles from an existing particle
  14660. */
  14661. export class SubEmitter {
  14662. /**
  14663. * the particle system to be used by the sub emitter
  14664. */
  14665. particleSystem: ParticleSystem;
  14666. /**
  14667. * Type of the submitter (Default: END)
  14668. */
  14669. type: SubEmitterType;
  14670. /**
  14671. * 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)
  14672. * Note: This only is supported when using an emitter of type Mesh
  14673. */
  14674. inheritDirection: boolean;
  14675. /**
  14676. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14677. */
  14678. inheritedVelocityAmount: number;
  14679. /**
  14680. * Creates a sub emitter
  14681. * @param particleSystem the particle system to be used by the sub emitter
  14682. */
  14683. constructor(
  14684. /**
  14685. * the particle system to be used by the sub emitter
  14686. */
  14687. particleSystem: ParticleSystem);
  14688. /**
  14689. * Clones the sub emitter
  14690. * @returns the cloned sub emitter
  14691. */
  14692. clone(): SubEmitter;
  14693. /**
  14694. * Serialize current object to a JSON object
  14695. * @returns the serialized object
  14696. */
  14697. serialize(): any;
  14698. /** @hidden */
  14699. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14700. /**
  14701. * Creates a new SubEmitter from a serialized JSON version
  14702. * @param serializationObject defines the JSON object to read from
  14703. * @param scene defines the hosting scene
  14704. * @param rootUrl defines the rootUrl for data loading
  14705. * @returns a new SubEmitter
  14706. */
  14707. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14708. /** Release associated resources */
  14709. dispose(): void;
  14710. }
  14711. }
  14712. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14713. /** @hidden */
  14714. export var clipPlaneFragmentDeclaration: {
  14715. name: string;
  14716. shader: string;
  14717. };
  14718. }
  14719. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14720. /** @hidden */
  14721. export var imageProcessingDeclaration: {
  14722. name: string;
  14723. shader: string;
  14724. };
  14725. }
  14726. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14727. /** @hidden */
  14728. export var imageProcessingFunctions: {
  14729. name: string;
  14730. shader: string;
  14731. };
  14732. }
  14733. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14734. /** @hidden */
  14735. export var clipPlaneFragment: {
  14736. name: string;
  14737. shader: string;
  14738. };
  14739. }
  14740. declare module "babylonjs/Shaders/particles.fragment" {
  14741. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14742. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14744. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14745. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14746. /** @hidden */
  14747. export var particlesPixelShader: {
  14748. name: string;
  14749. shader: string;
  14750. };
  14751. }
  14752. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14753. /** @hidden */
  14754. export var clipPlaneVertexDeclaration: {
  14755. name: string;
  14756. shader: string;
  14757. };
  14758. }
  14759. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14760. /** @hidden */
  14761. export var clipPlaneVertex: {
  14762. name: string;
  14763. shader: string;
  14764. };
  14765. }
  14766. declare module "babylonjs/Shaders/particles.vertex" {
  14767. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14768. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14769. /** @hidden */
  14770. export var particlesVertexShader: {
  14771. name: string;
  14772. shader: string;
  14773. };
  14774. }
  14775. declare module "babylonjs/Particles/particleSystem" {
  14776. import { Nullable } from "babylonjs/types";
  14777. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14778. import { Observable } from "babylonjs/Misc/observable";
  14779. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14780. import { Effect } from "babylonjs/Materials/effect";
  14781. import { Scene, IDisposable } from "babylonjs/scene";
  14782. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14783. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14784. import { Particle } from "babylonjs/Particles/particle";
  14785. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14786. import "babylonjs/Shaders/particles.fragment";
  14787. import "babylonjs/Shaders/particles.vertex";
  14788. /**
  14789. * This represents a particle system in Babylon.
  14790. * 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.
  14791. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14792. * @example https://doc.babylonjs.com/babylon101/particles
  14793. */
  14794. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14795. /**
  14796. * Billboard mode will only apply to Y axis
  14797. */
  14798. static readonly BILLBOARDMODE_Y: number;
  14799. /**
  14800. * Billboard mode will apply to all axes
  14801. */
  14802. static readonly BILLBOARDMODE_ALL: number;
  14803. /**
  14804. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14805. */
  14806. static readonly BILLBOARDMODE_STRETCHED: number;
  14807. /**
  14808. * This function can be defined to provide custom update for active particles.
  14809. * This function will be called instead of regular update (age, position, color, etc.).
  14810. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14811. */
  14812. updateFunction: (particles: Particle[]) => void;
  14813. private _emitterWorldMatrix;
  14814. /**
  14815. * This function can be defined to specify initial direction for every new particle.
  14816. * It by default use the emitterType defined function
  14817. */
  14818. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14819. /**
  14820. * This function can be defined to specify initial position for every new particle.
  14821. * It by default use the emitterType defined function
  14822. */
  14823. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14824. /**
  14825. * @hidden
  14826. */
  14827. _inheritedVelocityOffset: Vector3;
  14828. /**
  14829. * An event triggered when the system is disposed
  14830. */
  14831. onDisposeObservable: Observable<ParticleSystem>;
  14832. private _onDisposeObserver;
  14833. /**
  14834. * Sets a callback that will be triggered when the system is disposed
  14835. */
  14836. onDispose: () => void;
  14837. private _particles;
  14838. private _epsilon;
  14839. private _capacity;
  14840. private _stockParticles;
  14841. private _newPartsExcess;
  14842. private _vertexData;
  14843. private _vertexBuffer;
  14844. private _vertexBuffers;
  14845. private _spriteBuffer;
  14846. private _indexBuffer;
  14847. private _effect;
  14848. private _customEffect;
  14849. private _cachedDefines;
  14850. private _scaledColorStep;
  14851. private _colorDiff;
  14852. private _scaledDirection;
  14853. private _scaledGravity;
  14854. private _currentRenderId;
  14855. private _alive;
  14856. private _useInstancing;
  14857. private _started;
  14858. private _stopped;
  14859. private _actualFrame;
  14860. private _scaledUpdateSpeed;
  14861. private _vertexBufferSize;
  14862. /** @hidden */
  14863. _currentEmitRateGradient: Nullable<FactorGradient>;
  14864. /** @hidden */
  14865. _currentEmitRate1: number;
  14866. /** @hidden */
  14867. _currentEmitRate2: number;
  14868. /** @hidden */
  14869. _currentStartSizeGradient: Nullable<FactorGradient>;
  14870. /** @hidden */
  14871. _currentStartSize1: number;
  14872. /** @hidden */
  14873. _currentStartSize2: number;
  14874. private readonly _rawTextureWidth;
  14875. private _rampGradientsTexture;
  14876. private _useRampGradients;
  14877. /** Gets or sets a boolean indicating that ramp gradients must be used
  14878. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14879. */
  14880. useRampGradients: boolean;
  14881. /**
  14882. * 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.
  14883. * 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: [])
  14884. */
  14885. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14886. private _subEmitters;
  14887. /**
  14888. * @hidden
  14889. * If the particle systems emitter should be disposed when the particle system is disposed
  14890. */
  14891. _disposeEmitterOnDispose: boolean;
  14892. /**
  14893. * The current active Sub-systems, this property is used by the root particle system only.
  14894. */
  14895. activeSubSystems: Array<ParticleSystem>;
  14896. private _rootParticleSystem;
  14897. /**
  14898. * Gets the current list of active particles
  14899. */
  14900. readonly particles: Particle[];
  14901. /**
  14902. * Returns the string "ParticleSystem"
  14903. * @returns a string containing the class name
  14904. */
  14905. getClassName(): string;
  14906. /**
  14907. * Instantiates a particle system.
  14908. * 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.
  14909. * @param name The name of the particle system
  14910. * @param capacity The max number of particles alive at the same time
  14911. * @param scene The scene the particle system belongs to
  14912. * @param customEffect a custom effect used to change the way particles are rendered by default
  14913. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14914. * @param epsilon Offset used to render the particles
  14915. */
  14916. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14917. private _addFactorGradient;
  14918. private _removeFactorGradient;
  14919. /**
  14920. * Adds a new life time gradient
  14921. * @param gradient defines the gradient to use (between 0 and 1)
  14922. * @param factor defines the life time factor to affect to the specified gradient
  14923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14924. * @returns the current particle system
  14925. */
  14926. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14927. /**
  14928. * Remove a specific life time gradient
  14929. * @param gradient defines the gradient to remove
  14930. * @returns the current particle system
  14931. */
  14932. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14933. /**
  14934. * Adds a new size gradient
  14935. * @param gradient defines the gradient to use (between 0 and 1)
  14936. * @param factor defines the size factor to affect to the specified gradient
  14937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14938. * @returns the current particle system
  14939. */
  14940. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14941. /**
  14942. * Remove a specific size gradient
  14943. * @param gradient defines the gradient to remove
  14944. * @returns the current particle system
  14945. */
  14946. removeSizeGradient(gradient: number): IParticleSystem;
  14947. /**
  14948. * Adds a new color remap gradient
  14949. * @param gradient defines the gradient to use (between 0 and 1)
  14950. * @param min defines the color remap minimal range
  14951. * @param max defines the color remap maximal range
  14952. * @returns the current particle system
  14953. */
  14954. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14955. /**
  14956. * Remove a specific color remap gradient
  14957. * @param gradient defines the gradient to remove
  14958. * @returns the current particle system
  14959. */
  14960. removeColorRemapGradient(gradient: number): IParticleSystem;
  14961. /**
  14962. * Adds a new alpha remap gradient
  14963. * @param gradient defines the gradient to use (between 0 and 1)
  14964. * @param min defines the alpha remap minimal range
  14965. * @param max defines the alpha remap maximal range
  14966. * @returns the current particle system
  14967. */
  14968. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14969. /**
  14970. * Remove a specific alpha remap gradient
  14971. * @param gradient defines the gradient to remove
  14972. * @returns the current particle system
  14973. */
  14974. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14975. /**
  14976. * Adds a new angular speed gradient
  14977. * @param gradient defines the gradient to use (between 0 and 1)
  14978. * @param factor defines the angular speed to affect to the specified gradient
  14979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14980. * @returns the current particle system
  14981. */
  14982. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14983. /**
  14984. * Remove a specific angular speed gradient
  14985. * @param gradient defines the gradient to remove
  14986. * @returns the current particle system
  14987. */
  14988. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14989. /**
  14990. * Adds a new velocity gradient
  14991. * @param gradient defines the gradient to use (between 0 and 1)
  14992. * @param factor defines the velocity to affect to the specified gradient
  14993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14994. * @returns the current particle system
  14995. */
  14996. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14997. /**
  14998. * Remove a specific velocity gradient
  14999. * @param gradient defines the gradient to remove
  15000. * @returns the current particle system
  15001. */
  15002. removeVelocityGradient(gradient: number): IParticleSystem;
  15003. /**
  15004. * Adds a new limit velocity gradient
  15005. * @param gradient defines the gradient to use (between 0 and 1)
  15006. * @param factor defines the limit velocity value to affect to the specified gradient
  15007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15008. * @returns the current particle system
  15009. */
  15010. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15011. /**
  15012. * Remove a specific limit velocity gradient
  15013. * @param gradient defines the gradient to remove
  15014. * @returns the current particle system
  15015. */
  15016. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15017. /**
  15018. * Adds a new drag gradient
  15019. * @param gradient defines the gradient to use (between 0 and 1)
  15020. * @param factor defines the drag value to affect to the specified gradient
  15021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15022. * @returns the current particle system
  15023. */
  15024. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15025. /**
  15026. * Remove a specific drag gradient
  15027. * @param gradient defines the gradient to remove
  15028. * @returns the current particle system
  15029. */
  15030. removeDragGradient(gradient: number): IParticleSystem;
  15031. /**
  15032. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15033. * @param gradient defines the gradient to use (between 0 and 1)
  15034. * @param factor defines the emit rate value to affect to the specified gradient
  15035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15036. * @returns the current particle system
  15037. */
  15038. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15039. /**
  15040. * Remove a specific emit rate gradient
  15041. * @param gradient defines the gradient to remove
  15042. * @returns the current particle system
  15043. */
  15044. removeEmitRateGradient(gradient: number): IParticleSystem;
  15045. /**
  15046. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15047. * @param gradient defines the gradient to use (between 0 and 1)
  15048. * @param factor defines the start size value to affect to the specified gradient
  15049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15050. * @returns the current particle system
  15051. */
  15052. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15053. /**
  15054. * Remove a specific start size gradient
  15055. * @param gradient defines the gradient to remove
  15056. * @returns the current particle system
  15057. */
  15058. removeStartSizeGradient(gradient: number): IParticleSystem;
  15059. private _createRampGradientTexture;
  15060. /**
  15061. * Gets the current list of ramp gradients.
  15062. * You must use addRampGradient and removeRampGradient to udpate this list
  15063. * @returns the list of ramp gradients
  15064. */
  15065. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15066. /**
  15067. * Adds a new ramp gradient used to remap particle colors
  15068. * @param gradient defines the gradient to use (between 0 and 1)
  15069. * @param color defines the color to affect to the specified gradient
  15070. * @returns the current particle system
  15071. */
  15072. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15073. /**
  15074. * Remove a specific ramp gradient
  15075. * @param gradient defines the gradient to remove
  15076. * @returns the current particle system
  15077. */
  15078. removeRampGradient(gradient: number): ParticleSystem;
  15079. /**
  15080. * Adds a new color gradient
  15081. * @param gradient defines the gradient to use (between 0 and 1)
  15082. * @param color1 defines the color to affect to the specified gradient
  15083. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15084. * @returns this particle system
  15085. */
  15086. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15087. /**
  15088. * Remove a specific color gradient
  15089. * @param gradient defines the gradient to remove
  15090. * @returns this particle system
  15091. */
  15092. removeColorGradient(gradient: number): IParticleSystem;
  15093. private _fetchR;
  15094. protected _reset(): void;
  15095. private _resetEffect;
  15096. private _createVertexBuffers;
  15097. private _createIndexBuffer;
  15098. /**
  15099. * Gets the maximum number of particles active at the same time.
  15100. * @returns The max number of active particles.
  15101. */
  15102. getCapacity(): number;
  15103. /**
  15104. * Gets whether there are still active particles in the system.
  15105. * @returns True if it is alive, otherwise false.
  15106. */
  15107. isAlive(): boolean;
  15108. /**
  15109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15110. * @returns True if it has been started, otherwise false.
  15111. */
  15112. isStarted(): boolean;
  15113. private _prepareSubEmitterInternalArray;
  15114. /**
  15115. * Starts the particle system and begins to emit
  15116. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15117. */
  15118. start(delay?: number): void;
  15119. /**
  15120. * Stops the particle system.
  15121. * @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.
  15122. */
  15123. stop(stopSubEmitters?: boolean): void;
  15124. /**
  15125. * Remove all active particles
  15126. */
  15127. reset(): void;
  15128. /**
  15129. * @hidden (for internal use only)
  15130. */
  15131. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15132. /**
  15133. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15134. * Its lifetime will start back at 0.
  15135. */
  15136. recycleParticle: (particle: Particle) => void;
  15137. private _stopSubEmitters;
  15138. private _createParticle;
  15139. private _removeFromRoot;
  15140. private _emitFromParticle;
  15141. private _update;
  15142. /** @hidden */
  15143. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15144. /** @hidden */
  15145. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15146. /** @hidden */
  15147. private _getEffect;
  15148. /**
  15149. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15150. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15151. */
  15152. animate(preWarmOnly?: boolean): void;
  15153. private _appendParticleVertices;
  15154. /**
  15155. * Rebuilds the particle system.
  15156. */
  15157. rebuild(): void;
  15158. /**
  15159. * Is this system ready to be used/rendered
  15160. * @return true if the system is ready
  15161. */
  15162. isReady(): boolean;
  15163. private _render;
  15164. /**
  15165. * Renders the particle system in its current state.
  15166. * @returns the current number of particles
  15167. */
  15168. render(): number;
  15169. /**
  15170. * Disposes the particle system and free the associated resources
  15171. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15172. */
  15173. dispose(disposeTexture?: boolean): void;
  15174. /**
  15175. * Clones the particle system.
  15176. * @param name The name of the cloned object
  15177. * @param newEmitter The new emitter to use
  15178. * @returns the cloned particle system
  15179. */
  15180. clone(name: string, newEmitter: any): ParticleSystem;
  15181. /**
  15182. * Serializes the particle system to a JSON object.
  15183. * @returns the JSON object
  15184. */
  15185. serialize(): any;
  15186. /** @hidden */
  15187. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15188. /** @hidden */
  15189. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15190. /**
  15191. * Parses a JSON object to create a particle system.
  15192. * @param parsedParticleSystem The JSON object to parse
  15193. * @param scene The scene to create the particle system in
  15194. * @param rootUrl The root url to use to load external dependencies like texture
  15195. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15196. * @returns the Parsed particle system
  15197. */
  15198. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15199. }
  15200. }
  15201. declare module "babylonjs/Particles/particle" {
  15202. import { Nullable } from "babylonjs/types";
  15203. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15204. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15205. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15206. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15207. /**
  15208. * A particle represents one of the element emitted by a particle system.
  15209. * This is mainly define by its coordinates, direction, velocity and age.
  15210. */
  15211. export class Particle {
  15212. /**
  15213. * The particle system the particle belongs to.
  15214. */
  15215. particleSystem: ParticleSystem;
  15216. private static _Count;
  15217. /**
  15218. * Unique ID of the particle
  15219. */
  15220. id: number;
  15221. /**
  15222. * The world position of the particle in the scene.
  15223. */
  15224. position: Vector3;
  15225. /**
  15226. * The world direction of the particle in the scene.
  15227. */
  15228. direction: Vector3;
  15229. /**
  15230. * The color of the particle.
  15231. */
  15232. color: Color4;
  15233. /**
  15234. * The color change of the particle per step.
  15235. */
  15236. colorStep: Color4;
  15237. /**
  15238. * Defines how long will the life of the particle be.
  15239. */
  15240. lifeTime: number;
  15241. /**
  15242. * The current age of the particle.
  15243. */
  15244. age: number;
  15245. /**
  15246. * The current size of the particle.
  15247. */
  15248. size: number;
  15249. /**
  15250. * The current scale of the particle.
  15251. */
  15252. scale: Vector2;
  15253. /**
  15254. * The current angle of the particle.
  15255. */
  15256. angle: number;
  15257. /**
  15258. * Defines how fast is the angle changing.
  15259. */
  15260. angularSpeed: number;
  15261. /**
  15262. * Defines the cell index used by the particle to be rendered from a sprite.
  15263. */
  15264. cellIndex: number;
  15265. /**
  15266. * The information required to support color remapping
  15267. */
  15268. remapData: Vector4;
  15269. /** @hidden */
  15270. _randomCellOffset?: number;
  15271. /** @hidden */
  15272. _initialDirection: Nullable<Vector3>;
  15273. /** @hidden */
  15274. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15275. /** @hidden */
  15276. _initialStartSpriteCellID: number;
  15277. /** @hidden */
  15278. _initialEndSpriteCellID: number;
  15279. /** @hidden */
  15280. _currentColorGradient: Nullable<ColorGradient>;
  15281. /** @hidden */
  15282. _currentColor1: Color4;
  15283. /** @hidden */
  15284. _currentColor2: Color4;
  15285. /** @hidden */
  15286. _currentSizeGradient: Nullable<FactorGradient>;
  15287. /** @hidden */
  15288. _currentSize1: number;
  15289. /** @hidden */
  15290. _currentSize2: number;
  15291. /** @hidden */
  15292. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15293. /** @hidden */
  15294. _currentAngularSpeed1: number;
  15295. /** @hidden */
  15296. _currentAngularSpeed2: number;
  15297. /** @hidden */
  15298. _currentVelocityGradient: Nullable<FactorGradient>;
  15299. /** @hidden */
  15300. _currentVelocity1: number;
  15301. /** @hidden */
  15302. _currentVelocity2: number;
  15303. /** @hidden */
  15304. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15305. /** @hidden */
  15306. _currentLimitVelocity1: number;
  15307. /** @hidden */
  15308. _currentLimitVelocity2: number;
  15309. /** @hidden */
  15310. _currentDragGradient: Nullable<FactorGradient>;
  15311. /** @hidden */
  15312. _currentDrag1: number;
  15313. /** @hidden */
  15314. _currentDrag2: number;
  15315. /** @hidden */
  15316. _randomNoiseCoordinates1: Vector3;
  15317. /** @hidden */
  15318. _randomNoiseCoordinates2: Vector3;
  15319. /**
  15320. * Creates a new instance Particle
  15321. * @param particleSystem the particle system the particle belongs to
  15322. */
  15323. constructor(
  15324. /**
  15325. * The particle system the particle belongs to.
  15326. */
  15327. particleSystem: ParticleSystem);
  15328. private updateCellInfoFromSystem;
  15329. /**
  15330. * Defines how the sprite cell index is updated for the particle
  15331. */
  15332. updateCellIndex(): void;
  15333. /** @hidden */
  15334. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15335. /** @hidden */
  15336. _inheritParticleInfoToSubEmitters(): void;
  15337. /** @hidden */
  15338. _reset(): void;
  15339. /**
  15340. * Copy the properties of particle to another one.
  15341. * @param other the particle to copy the information to.
  15342. */
  15343. copyTo(other: Particle): void;
  15344. }
  15345. }
  15346. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15347. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15348. import { Effect } from "babylonjs/Materials/effect";
  15349. import { Particle } from "babylonjs/Particles/particle";
  15350. /**
  15351. * Particle emitter represents a volume emitting particles.
  15352. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15353. */
  15354. export interface IParticleEmitterType {
  15355. /**
  15356. * Called by the particle System when the direction is computed for the created particle.
  15357. * @param worldMatrix is the world matrix of the particle system
  15358. * @param directionToUpdate is the direction vector to update with the result
  15359. * @param particle is the particle we are computed the direction for
  15360. */
  15361. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15362. /**
  15363. * Called by the particle System when the position is computed for the created particle.
  15364. * @param worldMatrix is the world matrix of the particle system
  15365. * @param positionToUpdate is the position vector to update with the result
  15366. * @param particle is the particle we are computed the position for
  15367. */
  15368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15369. /**
  15370. * Clones the current emitter and returns a copy of it
  15371. * @returns the new emitter
  15372. */
  15373. clone(): IParticleEmitterType;
  15374. /**
  15375. * Called by the GPUParticleSystem to setup the update shader
  15376. * @param effect defines the update shader
  15377. */
  15378. applyToShader(effect: Effect): void;
  15379. /**
  15380. * Returns a string to use to update the GPU particles update shader
  15381. * @returns the effect defines string
  15382. */
  15383. getEffectDefines(): string;
  15384. /**
  15385. * Returns a string representing the class name
  15386. * @returns a string containing the class name
  15387. */
  15388. getClassName(): string;
  15389. /**
  15390. * Serializes the particle system to a JSON object.
  15391. * @returns the JSON object
  15392. */
  15393. serialize(): any;
  15394. /**
  15395. * Parse properties from a JSON object
  15396. * @param serializationObject defines the JSON object
  15397. */
  15398. parse(serializationObject: any): void;
  15399. }
  15400. }
  15401. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15402. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15403. import { Effect } from "babylonjs/Materials/effect";
  15404. import { Particle } from "babylonjs/Particles/particle";
  15405. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15406. /**
  15407. * Particle emitter emitting particles from the inside of a box.
  15408. * It emits the particles randomly between 2 given directions.
  15409. */
  15410. export class BoxParticleEmitter implements IParticleEmitterType {
  15411. /**
  15412. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15413. */
  15414. direction1: Vector3;
  15415. /**
  15416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15417. */
  15418. direction2: Vector3;
  15419. /**
  15420. * 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.
  15421. */
  15422. minEmitBox: Vector3;
  15423. /**
  15424. * 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.
  15425. */
  15426. maxEmitBox: Vector3;
  15427. /**
  15428. * Creates a new instance BoxParticleEmitter
  15429. */
  15430. constructor();
  15431. /**
  15432. * Called by the particle System when the direction is computed for the created particle.
  15433. * @param worldMatrix is the world matrix of the particle system
  15434. * @param directionToUpdate is the direction vector to update with the result
  15435. * @param particle is the particle we are computed the direction for
  15436. */
  15437. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15438. /**
  15439. * Called by the particle System when the position is computed for the created particle.
  15440. * @param worldMatrix is the world matrix of the particle system
  15441. * @param positionToUpdate is the position vector to update with the result
  15442. * @param particle is the particle we are computed the position for
  15443. */
  15444. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15445. /**
  15446. * Clones the current emitter and returns a copy of it
  15447. * @returns the new emitter
  15448. */
  15449. clone(): BoxParticleEmitter;
  15450. /**
  15451. * Called by the GPUParticleSystem to setup the update shader
  15452. * @param effect defines the update shader
  15453. */
  15454. applyToShader(effect: Effect): void;
  15455. /**
  15456. * Returns a string to use to update the GPU particles update shader
  15457. * @returns a string containng the defines string
  15458. */
  15459. getEffectDefines(): string;
  15460. /**
  15461. * Returns the string "BoxParticleEmitter"
  15462. * @returns a string containing the class name
  15463. */
  15464. getClassName(): string;
  15465. /**
  15466. * Serializes the particle system to a JSON object.
  15467. * @returns the JSON object
  15468. */
  15469. serialize(): any;
  15470. /**
  15471. * Parse properties from a JSON object
  15472. * @param serializationObject defines the JSON object
  15473. */
  15474. parse(serializationObject: any): void;
  15475. }
  15476. }
  15477. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15478. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15479. import { Effect } from "babylonjs/Materials/effect";
  15480. import { Particle } from "babylonjs/Particles/particle";
  15481. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15482. /**
  15483. * Particle emitter emitting particles from the inside of a cone.
  15484. * It emits the particles alongside the cone volume from the base to the particle.
  15485. * The emission direction might be randomized.
  15486. */
  15487. export class ConeParticleEmitter implements IParticleEmitterType {
  15488. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15489. directionRandomizer: number;
  15490. private _radius;
  15491. private _angle;
  15492. private _height;
  15493. /**
  15494. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15495. */
  15496. radiusRange: number;
  15497. /**
  15498. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15499. */
  15500. heightRange: number;
  15501. /**
  15502. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15503. */
  15504. emitFromSpawnPointOnly: boolean;
  15505. /**
  15506. * Gets or sets the radius of the emission cone
  15507. */
  15508. radius: number;
  15509. /**
  15510. * Gets or sets the angle of the emission cone
  15511. */
  15512. angle: number;
  15513. private _buildHeight;
  15514. /**
  15515. * Creates a new instance ConeParticleEmitter
  15516. * @param radius the radius of the emission cone (1 by default)
  15517. * @param angle the cone base angle (PI by default)
  15518. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15519. */
  15520. constructor(radius?: number, angle?: number,
  15521. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15522. directionRandomizer?: number);
  15523. /**
  15524. * Called by the particle System when the direction is computed for the created particle.
  15525. * @param worldMatrix is the world matrix of the particle system
  15526. * @param directionToUpdate is the direction vector to update with the result
  15527. * @param particle is the particle we are computed the direction for
  15528. */
  15529. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15530. /**
  15531. * Called by the particle System when the position is computed for the created particle.
  15532. * @param worldMatrix is the world matrix of the particle system
  15533. * @param positionToUpdate is the position vector to update with the result
  15534. * @param particle is the particle we are computed the position for
  15535. */
  15536. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15537. /**
  15538. * Clones the current emitter and returns a copy of it
  15539. * @returns the new emitter
  15540. */
  15541. clone(): ConeParticleEmitter;
  15542. /**
  15543. * Called by the GPUParticleSystem to setup the update shader
  15544. * @param effect defines the update shader
  15545. */
  15546. applyToShader(effect: Effect): void;
  15547. /**
  15548. * Returns a string to use to update the GPU particles update shader
  15549. * @returns a string containng the defines string
  15550. */
  15551. getEffectDefines(): string;
  15552. /**
  15553. * Returns the string "ConeParticleEmitter"
  15554. * @returns a string containing the class name
  15555. */
  15556. getClassName(): string;
  15557. /**
  15558. * Serializes the particle system to a JSON object.
  15559. * @returns the JSON object
  15560. */
  15561. serialize(): any;
  15562. /**
  15563. * Parse properties from a JSON object
  15564. * @param serializationObject defines the JSON object
  15565. */
  15566. parse(serializationObject: any): void;
  15567. }
  15568. }
  15569. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15570. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15571. import { Effect } from "babylonjs/Materials/effect";
  15572. import { Particle } from "babylonjs/Particles/particle";
  15573. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15574. /**
  15575. * Particle emitter emitting particles from the inside of a cylinder.
  15576. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15577. */
  15578. export class CylinderParticleEmitter implements IParticleEmitterType {
  15579. /**
  15580. * The radius of the emission cylinder.
  15581. */
  15582. radius: number;
  15583. /**
  15584. * The height of the emission cylinder.
  15585. */
  15586. height: number;
  15587. /**
  15588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15589. */
  15590. radiusRange: number;
  15591. /**
  15592. * How much to randomize the particle direction [0-1].
  15593. */
  15594. directionRandomizer: number;
  15595. /**
  15596. * Creates a new instance CylinderParticleEmitter
  15597. * @param radius the radius of the emission cylinder (1 by default)
  15598. * @param height the height of the emission cylinder (1 by default)
  15599. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15600. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15601. */
  15602. constructor(
  15603. /**
  15604. * The radius of the emission cylinder.
  15605. */
  15606. radius?: number,
  15607. /**
  15608. * The height of the emission cylinder.
  15609. */
  15610. height?: number,
  15611. /**
  15612. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15613. */
  15614. radiusRange?: number,
  15615. /**
  15616. * How much to randomize the particle direction [0-1].
  15617. */
  15618. directionRandomizer?: number);
  15619. /**
  15620. * Called by the particle System when the direction is computed for the created particle.
  15621. * @param worldMatrix is the world matrix of the particle system
  15622. * @param directionToUpdate is the direction vector to update with the result
  15623. * @param particle is the particle we are computed the direction for
  15624. */
  15625. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15626. /**
  15627. * Called by the particle System when the position is computed for the created particle.
  15628. * @param worldMatrix is the world matrix of the particle system
  15629. * @param positionToUpdate is the position vector to update with the result
  15630. * @param particle is the particle we are computed the position for
  15631. */
  15632. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15633. /**
  15634. * Clones the current emitter and returns a copy of it
  15635. * @returns the new emitter
  15636. */
  15637. clone(): CylinderParticleEmitter;
  15638. /**
  15639. * Called by the GPUParticleSystem to setup the update shader
  15640. * @param effect defines the update shader
  15641. */
  15642. applyToShader(effect: Effect): void;
  15643. /**
  15644. * Returns a string to use to update the GPU particles update shader
  15645. * @returns a string containng the defines string
  15646. */
  15647. getEffectDefines(): string;
  15648. /**
  15649. * Returns the string "CylinderParticleEmitter"
  15650. * @returns a string containing the class name
  15651. */
  15652. getClassName(): string;
  15653. /**
  15654. * Serializes the particle system to a JSON object.
  15655. * @returns the JSON object
  15656. */
  15657. serialize(): any;
  15658. /**
  15659. * Parse properties from a JSON object
  15660. * @param serializationObject defines the JSON object
  15661. */
  15662. parse(serializationObject: any): void;
  15663. }
  15664. /**
  15665. * Particle emitter emitting particles from the inside of a cylinder.
  15666. * It emits the particles randomly between two vectors.
  15667. */
  15668. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15669. /**
  15670. * The min limit of the emission direction.
  15671. */
  15672. direction1: Vector3;
  15673. /**
  15674. * The max limit of the emission direction.
  15675. */
  15676. direction2: Vector3;
  15677. /**
  15678. * Creates a new instance CylinderDirectedParticleEmitter
  15679. * @param radius the radius of the emission cylinder (1 by default)
  15680. * @param height the height of the emission cylinder (1 by default)
  15681. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15682. * @param direction1 the min limit of the emission direction (up vector by default)
  15683. * @param direction2 the max limit of the emission direction (up vector by default)
  15684. */
  15685. constructor(radius?: number, height?: number, radiusRange?: number,
  15686. /**
  15687. * The min limit of the emission direction.
  15688. */
  15689. direction1?: Vector3,
  15690. /**
  15691. * The max limit of the emission direction.
  15692. */
  15693. direction2?: Vector3);
  15694. /**
  15695. * Called by the particle System when the direction is computed for the created particle.
  15696. * @param worldMatrix is the world matrix of the particle system
  15697. * @param directionToUpdate is the direction vector to update with the result
  15698. * @param particle is the particle we are computed the direction for
  15699. */
  15700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15701. /**
  15702. * Clones the current emitter and returns a copy of it
  15703. * @returns the new emitter
  15704. */
  15705. clone(): CylinderDirectedParticleEmitter;
  15706. /**
  15707. * Called by the GPUParticleSystem to setup the update shader
  15708. * @param effect defines the update shader
  15709. */
  15710. applyToShader(effect: Effect): void;
  15711. /**
  15712. * Returns a string to use to update the GPU particles update shader
  15713. * @returns a string containng the defines string
  15714. */
  15715. getEffectDefines(): string;
  15716. /**
  15717. * Returns the string "CylinderDirectedParticleEmitter"
  15718. * @returns a string containing the class name
  15719. */
  15720. getClassName(): string;
  15721. /**
  15722. * Serializes the particle system to a JSON object.
  15723. * @returns the JSON object
  15724. */
  15725. serialize(): any;
  15726. /**
  15727. * Parse properties from a JSON object
  15728. * @param serializationObject defines the JSON object
  15729. */
  15730. parse(serializationObject: any): void;
  15731. }
  15732. }
  15733. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15734. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15735. import { Effect } from "babylonjs/Materials/effect";
  15736. import { Particle } from "babylonjs/Particles/particle";
  15737. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15738. /**
  15739. * Particle emitter emitting particles from the inside of a hemisphere.
  15740. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15741. */
  15742. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15743. /**
  15744. * The radius of the emission hemisphere.
  15745. */
  15746. radius: number;
  15747. /**
  15748. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15749. */
  15750. radiusRange: number;
  15751. /**
  15752. * How much to randomize the particle direction [0-1].
  15753. */
  15754. directionRandomizer: number;
  15755. /**
  15756. * Creates a new instance HemisphericParticleEmitter
  15757. * @param radius the radius of the emission hemisphere (1 by default)
  15758. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15759. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15760. */
  15761. constructor(
  15762. /**
  15763. * The radius of the emission hemisphere.
  15764. */
  15765. radius?: number,
  15766. /**
  15767. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15768. */
  15769. radiusRange?: number,
  15770. /**
  15771. * How much to randomize the particle direction [0-1].
  15772. */
  15773. directionRandomizer?: number);
  15774. /**
  15775. * Called by the particle System when the direction is computed for the created particle.
  15776. * @param worldMatrix is the world matrix of the particle system
  15777. * @param directionToUpdate is the direction vector to update with the result
  15778. * @param particle is the particle we are computed the direction for
  15779. */
  15780. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15781. /**
  15782. * Called by the particle System when the position is computed for the created particle.
  15783. * @param worldMatrix is the world matrix of the particle system
  15784. * @param positionToUpdate is the position vector to update with the result
  15785. * @param particle is the particle we are computed the position for
  15786. */
  15787. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15788. /**
  15789. * Clones the current emitter and returns a copy of it
  15790. * @returns the new emitter
  15791. */
  15792. clone(): HemisphericParticleEmitter;
  15793. /**
  15794. * Called by the GPUParticleSystem to setup the update shader
  15795. * @param effect defines the update shader
  15796. */
  15797. applyToShader(effect: Effect): void;
  15798. /**
  15799. * Returns a string to use to update the GPU particles update shader
  15800. * @returns a string containng the defines string
  15801. */
  15802. getEffectDefines(): string;
  15803. /**
  15804. * Returns the string "HemisphericParticleEmitter"
  15805. * @returns a string containing the class name
  15806. */
  15807. getClassName(): string;
  15808. /**
  15809. * Serializes the particle system to a JSON object.
  15810. * @returns the JSON object
  15811. */
  15812. serialize(): any;
  15813. /**
  15814. * Parse properties from a JSON object
  15815. * @param serializationObject defines the JSON object
  15816. */
  15817. parse(serializationObject: any): void;
  15818. }
  15819. }
  15820. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15821. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15822. import { Effect } from "babylonjs/Materials/effect";
  15823. import { Particle } from "babylonjs/Particles/particle";
  15824. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15825. /**
  15826. * Particle emitter emitting particles from a point.
  15827. * It emits the particles randomly between 2 given directions.
  15828. */
  15829. export class PointParticleEmitter implements IParticleEmitterType {
  15830. /**
  15831. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15832. */
  15833. direction1: Vector3;
  15834. /**
  15835. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15836. */
  15837. direction2: Vector3;
  15838. /**
  15839. * Creates a new instance PointParticleEmitter
  15840. */
  15841. constructor();
  15842. /**
  15843. * Called by the particle System when the direction is computed for the created particle.
  15844. * @param worldMatrix is the world matrix of the particle system
  15845. * @param directionToUpdate is the direction vector to update with the result
  15846. * @param particle is the particle we are computed the direction for
  15847. */
  15848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15849. /**
  15850. * Called by the particle System when the position is computed for the created particle.
  15851. * @param worldMatrix is the world matrix of the particle system
  15852. * @param positionToUpdate is the position vector to update with the result
  15853. * @param particle is the particle we are computed the position for
  15854. */
  15855. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15856. /**
  15857. * Clones the current emitter and returns a copy of it
  15858. * @returns the new emitter
  15859. */
  15860. clone(): PointParticleEmitter;
  15861. /**
  15862. * Called by the GPUParticleSystem to setup the update shader
  15863. * @param effect defines the update shader
  15864. */
  15865. applyToShader(effect: Effect): void;
  15866. /**
  15867. * Returns a string to use to update the GPU particles update shader
  15868. * @returns a string containng the defines string
  15869. */
  15870. getEffectDefines(): string;
  15871. /**
  15872. * Returns the string "PointParticleEmitter"
  15873. * @returns a string containing the class name
  15874. */
  15875. getClassName(): string;
  15876. /**
  15877. * Serializes the particle system to a JSON object.
  15878. * @returns the JSON object
  15879. */
  15880. serialize(): any;
  15881. /**
  15882. * Parse properties from a JSON object
  15883. * @param serializationObject defines the JSON object
  15884. */
  15885. parse(serializationObject: any): void;
  15886. }
  15887. }
  15888. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15889. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15890. import { Effect } from "babylonjs/Materials/effect";
  15891. import { Particle } from "babylonjs/Particles/particle";
  15892. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15893. /**
  15894. * Particle emitter emitting particles from the inside of a sphere.
  15895. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15896. */
  15897. export class SphereParticleEmitter implements IParticleEmitterType {
  15898. /**
  15899. * The radius of the emission sphere.
  15900. */
  15901. radius: number;
  15902. /**
  15903. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15904. */
  15905. radiusRange: number;
  15906. /**
  15907. * How much to randomize the particle direction [0-1].
  15908. */
  15909. directionRandomizer: number;
  15910. /**
  15911. * Creates a new instance SphereParticleEmitter
  15912. * @param radius the radius of the emission sphere (1 by default)
  15913. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15914. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15915. */
  15916. constructor(
  15917. /**
  15918. * The radius of the emission sphere.
  15919. */
  15920. radius?: number,
  15921. /**
  15922. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15923. */
  15924. radiusRange?: number,
  15925. /**
  15926. * How much to randomize the particle direction [0-1].
  15927. */
  15928. directionRandomizer?: number);
  15929. /**
  15930. * Called by the particle System when the direction is computed for the created particle.
  15931. * @param worldMatrix is the world matrix of the particle system
  15932. * @param directionToUpdate is the direction vector to update with the result
  15933. * @param particle is the particle we are computed the direction for
  15934. */
  15935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15936. /**
  15937. * Called by the particle System when the position is computed for the created particle.
  15938. * @param worldMatrix is the world matrix of the particle system
  15939. * @param positionToUpdate is the position vector to update with the result
  15940. * @param particle is the particle we are computed the position for
  15941. */
  15942. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15943. /**
  15944. * Clones the current emitter and returns a copy of it
  15945. * @returns the new emitter
  15946. */
  15947. clone(): SphereParticleEmitter;
  15948. /**
  15949. * Called by the GPUParticleSystem to setup the update shader
  15950. * @param effect defines the update shader
  15951. */
  15952. applyToShader(effect: Effect): void;
  15953. /**
  15954. * Returns a string to use to update the GPU particles update shader
  15955. * @returns a string containng the defines string
  15956. */
  15957. getEffectDefines(): string;
  15958. /**
  15959. * Returns the string "SphereParticleEmitter"
  15960. * @returns a string containing the class name
  15961. */
  15962. getClassName(): string;
  15963. /**
  15964. * Serializes the particle system to a JSON object.
  15965. * @returns the JSON object
  15966. */
  15967. serialize(): any;
  15968. /**
  15969. * Parse properties from a JSON object
  15970. * @param serializationObject defines the JSON object
  15971. */
  15972. parse(serializationObject: any): void;
  15973. }
  15974. /**
  15975. * Particle emitter emitting particles from the inside of a sphere.
  15976. * It emits the particles randomly between two vectors.
  15977. */
  15978. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15979. /**
  15980. * The min limit of the emission direction.
  15981. */
  15982. direction1: Vector3;
  15983. /**
  15984. * The max limit of the emission direction.
  15985. */
  15986. direction2: Vector3;
  15987. /**
  15988. * Creates a new instance SphereDirectedParticleEmitter
  15989. * @param radius the radius of the emission sphere (1 by default)
  15990. * @param direction1 the min limit of the emission direction (up vector by default)
  15991. * @param direction2 the max limit of the emission direction (up vector by default)
  15992. */
  15993. constructor(radius?: number,
  15994. /**
  15995. * The min limit of the emission direction.
  15996. */
  15997. direction1?: Vector3,
  15998. /**
  15999. * The max limit of the emission direction.
  16000. */
  16001. direction2?: Vector3);
  16002. /**
  16003. * Called by the particle System when the direction is computed for the created particle.
  16004. * @param worldMatrix is the world matrix of the particle system
  16005. * @param directionToUpdate is the direction vector to update with the result
  16006. * @param particle is the particle we are computed the direction for
  16007. */
  16008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16009. /**
  16010. * Clones the current emitter and returns a copy of it
  16011. * @returns the new emitter
  16012. */
  16013. clone(): SphereDirectedParticleEmitter;
  16014. /**
  16015. * Called by the GPUParticleSystem to setup the update shader
  16016. * @param effect defines the update shader
  16017. */
  16018. applyToShader(effect: Effect): void;
  16019. /**
  16020. * Returns a string to use to update the GPU particles update shader
  16021. * @returns a string containng the defines string
  16022. */
  16023. getEffectDefines(): string;
  16024. /**
  16025. * Returns the string "SphereDirectedParticleEmitter"
  16026. * @returns a string containing the class name
  16027. */
  16028. getClassName(): string;
  16029. /**
  16030. * Serializes the particle system to a JSON object.
  16031. * @returns the JSON object
  16032. */
  16033. serialize(): any;
  16034. /**
  16035. * Parse properties from a JSON object
  16036. * @param serializationObject defines the JSON object
  16037. */
  16038. parse(serializationObject: any): void;
  16039. }
  16040. }
  16041. declare module "babylonjs/Particles/EmitterTypes/index" {
  16042. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16043. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16044. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16045. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16046. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16047. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16048. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16049. }
  16050. declare module "babylonjs/Particles/IParticleSystem" {
  16051. import { Nullable } from "babylonjs/types";
  16052. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16054. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16055. import { Texture } from "babylonjs/Materials/Textures/texture";
  16056. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16057. import { Scene } from "babylonjs/scene";
  16058. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16059. import { Animation } from "babylonjs/Animations/animation";
  16060. /**
  16061. * Interface representing a particle system in Babylon.js.
  16062. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16063. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16064. */
  16065. export interface IParticleSystem {
  16066. /**
  16067. * List of animations used by the particle system.
  16068. */
  16069. animations: Animation[];
  16070. /**
  16071. * The id of the Particle system.
  16072. */
  16073. id: string;
  16074. /**
  16075. * The name of the Particle system.
  16076. */
  16077. name: string;
  16078. /**
  16079. * The emitter represents the Mesh or position we are attaching the particle system to.
  16080. */
  16081. emitter: Nullable<AbstractMesh | Vector3>;
  16082. /**
  16083. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16084. */
  16085. isBillboardBased: boolean;
  16086. /**
  16087. * The rendering group used by the Particle system to chose when to render.
  16088. */
  16089. renderingGroupId: number;
  16090. /**
  16091. * The layer mask we are rendering the particles through.
  16092. */
  16093. layerMask: number;
  16094. /**
  16095. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16096. */
  16097. updateSpeed: number;
  16098. /**
  16099. * The amount of time the particle system is running (depends of the overall update speed).
  16100. */
  16101. targetStopDuration: number;
  16102. /**
  16103. * The texture used to render each particle. (this can be a spritesheet)
  16104. */
  16105. particleTexture: Nullable<Texture>;
  16106. /**
  16107. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16108. */
  16109. blendMode: number;
  16110. /**
  16111. * Minimum life time of emitting particles.
  16112. */
  16113. minLifeTime: number;
  16114. /**
  16115. * Maximum life time of emitting particles.
  16116. */
  16117. maxLifeTime: number;
  16118. /**
  16119. * Minimum Size of emitting particles.
  16120. */
  16121. minSize: number;
  16122. /**
  16123. * Maximum Size of emitting particles.
  16124. */
  16125. maxSize: number;
  16126. /**
  16127. * Minimum scale of emitting particles on X axis.
  16128. */
  16129. minScaleX: number;
  16130. /**
  16131. * Maximum scale of emitting particles on X axis.
  16132. */
  16133. maxScaleX: number;
  16134. /**
  16135. * Minimum scale of emitting particles on Y axis.
  16136. */
  16137. minScaleY: number;
  16138. /**
  16139. * Maximum scale of emitting particles on Y axis.
  16140. */
  16141. maxScaleY: number;
  16142. /**
  16143. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16144. */
  16145. color1: Color4;
  16146. /**
  16147. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16148. */
  16149. color2: Color4;
  16150. /**
  16151. * Color the particle will have at the end of its lifetime.
  16152. */
  16153. colorDead: Color4;
  16154. /**
  16155. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16156. */
  16157. emitRate: number;
  16158. /**
  16159. * You can use gravity if you want to give an orientation to your particles.
  16160. */
  16161. gravity: Vector3;
  16162. /**
  16163. * Minimum power of emitting particles.
  16164. */
  16165. minEmitPower: number;
  16166. /**
  16167. * Maximum power of emitting particles.
  16168. */
  16169. maxEmitPower: number;
  16170. /**
  16171. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16172. */
  16173. minAngularSpeed: number;
  16174. /**
  16175. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16176. */
  16177. maxAngularSpeed: number;
  16178. /**
  16179. * Gets or sets the minimal initial rotation in radians.
  16180. */
  16181. minInitialRotation: number;
  16182. /**
  16183. * Gets or sets the maximal initial rotation in radians.
  16184. */
  16185. maxInitialRotation: number;
  16186. /**
  16187. * The particle emitter type defines the emitter used by the particle system.
  16188. * It can be for example box, sphere, or cone...
  16189. */
  16190. particleEmitterType: Nullable<IParticleEmitterType>;
  16191. /**
  16192. * Defines the delay in milliseconds before starting the system (0 by default)
  16193. */
  16194. startDelay: number;
  16195. /**
  16196. * 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
  16197. */
  16198. preWarmCycles: number;
  16199. /**
  16200. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16201. */
  16202. preWarmStepOffset: number;
  16203. /**
  16204. * 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)
  16205. */
  16206. spriteCellChangeSpeed: number;
  16207. /**
  16208. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16209. */
  16210. startSpriteCellID: number;
  16211. /**
  16212. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16213. */
  16214. endSpriteCellID: number;
  16215. /**
  16216. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16217. */
  16218. spriteCellWidth: number;
  16219. /**
  16220. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16221. */
  16222. spriteCellHeight: number;
  16223. /**
  16224. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16225. */
  16226. spriteRandomStartCell: boolean;
  16227. /**
  16228. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16229. */
  16230. isAnimationSheetEnabled: boolean;
  16231. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16232. translationPivot: Vector2;
  16233. /**
  16234. * Gets or sets a texture used to add random noise to particle positions
  16235. */
  16236. noiseTexture: Nullable<BaseTexture>;
  16237. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16238. noiseStrength: Vector3;
  16239. /**
  16240. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16241. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16242. */
  16243. billboardMode: number;
  16244. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16245. limitVelocityDamping: number;
  16246. /**
  16247. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16248. */
  16249. beginAnimationOnStart: boolean;
  16250. /**
  16251. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16252. */
  16253. beginAnimationFrom: number;
  16254. /**
  16255. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16256. */
  16257. beginAnimationTo: number;
  16258. /**
  16259. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16260. */
  16261. beginAnimationLoop: boolean;
  16262. /**
  16263. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16264. */
  16265. disposeOnStop: boolean;
  16266. /**
  16267. * Gets the maximum number of particles active at the same time.
  16268. * @returns The max number of active particles.
  16269. */
  16270. getCapacity(): number;
  16271. /**
  16272. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16273. * @returns True if it has been started, otherwise false.
  16274. */
  16275. isStarted(): boolean;
  16276. /**
  16277. * Animates the particle system for this frame.
  16278. */
  16279. animate(): void;
  16280. /**
  16281. * Renders the particle system in its current state.
  16282. * @returns the current number of particles
  16283. */
  16284. render(): number;
  16285. /**
  16286. * Dispose the particle system and frees its associated resources.
  16287. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16288. */
  16289. dispose(disposeTexture?: boolean): void;
  16290. /**
  16291. * Clones the particle system.
  16292. * @param name The name of the cloned object
  16293. * @param newEmitter The new emitter to use
  16294. * @returns the cloned particle system
  16295. */
  16296. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16297. /**
  16298. * Serializes the particle system to a JSON object.
  16299. * @returns the JSON object
  16300. */
  16301. serialize(): any;
  16302. /**
  16303. * Rebuild the particle system
  16304. */
  16305. rebuild(): void;
  16306. /**
  16307. * Starts the particle system and begins to emit
  16308. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16309. */
  16310. start(delay?: number): void;
  16311. /**
  16312. * Stops the particle system.
  16313. */
  16314. stop(): void;
  16315. /**
  16316. * Remove all active particles
  16317. */
  16318. reset(): void;
  16319. /**
  16320. * Is this system ready to be used/rendered
  16321. * @return true if the system is ready
  16322. */
  16323. isReady(): boolean;
  16324. /**
  16325. * Adds a new color gradient
  16326. * @param gradient defines the gradient to use (between 0 and 1)
  16327. * @param color1 defines the color to affect to the specified gradient
  16328. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16329. * @returns the current particle system
  16330. */
  16331. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16332. /**
  16333. * Remove a specific color gradient
  16334. * @param gradient defines the gradient to remove
  16335. * @returns the current particle system
  16336. */
  16337. removeColorGradient(gradient: number): IParticleSystem;
  16338. /**
  16339. * Adds a new size gradient
  16340. * @param gradient defines the gradient to use (between 0 and 1)
  16341. * @param factor defines the size factor to affect to the specified gradient
  16342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16343. * @returns the current particle system
  16344. */
  16345. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16346. /**
  16347. * Remove a specific size gradient
  16348. * @param gradient defines the gradient to remove
  16349. * @returns the current particle system
  16350. */
  16351. removeSizeGradient(gradient: number): IParticleSystem;
  16352. /**
  16353. * Gets the current list of color gradients.
  16354. * You must use addColorGradient and removeColorGradient to udpate this list
  16355. * @returns the list of color gradients
  16356. */
  16357. getColorGradients(): Nullable<Array<ColorGradient>>;
  16358. /**
  16359. * Gets the current list of size gradients.
  16360. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16361. * @returns the list of size gradients
  16362. */
  16363. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16364. /**
  16365. * Gets the current list of angular speed gradients.
  16366. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16367. * @returns the list of angular speed gradients
  16368. */
  16369. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16370. /**
  16371. * Adds a new angular speed gradient
  16372. * @param gradient defines the gradient to use (between 0 and 1)
  16373. * @param factor defines the angular speed to affect to the specified gradient
  16374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16375. * @returns the current particle system
  16376. */
  16377. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16378. /**
  16379. * Remove a specific angular speed gradient
  16380. * @param gradient defines the gradient to remove
  16381. * @returns the current particle system
  16382. */
  16383. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16384. /**
  16385. * Gets the current list of velocity gradients.
  16386. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16387. * @returns the list of velocity gradients
  16388. */
  16389. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16390. /**
  16391. * Adds a new velocity gradient
  16392. * @param gradient defines the gradient to use (between 0 and 1)
  16393. * @param factor defines the velocity to affect to the specified gradient
  16394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16395. * @returns the current particle system
  16396. */
  16397. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16398. /**
  16399. * Remove a specific velocity gradient
  16400. * @param gradient defines the gradient to remove
  16401. * @returns the current particle system
  16402. */
  16403. removeVelocityGradient(gradient: number): IParticleSystem;
  16404. /**
  16405. * Gets the current list of limit velocity gradients.
  16406. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16407. * @returns the list of limit velocity gradients
  16408. */
  16409. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16410. /**
  16411. * Adds a new limit velocity gradient
  16412. * @param gradient defines the gradient to use (between 0 and 1)
  16413. * @param factor defines the limit velocity to affect to the specified gradient
  16414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16415. * @returns the current particle system
  16416. */
  16417. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16418. /**
  16419. * Remove a specific limit velocity gradient
  16420. * @param gradient defines the gradient to remove
  16421. * @returns the current particle system
  16422. */
  16423. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16424. /**
  16425. * Adds a new drag gradient
  16426. * @param gradient defines the gradient to use (between 0 and 1)
  16427. * @param factor defines the drag to affect to the specified gradient
  16428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16429. * @returns the current particle system
  16430. */
  16431. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16432. /**
  16433. * Remove a specific drag gradient
  16434. * @param gradient defines the gradient to remove
  16435. * @returns the current particle system
  16436. */
  16437. removeDragGradient(gradient: number): IParticleSystem;
  16438. /**
  16439. * Gets the current list of drag gradients.
  16440. * You must use addDragGradient and removeDragGradient to udpate this list
  16441. * @returns the list of drag gradients
  16442. */
  16443. getDragGradients(): Nullable<Array<FactorGradient>>;
  16444. /**
  16445. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16446. * @param gradient defines the gradient to use (between 0 and 1)
  16447. * @param factor defines the emit rate to affect to the specified gradient
  16448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16449. * @returns the current particle system
  16450. */
  16451. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16452. /**
  16453. * Remove a specific emit rate gradient
  16454. * @param gradient defines the gradient to remove
  16455. * @returns the current particle system
  16456. */
  16457. removeEmitRateGradient(gradient: number): IParticleSystem;
  16458. /**
  16459. * Gets the current list of emit rate gradients.
  16460. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16461. * @returns the list of emit rate gradients
  16462. */
  16463. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16464. /**
  16465. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16466. * @param gradient defines the gradient to use (between 0 and 1)
  16467. * @param factor defines the start size to affect to the specified gradient
  16468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16469. * @returns the current particle system
  16470. */
  16471. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16472. /**
  16473. * Remove a specific start size gradient
  16474. * @param gradient defines the gradient to remove
  16475. * @returns the current particle system
  16476. */
  16477. removeStartSizeGradient(gradient: number): IParticleSystem;
  16478. /**
  16479. * Gets the current list of start size gradients.
  16480. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16481. * @returns the list of start size gradients
  16482. */
  16483. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16484. /**
  16485. * Adds a new life time gradient
  16486. * @param gradient defines the gradient to use (between 0 and 1)
  16487. * @param factor defines the life time factor to affect to the specified gradient
  16488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16489. * @returns the current particle system
  16490. */
  16491. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16492. /**
  16493. * Remove a specific life time gradient
  16494. * @param gradient defines the gradient to remove
  16495. * @returns the current particle system
  16496. */
  16497. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16498. /**
  16499. * Gets the current list of life time gradients.
  16500. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16501. * @returns the list of life time gradients
  16502. */
  16503. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Gets the current list of color gradients.
  16506. * You must use addColorGradient and removeColorGradient to udpate this list
  16507. * @returns the list of color gradients
  16508. */
  16509. getColorGradients(): Nullable<Array<ColorGradient>>;
  16510. /**
  16511. * Adds a new ramp gradient used to remap particle colors
  16512. * @param gradient defines the gradient to use (between 0 and 1)
  16513. * @param color defines the color to affect to the specified gradient
  16514. * @returns the current particle system
  16515. */
  16516. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16517. /**
  16518. * Gets the current list of ramp gradients.
  16519. * You must use addRampGradient and removeRampGradient to udpate this list
  16520. * @returns the list of ramp gradients
  16521. */
  16522. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16523. /** Gets or sets a boolean indicating that ramp gradients must be used
  16524. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16525. */
  16526. useRampGradients: boolean;
  16527. /**
  16528. * Adds a new color remap gradient
  16529. * @param gradient defines the gradient to use (between 0 and 1)
  16530. * @param min defines the color remap minimal range
  16531. * @param max defines the color remap maximal range
  16532. * @returns the current particle system
  16533. */
  16534. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16535. /**
  16536. * Gets the current list of color remap gradients.
  16537. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16538. * @returns the list of color remap gradients
  16539. */
  16540. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16541. /**
  16542. * Adds a new alpha remap gradient
  16543. * @param gradient defines the gradient to use (between 0 and 1)
  16544. * @param min defines the alpha remap minimal range
  16545. * @param max defines the alpha remap maximal range
  16546. * @returns the current particle system
  16547. */
  16548. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16549. /**
  16550. * Gets the current list of alpha remap gradients.
  16551. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16552. * @returns the list of alpha remap gradients
  16553. */
  16554. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16555. /**
  16556. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16559. * @returns the emitter
  16560. */
  16561. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16562. /**
  16563. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16564. * @param radius The radius of the hemisphere to emit from
  16565. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16566. * @returns the emitter
  16567. */
  16568. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16569. /**
  16570. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16571. * @param radius The radius of the sphere to emit from
  16572. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16573. * @returns the emitter
  16574. */
  16575. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16576. /**
  16577. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16578. * @param radius The radius of the sphere to emit from
  16579. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16580. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16581. * @returns the emitter
  16582. */
  16583. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16584. /**
  16585. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16586. * @param radius The radius of the emission cylinder
  16587. * @param height The height of the emission cylinder
  16588. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16589. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16590. * @returns the emitter
  16591. */
  16592. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16593. /**
  16594. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16595. * @param radius The radius of the cylinder to emit from
  16596. * @param height The height of the emission cylinder
  16597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16600. * @returns the emitter
  16601. */
  16602. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16603. /**
  16604. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16605. * @param radius The radius of the cone to emit from
  16606. * @param angle The base angle of the cone
  16607. * @returns the emitter
  16608. */
  16609. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16610. /**
  16611. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16614. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16615. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16616. * @returns the emitter
  16617. */
  16618. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16619. /**
  16620. * Get hosting scene
  16621. * @returns the scene
  16622. */
  16623. getScene(): Scene;
  16624. }
  16625. }
  16626. declare module "babylonjs/Meshes/instancedMesh" {
  16627. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16628. import { Vector3 } from "babylonjs/Maths/math";
  16629. import { Camera } from "babylonjs/Cameras/camera";
  16630. import { Node } from "babylonjs/node";
  16631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16632. import { Mesh } from "babylonjs/Meshes/mesh";
  16633. import { Material } from "babylonjs/Materials/material";
  16634. import { Skeleton } from "babylonjs/Bones/skeleton";
  16635. /**
  16636. * Creates an instance based on a source mesh.
  16637. */
  16638. export class InstancedMesh extends AbstractMesh {
  16639. private _sourceMesh;
  16640. private _currentLOD;
  16641. /** @hidden */
  16642. _indexInSourceMeshInstanceArray: number;
  16643. constructor(name: string, source: Mesh);
  16644. /**
  16645. * Returns the string "InstancedMesh".
  16646. */
  16647. getClassName(): string;
  16648. /**
  16649. * If the source mesh receives shadows
  16650. */
  16651. readonly receiveShadows: boolean;
  16652. /**
  16653. * The material of the source mesh
  16654. */
  16655. readonly material: Nullable<Material>;
  16656. /**
  16657. * Visibility of the source mesh
  16658. */
  16659. readonly visibility: number;
  16660. /**
  16661. * Skeleton of the source mesh
  16662. */
  16663. readonly skeleton: Nullable<Skeleton>;
  16664. /**
  16665. * Rendering ground id of the source mesh
  16666. */
  16667. renderingGroupId: number;
  16668. /**
  16669. * Returns the total number of vertices (integer).
  16670. */
  16671. getTotalVertices(): number;
  16672. /**
  16673. * Returns a positive integer : the total number of indices in this mesh geometry.
  16674. * @returns the numner of indices or zero if the mesh has no geometry.
  16675. */
  16676. getTotalIndices(): number;
  16677. /**
  16678. * The source mesh of the instance
  16679. */
  16680. readonly sourceMesh: Mesh;
  16681. /**
  16682. * Is this node ready to be used/rendered
  16683. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16684. * @return {boolean} is it ready
  16685. */
  16686. isReady(completeCheck?: boolean): boolean;
  16687. /**
  16688. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16689. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16690. * @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.
  16691. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16692. */
  16693. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16694. /**
  16695. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16696. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16697. * The `data` are either a numeric array either a Float32Array.
  16698. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16699. * 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).
  16700. * Note that a new underlying VertexBuffer object is created each call.
  16701. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16702. *
  16703. * Possible `kind` values :
  16704. * - VertexBuffer.PositionKind
  16705. * - VertexBuffer.UVKind
  16706. * - VertexBuffer.UV2Kind
  16707. * - VertexBuffer.UV3Kind
  16708. * - VertexBuffer.UV4Kind
  16709. * - VertexBuffer.UV5Kind
  16710. * - VertexBuffer.UV6Kind
  16711. * - VertexBuffer.ColorKind
  16712. * - VertexBuffer.MatricesIndicesKind
  16713. * - VertexBuffer.MatricesIndicesExtraKind
  16714. * - VertexBuffer.MatricesWeightsKind
  16715. * - VertexBuffer.MatricesWeightsExtraKind
  16716. *
  16717. * Returns the Mesh.
  16718. */
  16719. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16720. /**
  16721. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16722. * If the mesh has no geometry, it is simply returned as it is.
  16723. * The `data` are either a numeric array either a Float32Array.
  16724. * No new underlying VertexBuffer object is created.
  16725. * 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.
  16726. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16727. *
  16728. * Possible `kind` values :
  16729. * - VertexBuffer.PositionKind
  16730. * - VertexBuffer.UVKind
  16731. * - VertexBuffer.UV2Kind
  16732. * - VertexBuffer.UV3Kind
  16733. * - VertexBuffer.UV4Kind
  16734. * - VertexBuffer.UV5Kind
  16735. * - VertexBuffer.UV6Kind
  16736. * - VertexBuffer.ColorKind
  16737. * - VertexBuffer.MatricesIndicesKind
  16738. * - VertexBuffer.MatricesIndicesExtraKind
  16739. * - VertexBuffer.MatricesWeightsKind
  16740. * - VertexBuffer.MatricesWeightsExtraKind
  16741. *
  16742. * Returns the Mesh.
  16743. */
  16744. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16745. /**
  16746. * Sets the mesh indices.
  16747. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16748. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16749. * This method creates a new index buffer each call.
  16750. * Returns the Mesh.
  16751. */
  16752. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16753. /**
  16754. * Boolean : True if the mesh owns the requested kind of data.
  16755. */
  16756. isVerticesDataPresent(kind: string): boolean;
  16757. /**
  16758. * Returns an array of indices (IndicesArray).
  16759. */
  16760. getIndices(): Nullable<IndicesArray>;
  16761. readonly _positions: Nullable<Vector3[]>;
  16762. /**
  16763. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16764. * This means the mesh underlying bounding box and sphere are recomputed.
  16765. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16766. * @returns the current mesh
  16767. */
  16768. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16769. /** @hidden */
  16770. _preActivate(): InstancedMesh;
  16771. /** @hidden */
  16772. _activate(renderId: number): InstancedMesh;
  16773. /**
  16774. * Returns the current associated LOD AbstractMesh.
  16775. */
  16776. getLOD(camera: Camera): AbstractMesh;
  16777. /** @hidden */
  16778. _syncSubMeshes(): InstancedMesh;
  16779. /** @hidden */
  16780. _generatePointsArray(): boolean;
  16781. /**
  16782. * Creates a new InstancedMesh from the current mesh.
  16783. * - name (string) : the cloned mesh name
  16784. * - newParent (optional Node) : the optional Node to parent the clone to.
  16785. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16786. *
  16787. * Returns the clone.
  16788. */
  16789. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16790. /**
  16791. * Disposes the InstancedMesh.
  16792. * Returns nothing.
  16793. */
  16794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16795. }
  16796. }
  16797. declare module "babylonjs/Materials/shaderMaterial" {
  16798. import { Scene } from "babylonjs/scene";
  16799. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16801. import { Mesh } from "babylonjs/Meshes/mesh";
  16802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16803. import { Texture } from "babylonjs/Materials/Textures/texture";
  16804. import { Material } from "babylonjs/Materials/material";
  16805. /**
  16806. * Defines the options associated with the creation of a shader material.
  16807. */
  16808. export interface IShaderMaterialOptions {
  16809. /**
  16810. * Does the material work in alpha blend mode
  16811. */
  16812. needAlphaBlending: boolean;
  16813. /**
  16814. * Does the material work in alpha test mode
  16815. */
  16816. needAlphaTesting: boolean;
  16817. /**
  16818. * The list of attribute names used in the shader
  16819. */
  16820. attributes: string[];
  16821. /**
  16822. * The list of unifrom names used in the shader
  16823. */
  16824. uniforms: string[];
  16825. /**
  16826. * The list of UBO names used in the shader
  16827. */
  16828. uniformBuffers: string[];
  16829. /**
  16830. * The list of sampler names used in the shader
  16831. */
  16832. samplers: string[];
  16833. /**
  16834. * The list of defines used in the shader
  16835. */
  16836. defines: string[];
  16837. }
  16838. /**
  16839. * 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.
  16840. *
  16841. * This returned material effects how the mesh will look based on the code in the shaders.
  16842. *
  16843. * @see http://doc.babylonjs.com/how_to/shader_material
  16844. */
  16845. export class ShaderMaterial extends Material {
  16846. private _shaderPath;
  16847. private _options;
  16848. private _textures;
  16849. private _textureArrays;
  16850. private _floats;
  16851. private _ints;
  16852. private _floatsArrays;
  16853. private _colors3;
  16854. private _colors3Arrays;
  16855. private _colors4;
  16856. private _vectors2;
  16857. private _vectors3;
  16858. private _vectors4;
  16859. private _matrices;
  16860. private _matrices3x3;
  16861. private _matrices2x2;
  16862. private _vectors2Arrays;
  16863. private _vectors3Arrays;
  16864. private _cachedWorldViewMatrix;
  16865. private _renderId;
  16866. /**
  16867. * Instantiate a new shader material.
  16868. * 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.
  16869. * This returned material effects how the mesh will look based on the code in the shaders.
  16870. * @see http://doc.babylonjs.com/how_to/shader_material
  16871. * @param name Define the name of the material in the scene
  16872. * @param scene Define the scene the material belongs to
  16873. * @param shaderPath Defines the route to the shader code in one of three ways:
  16874. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16875. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16876. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16877. * @param options Define the options used to create the shader
  16878. */
  16879. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16880. /**
  16881. * Gets the options used to compile the shader.
  16882. * They can be modified to trigger a new compilation
  16883. */
  16884. readonly options: IShaderMaterialOptions;
  16885. /**
  16886. * Gets the current class name of the material e.g. "ShaderMaterial"
  16887. * Mainly use in serialization.
  16888. * @returns the class name
  16889. */
  16890. getClassName(): string;
  16891. /**
  16892. * Specifies if the material will require alpha blending
  16893. * @returns a boolean specifying if alpha blending is needed
  16894. */
  16895. needAlphaBlending(): boolean;
  16896. /**
  16897. * Specifies if this material should be rendered in alpha test mode
  16898. * @returns a boolean specifying if an alpha test is needed.
  16899. */
  16900. needAlphaTesting(): boolean;
  16901. private _checkUniform;
  16902. /**
  16903. * Set a texture in the shader.
  16904. * @param name Define the name of the uniform samplers as defined in the shader
  16905. * @param texture Define the texture to bind to this sampler
  16906. * @return the material itself allowing "fluent" like uniform updates
  16907. */
  16908. setTexture(name: string, texture: Texture): ShaderMaterial;
  16909. /**
  16910. * Set a texture array in the shader.
  16911. * @param name Define the name of the uniform sampler array as defined in the shader
  16912. * @param textures Define the list of textures to bind to this sampler
  16913. * @return the material itself allowing "fluent" like uniform updates
  16914. */
  16915. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16916. /**
  16917. * Set a float in the shader.
  16918. * @param name Define the name of the uniform as defined in the shader
  16919. * @param value Define the value to give to the uniform
  16920. * @return the material itself allowing "fluent" like uniform updates
  16921. */
  16922. setFloat(name: string, value: number): ShaderMaterial;
  16923. /**
  16924. * Set a int in the shader.
  16925. * @param name Define the name of the uniform as defined in the shader
  16926. * @param value Define the value to give to the uniform
  16927. * @return the material itself allowing "fluent" like uniform updates
  16928. */
  16929. setInt(name: string, value: number): ShaderMaterial;
  16930. /**
  16931. * Set an array of floats in the shader.
  16932. * @param name Define the name of the uniform as defined in the shader
  16933. * @param value Define the value to give to the uniform
  16934. * @return the material itself allowing "fluent" like uniform updates
  16935. */
  16936. setFloats(name: string, value: number[]): ShaderMaterial;
  16937. /**
  16938. * Set a vec3 in the shader from a Color3.
  16939. * @param name Define the name of the uniform as defined in the shader
  16940. * @param value Define the value to give to the uniform
  16941. * @return the material itself allowing "fluent" like uniform updates
  16942. */
  16943. setColor3(name: string, value: Color3): ShaderMaterial;
  16944. /**
  16945. * Set a vec3 array in the shader from a Color3 array.
  16946. * @param name Define the name of the uniform as defined in the shader
  16947. * @param value Define the value to give to the uniform
  16948. * @return the material itself allowing "fluent" like uniform updates
  16949. */
  16950. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16951. /**
  16952. * Set a vec4 in the shader from a Color4.
  16953. * @param name Define the name of the uniform as defined in the shader
  16954. * @param value Define the value to give to the uniform
  16955. * @return the material itself allowing "fluent" like uniform updates
  16956. */
  16957. setColor4(name: string, value: Color4): ShaderMaterial;
  16958. /**
  16959. * Set a vec2 in the shader from a Vector2.
  16960. * @param name Define the name of the uniform as defined in the shader
  16961. * @param value Define the value to give to the uniform
  16962. * @return the material itself allowing "fluent" like uniform updates
  16963. */
  16964. setVector2(name: string, value: Vector2): ShaderMaterial;
  16965. /**
  16966. * Set a vec3 in the shader from a Vector3.
  16967. * @param name Define the name of the uniform as defined in the shader
  16968. * @param value Define the value to give to the uniform
  16969. * @return the material itself allowing "fluent" like uniform updates
  16970. */
  16971. setVector3(name: string, value: Vector3): ShaderMaterial;
  16972. /**
  16973. * Set a vec4 in the shader from a Vector4.
  16974. * @param name Define the name of the uniform as defined in the shader
  16975. * @param value Define the value to give to the uniform
  16976. * @return the material itself allowing "fluent" like uniform updates
  16977. */
  16978. setVector4(name: string, value: Vector4): ShaderMaterial;
  16979. /**
  16980. * Set a mat4 in the shader from a Matrix.
  16981. * @param name Define the name of the uniform as defined in the shader
  16982. * @param value Define the value to give to the uniform
  16983. * @return the material itself allowing "fluent" like uniform updates
  16984. */
  16985. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16986. /**
  16987. * Set a mat3 in the shader from a Float32Array.
  16988. * @param name Define the name of the uniform as defined in the shader
  16989. * @param value Define the value to give to the uniform
  16990. * @return the material itself allowing "fluent" like uniform updates
  16991. */
  16992. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16993. /**
  16994. * Set a mat2 in the shader from a Float32Array.
  16995. * @param name Define the name of the uniform as defined in the shader
  16996. * @param value Define the value to give to the uniform
  16997. * @return the material itself allowing "fluent" like uniform updates
  16998. */
  16999. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17000. /**
  17001. * Set a vec2 array in the shader from a number array.
  17002. * @param name Define the name of the uniform as defined in the shader
  17003. * @param value Define the value to give to the uniform
  17004. * @return the material itself allowing "fluent" like uniform updates
  17005. */
  17006. setArray2(name: string, value: number[]): ShaderMaterial;
  17007. /**
  17008. * Set a vec3 array in the shader from a number array.
  17009. * @param name Define the name of the uniform as defined in the shader
  17010. * @param value Define the value to give to the uniform
  17011. * @return the material itself allowing "fluent" like uniform updates
  17012. */
  17013. setArray3(name: string, value: number[]): ShaderMaterial;
  17014. private _checkCache;
  17015. /**
  17016. * Checks if the material is ready to render the requested mesh
  17017. * @param mesh Define the mesh to render
  17018. * @param useInstances Define whether or not the material is used with instances
  17019. * @returns true if ready, otherwise false
  17020. */
  17021. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17022. /**
  17023. * Binds the world matrix to the material
  17024. * @param world defines the world transformation matrix
  17025. */
  17026. bindOnlyWorldMatrix(world: Matrix): void;
  17027. /**
  17028. * Binds the material to the mesh
  17029. * @param world defines the world transformation matrix
  17030. * @param mesh defines the mesh to bind the material to
  17031. */
  17032. bind(world: Matrix, mesh?: Mesh): void;
  17033. /**
  17034. * Gets the active textures from the material
  17035. * @returns an array of textures
  17036. */
  17037. getActiveTextures(): BaseTexture[];
  17038. /**
  17039. * Specifies if the material uses a texture
  17040. * @param texture defines the texture to check against the material
  17041. * @returns a boolean specifying if the material uses the texture
  17042. */
  17043. hasTexture(texture: BaseTexture): boolean;
  17044. /**
  17045. * Makes a duplicate of the material, and gives it a new name
  17046. * @param name defines the new name for the duplicated material
  17047. * @returns the cloned material
  17048. */
  17049. clone(name: string): ShaderMaterial;
  17050. /**
  17051. * Disposes the material
  17052. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17053. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17054. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17055. */
  17056. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17057. /**
  17058. * Serializes this material in a JSON representation
  17059. * @returns the serialized material object
  17060. */
  17061. serialize(): any;
  17062. /**
  17063. * Creates a shader material from parsed shader material data
  17064. * @param source defines the JSON represnetation of the material
  17065. * @param scene defines the hosting scene
  17066. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17067. * @returns a new material
  17068. */
  17069. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17070. }
  17071. }
  17072. declare module "babylonjs/Shaders/color.fragment" {
  17073. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17074. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17075. /** @hidden */
  17076. export var colorPixelShader: {
  17077. name: string;
  17078. shader: string;
  17079. };
  17080. }
  17081. declare module "babylonjs/Shaders/color.vertex" {
  17082. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17083. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17084. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17085. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17086. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17087. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17088. /** @hidden */
  17089. export var colorVertexShader: {
  17090. name: string;
  17091. shader: string;
  17092. };
  17093. }
  17094. declare module "babylonjs/Meshes/linesMesh" {
  17095. import { Nullable } from "babylonjs/types";
  17096. import { Scene } from "babylonjs/scene";
  17097. import { Color3 } from "babylonjs/Maths/math";
  17098. import { Node } from "babylonjs/node";
  17099. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17100. import { Mesh } from "babylonjs/Meshes/mesh";
  17101. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17102. import { Effect } from "babylonjs/Materials/effect";
  17103. import { Material } from "babylonjs/Materials/material";
  17104. import "babylonjs/Shaders/color.fragment";
  17105. import "babylonjs/Shaders/color.vertex";
  17106. /**
  17107. * Line mesh
  17108. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17109. */
  17110. export class LinesMesh extends Mesh {
  17111. /**
  17112. * If vertex color should be applied to the mesh
  17113. */
  17114. useVertexColor?: boolean | undefined;
  17115. /**
  17116. * If vertex alpha should be applied to the mesh
  17117. */
  17118. useVertexAlpha?: boolean | undefined;
  17119. /**
  17120. * Color of the line (Default: White)
  17121. */
  17122. color: Color3;
  17123. /**
  17124. * Alpha of the line (Default: 1)
  17125. */
  17126. alpha: number;
  17127. /**
  17128. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17129. * This margin is expressed in world space coordinates, so its value may vary.
  17130. * Default value is 0.1
  17131. */
  17132. intersectionThreshold: number;
  17133. private _colorShader;
  17134. /**
  17135. * Creates a new LinesMesh
  17136. * @param name defines the name
  17137. * @param scene defines the hosting scene
  17138. * @param parent defines the parent mesh if any
  17139. * @param source defines the optional source LinesMesh used to clone data from
  17140. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17141. * When false, achieved by calling a clone(), also passing False.
  17142. * This will make creation of children, recursive.
  17143. * @param useVertexColor defines if this LinesMesh supports vertex color
  17144. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17145. */
  17146. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17147. /**
  17148. * If vertex color should be applied to the mesh
  17149. */
  17150. useVertexColor?: boolean | undefined,
  17151. /**
  17152. * If vertex alpha should be applied to the mesh
  17153. */
  17154. useVertexAlpha?: boolean | undefined);
  17155. private _addClipPlaneDefine;
  17156. private _removeClipPlaneDefine;
  17157. isReady(): boolean;
  17158. /**
  17159. * Returns the string "LineMesh"
  17160. */
  17161. getClassName(): string;
  17162. /**
  17163. * @hidden
  17164. */
  17165. /**
  17166. * @hidden
  17167. */
  17168. material: Material;
  17169. /**
  17170. * @hidden
  17171. */
  17172. readonly checkCollisions: boolean;
  17173. /** @hidden */
  17174. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17175. /** @hidden */
  17176. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17177. /**
  17178. * Disposes of the line mesh
  17179. * @param doNotRecurse If children should be disposed
  17180. */
  17181. dispose(doNotRecurse?: boolean): void;
  17182. /**
  17183. * Returns a new LineMesh object cloned from the current one.
  17184. */
  17185. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17186. /**
  17187. * Creates a new InstancedLinesMesh object from the mesh model.
  17188. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17189. * @param name defines the name of the new instance
  17190. * @returns a new InstancedLinesMesh
  17191. */
  17192. createInstance(name: string): InstancedLinesMesh;
  17193. }
  17194. /**
  17195. * Creates an instance based on a source LinesMesh
  17196. */
  17197. export class InstancedLinesMesh extends InstancedMesh {
  17198. /**
  17199. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17200. * This margin is expressed in world space coordinates, so its value may vary.
  17201. * Initilized with the intersectionThreshold value of the source LinesMesh
  17202. */
  17203. intersectionThreshold: number;
  17204. constructor(name: string, source: LinesMesh);
  17205. /**
  17206. * Returns the string "InstancedLinesMesh".
  17207. */
  17208. getClassName(): string;
  17209. }
  17210. }
  17211. declare module "babylonjs/Shaders/line.fragment" {
  17212. /** @hidden */
  17213. export var linePixelShader: {
  17214. name: string;
  17215. shader: string;
  17216. };
  17217. }
  17218. declare module "babylonjs/Shaders/line.vertex" {
  17219. /** @hidden */
  17220. export var lineVertexShader: {
  17221. name: string;
  17222. shader: string;
  17223. };
  17224. }
  17225. declare module "babylonjs/Rendering/edgesRenderer" {
  17226. import { Nullable } from "babylonjs/types";
  17227. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17229. import { Vector3 } from "babylonjs/Maths/math";
  17230. import { IDisposable } from "babylonjs/scene";
  17231. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17232. import "babylonjs/Shaders/line.fragment";
  17233. import "babylonjs/Shaders/line.vertex";
  17234. module "babylonjs/Meshes/abstractMesh" {
  17235. interface AbstractMesh {
  17236. /**
  17237. * Disables the mesh edge rendering mode
  17238. * @returns the currentAbstractMesh
  17239. */
  17240. disableEdgesRendering(): AbstractMesh;
  17241. /**
  17242. * Enables the edge rendering mode on the mesh.
  17243. * This mode makes the mesh edges visible
  17244. * @param epsilon defines the maximal distance between two angles to detect a face
  17245. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17246. * @returns the currentAbstractMesh
  17247. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17248. */
  17249. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17250. /**
  17251. * Gets the edgesRenderer associated with the mesh
  17252. */
  17253. edgesRenderer: Nullable<EdgesRenderer>;
  17254. }
  17255. }
  17256. module "babylonjs/Meshes/linesMesh" {
  17257. interface LinesMesh {
  17258. /**
  17259. * Enables the edge rendering mode on the mesh.
  17260. * This mode makes the mesh edges visible
  17261. * @param epsilon defines the maximal distance between two angles to detect a face
  17262. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17263. * @returns the currentAbstractMesh
  17264. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17265. */
  17266. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17267. }
  17268. }
  17269. module "babylonjs/Meshes/linesMesh" {
  17270. interface InstancedLinesMesh {
  17271. /**
  17272. * Enables the edge rendering mode on the mesh.
  17273. * This mode makes the mesh edges visible
  17274. * @param epsilon defines the maximal distance between two angles to detect a face
  17275. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17276. * @returns the current InstancedLinesMesh
  17277. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17278. */
  17279. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17280. }
  17281. }
  17282. /**
  17283. * Defines the minimum contract an Edges renderer should follow.
  17284. */
  17285. export interface IEdgesRenderer extends IDisposable {
  17286. /**
  17287. * Gets or sets a boolean indicating if the edgesRenderer is active
  17288. */
  17289. isEnabled: boolean;
  17290. /**
  17291. * Renders the edges of the attached mesh,
  17292. */
  17293. render(): void;
  17294. /**
  17295. * Checks wether or not the edges renderer is ready to render.
  17296. * @return true if ready, otherwise false.
  17297. */
  17298. isReady(): boolean;
  17299. }
  17300. /**
  17301. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17302. */
  17303. export class EdgesRenderer implements IEdgesRenderer {
  17304. /**
  17305. * Define the size of the edges with an orthographic camera
  17306. */
  17307. edgesWidthScalerForOrthographic: number;
  17308. /**
  17309. * Define the size of the edges with a perspective camera
  17310. */
  17311. edgesWidthScalerForPerspective: number;
  17312. protected _source: AbstractMesh;
  17313. protected _linesPositions: number[];
  17314. protected _linesNormals: number[];
  17315. protected _linesIndices: number[];
  17316. protected _epsilon: number;
  17317. protected _indicesCount: number;
  17318. protected _lineShader: ShaderMaterial;
  17319. protected _ib: WebGLBuffer;
  17320. protected _buffers: {
  17321. [key: string]: Nullable<VertexBuffer>;
  17322. };
  17323. protected _checkVerticesInsteadOfIndices: boolean;
  17324. private _meshRebuildObserver;
  17325. private _meshDisposeObserver;
  17326. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17327. isEnabled: boolean;
  17328. /**
  17329. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17330. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17331. * @param source Mesh used to create edges
  17332. * @param epsilon sum of angles in adjacency to check for edge
  17333. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17334. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17335. */
  17336. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17337. protected _prepareRessources(): void;
  17338. /** @hidden */
  17339. _rebuild(): void;
  17340. /**
  17341. * Releases the required resources for the edges renderer
  17342. */
  17343. dispose(): void;
  17344. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17345. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17346. /**
  17347. * Checks if the pair of p0 and p1 is en edge
  17348. * @param faceIndex
  17349. * @param edge
  17350. * @param faceNormals
  17351. * @param p0
  17352. * @param p1
  17353. * @private
  17354. */
  17355. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17356. /**
  17357. * push line into the position, normal and index buffer
  17358. * @protected
  17359. */
  17360. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17361. /**
  17362. * Generates lines edges from adjacencjes
  17363. * @private
  17364. */
  17365. _generateEdgesLines(): void;
  17366. /**
  17367. * Checks wether or not the edges renderer is ready to render.
  17368. * @return true if ready, otherwise false.
  17369. */
  17370. isReady(): boolean;
  17371. /**
  17372. * Renders the edges of the attached mesh,
  17373. */
  17374. render(): void;
  17375. }
  17376. /**
  17377. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17378. */
  17379. export class LineEdgesRenderer extends EdgesRenderer {
  17380. /**
  17381. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17382. * @param source LineMesh used to generate edges
  17383. * @param epsilon not important (specified angle for edge detection)
  17384. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17385. */
  17386. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17387. /**
  17388. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17389. */
  17390. _generateEdgesLines(): void;
  17391. }
  17392. }
  17393. declare module "babylonjs/Rendering/renderingGroup" {
  17394. import { SmartArray } from "babylonjs/Misc/smartArray";
  17395. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17397. import { Nullable } from "babylonjs/types";
  17398. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17399. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17400. import { Material } from "babylonjs/Materials/material";
  17401. import { Scene } from "babylonjs/scene";
  17402. /**
  17403. * This represents the object necessary to create a rendering group.
  17404. * This is exclusively used and created by the rendering manager.
  17405. * To modify the behavior, you use the available helpers in your scene or meshes.
  17406. * @hidden
  17407. */
  17408. export class RenderingGroup {
  17409. index: number;
  17410. private _scene;
  17411. private _opaqueSubMeshes;
  17412. private _transparentSubMeshes;
  17413. private _alphaTestSubMeshes;
  17414. private _depthOnlySubMeshes;
  17415. private _particleSystems;
  17416. private _spriteManagers;
  17417. private _opaqueSortCompareFn;
  17418. private _alphaTestSortCompareFn;
  17419. private _transparentSortCompareFn;
  17420. private _renderOpaque;
  17421. private _renderAlphaTest;
  17422. private _renderTransparent;
  17423. private _edgesRenderers;
  17424. onBeforeTransparentRendering: () => void;
  17425. /**
  17426. * Set the opaque sort comparison function.
  17427. * If null the sub meshes will be render in the order they were created
  17428. */
  17429. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17430. /**
  17431. * Set the alpha test sort comparison function.
  17432. * If null the sub meshes will be render in the order they were created
  17433. */
  17434. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17435. /**
  17436. * Set the transparent sort comparison function.
  17437. * If null the sub meshes will be render in the order they were created
  17438. */
  17439. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17440. /**
  17441. * Creates a new rendering group.
  17442. * @param index The rendering group index
  17443. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17444. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17445. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17446. */
  17447. 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>);
  17448. /**
  17449. * Render all the sub meshes contained in the group.
  17450. * @param customRenderFunction Used to override the default render behaviour of the group.
  17451. * @returns true if rendered some submeshes.
  17452. */
  17453. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17454. /**
  17455. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17456. * @param subMeshes The submeshes to render
  17457. */
  17458. private renderOpaqueSorted;
  17459. /**
  17460. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17461. * @param subMeshes The submeshes to render
  17462. */
  17463. private renderAlphaTestSorted;
  17464. /**
  17465. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17466. * @param subMeshes The submeshes to render
  17467. */
  17468. private renderTransparentSorted;
  17469. /**
  17470. * Renders the submeshes in a specified order.
  17471. * @param subMeshes The submeshes to sort before render
  17472. * @param sortCompareFn The comparison function use to sort
  17473. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17474. * @param transparent Specifies to activate blending if true
  17475. */
  17476. private static renderSorted;
  17477. /**
  17478. * Renders the submeshes in the order they were dispatched (no sort applied).
  17479. * @param subMeshes The submeshes to render
  17480. */
  17481. private static renderUnsorted;
  17482. /**
  17483. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17484. * are rendered back to front if in the same alpha index.
  17485. *
  17486. * @param a The first submesh
  17487. * @param b The second submesh
  17488. * @returns The result of the comparison
  17489. */
  17490. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17491. /**
  17492. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17493. * are rendered back to front.
  17494. *
  17495. * @param a The first submesh
  17496. * @param b The second submesh
  17497. * @returns The result of the comparison
  17498. */
  17499. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17500. /**
  17501. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17502. * are rendered front to back (prevent overdraw).
  17503. *
  17504. * @param a The first submesh
  17505. * @param b The second submesh
  17506. * @returns The result of the comparison
  17507. */
  17508. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17509. /**
  17510. * Resets the different lists of submeshes to prepare a new frame.
  17511. */
  17512. prepare(): void;
  17513. dispose(): void;
  17514. /**
  17515. * Inserts the submesh in its correct queue depending on its material.
  17516. * @param subMesh The submesh to dispatch
  17517. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17518. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17519. */
  17520. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17521. dispatchSprites(spriteManager: ISpriteManager): void;
  17522. dispatchParticles(particleSystem: IParticleSystem): void;
  17523. private _renderParticles;
  17524. private _renderSprites;
  17525. }
  17526. }
  17527. declare module "babylonjs/Rendering/renderingManager" {
  17528. import { Nullable } from "babylonjs/types";
  17529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17530. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17531. import { SmartArray } from "babylonjs/Misc/smartArray";
  17532. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17533. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17534. import { Material } from "babylonjs/Materials/material";
  17535. import { Scene } from "babylonjs/scene";
  17536. import { Camera } from "babylonjs/Cameras/camera";
  17537. /**
  17538. * Interface describing the different options available in the rendering manager
  17539. * regarding Auto Clear between groups.
  17540. */
  17541. export interface IRenderingManagerAutoClearSetup {
  17542. /**
  17543. * Defines whether or not autoclear is enable.
  17544. */
  17545. autoClear: boolean;
  17546. /**
  17547. * Defines whether or not to autoclear the depth buffer.
  17548. */
  17549. depth: boolean;
  17550. /**
  17551. * Defines whether or not to autoclear the stencil buffer.
  17552. */
  17553. stencil: boolean;
  17554. }
  17555. /**
  17556. * This class is used by the onRenderingGroupObservable
  17557. */
  17558. export class RenderingGroupInfo {
  17559. /**
  17560. * The Scene that being rendered
  17561. */
  17562. scene: Scene;
  17563. /**
  17564. * The camera currently used for the rendering pass
  17565. */
  17566. camera: Nullable<Camera>;
  17567. /**
  17568. * The ID of the renderingGroup being processed
  17569. */
  17570. renderingGroupId: number;
  17571. }
  17572. /**
  17573. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17574. * It is enable to manage the different groups as well as the different necessary sort functions.
  17575. * This should not be used directly aside of the few static configurations
  17576. */
  17577. export class RenderingManager {
  17578. /**
  17579. * The max id used for rendering groups (not included)
  17580. */
  17581. static MAX_RENDERINGGROUPS: number;
  17582. /**
  17583. * The min id used for rendering groups (included)
  17584. */
  17585. static MIN_RENDERINGGROUPS: number;
  17586. /**
  17587. * Used to globally prevent autoclearing scenes.
  17588. */
  17589. static AUTOCLEAR: boolean;
  17590. /**
  17591. * @hidden
  17592. */
  17593. _useSceneAutoClearSetup: boolean;
  17594. private _scene;
  17595. private _renderingGroups;
  17596. private _depthStencilBufferAlreadyCleaned;
  17597. private _autoClearDepthStencil;
  17598. private _customOpaqueSortCompareFn;
  17599. private _customAlphaTestSortCompareFn;
  17600. private _customTransparentSortCompareFn;
  17601. private _renderingGroupInfo;
  17602. /**
  17603. * Instantiates a new rendering group for a particular scene
  17604. * @param scene Defines the scene the groups belongs to
  17605. */
  17606. constructor(scene: Scene);
  17607. private _clearDepthStencilBuffer;
  17608. /**
  17609. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17610. * @hidden
  17611. */
  17612. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17613. /**
  17614. * Resets the different information of the group to prepare a new frame
  17615. * @hidden
  17616. */
  17617. reset(): void;
  17618. /**
  17619. * Dispose and release the group and its associated resources.
  17620. * @hidden
  17621. */
  17622. dispose(): void;
  17623. /**
  17624. * Clear the info related to rendering groups preventing retention points during dispose.
  17625. */
  17626. freeRenderingGroups(): void;
  17627. private _prepareRenderingGroup;
  17628. /**
  17629. * Add a sprite manager to the rendering manager in order to render it this frame.
  17630. * @param spriteManager Define the sprite manager to render
  17631. */
  17632. dispatchSprites(spriteManager: ISpriteManager): void;
  17633. /**
  17634. * Add a particle system to the rendering manager in order to render it this frame.
  17635. * @param particleSystem Define the particle system to render
  17636. */
  17637. dispatchParticles(particleSystem: IParticleSystem): void;
  17638. /**
  17639. * Add a submesh to the manager in order to render it this frame
  17640. * @param subMesh The submesh to dispatch
  17641. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17642. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17643. */
  17644. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17645. /**
  17646. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17647. * This allowed control for front to back rendering or reversly depending of the special needs.
  17648. *
  17649. * @param renderingGroupId The rendering group id corresponding to its index
  17650. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17651. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17652. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17653. */
  17654. 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;
  17655. /**
  17656. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17657. *
  17658. * @param renderingGroupId The rendering group id corresponding to its index
  17659. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17660. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17661. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17662. */
  17663. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17664. /**
  17665. * Gets the current auto clear configuration for one rendering group of the rendering
  17666. * manager.
  17667. * @param index the rendering group index to get the information for
  17668. * @returns The auto clear setup for the requested rendering group
  17669. */
  17670. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17671. }
  17672. }
  17673. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17674. import { Observable } from "babylonjs/Misc/observable";
  17675. import { SmartArray } from "babylonjs/Misc/smartArray";
  17676. import { Nullable } from "babylonjs/types";
  17677. import { Camera } from "babylonjs/Cameras/camera";
  17678. import { Scene } from "babylonjs/scene";
  17679. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17680. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17683. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17684. import { Texture } from "babylonjs/Materials/Textures/texture";
  17685. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17686. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17687. import { Engine } from "babylonjs/Engines/engine";
  17688. /**
  17689. * This Helps creating a texture that will be created from a camera in your scene.
  17690. * It is basically a dynamic texture that could be used to create special effects for instance.
  17691. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17692. */
  17693. export class RenderTargetTexture extends Texture {
  17694. isCube: boolean;
  17695. /**
  17696. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17697. */
  17698. static readonly REFRESHRATE_RENDER_ONCE: number;
  17699. /**
  17700. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17701. */
  17702. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17703. /**
  17704. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17705. * the central point of your effect and can save a lot of performances.
  17706. */
  17707. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17708. /**
  17709. * Use this predicate to dynamically define the list of mesh you want to render.
  17710. * If set, the renderList property will be overwritten.
  17711. */
  17712. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17713. private _renderList;
  17714. /**
  17715. * Use this list to define the list of mesh you want to render.
  17716. */
  17717. renderList: Nullable<Array<AbstractMesh>>;
  17718. private _hookArray;
  17719. /**
  17720. * Define if particles should be rendered in your texture.
  17721. */
  17722. renderParticles: boolean;
  17723. /**
  17724. * Define if sprites should be rendered in your texture.
  17725. */
  17726. renderSprites: boolean;
  17727. /**
  17728. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17729. */
  17730. coordinatesMode: number;
  17731. /**
  17732. * Define the camera used to render the texture.
  17733. */
  17734. activeCamera: Nullable<Camera>;
  17735. /**
  17736. * Override the render function of the texture with your own one.
  17737. */
  17738. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17739. /**
  17740. * Define if camera post processes should be use while rendering the texture.
  17741. */
  17742. useCameraPostProcesses: boolean;
  17743. /**
  17744. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17745. */
  17746. ignoreCameraViewport: boolean;
  17747. private _postProcessManager;
  17748. private _postProcesses;
  17749. private _resizeObserver;
  17750. /**
  17751. * An event triggered when the texture is unbind.
  17752. */
  17753. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17754. /**
  17755. * An event triggered when the texture is unbind.
  17756. */
  17757. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17758. private _onAfterUnbindObserver;
  17759. /**
  17760. * Set a after unbind callback in the texture.
  17761. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17762. */
  17763. onAfterUnbind: () => void;
  17764. /**
  17765. * An event triggered before rendering the texture
  17766. */
  17767. onBeforeRenderObservable: Observable<number>;
  17768. private _onBeforeRenderObserver;
  17769. /**
  17770. * Set a before render callback in the texture.
  17771. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17772. */
  17773. onBeforeRender: (faceIndex: number) => void;
  17774. /**
  17775. * An event triggered after rendering the texture
  17776. */
  17777. onAfterRenderObservable: Observable<number>;
  17778. private _onAfterRenderObserver;
  17779. /**
  17780. * Set a after render callback in the texture.
  17781. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17782. */
  17783. onAfterRender: (faceIndex: number) => void;
  17784. /**
  17785. * An event triggered after the texture clear
  17786. */
  17787. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17788. private _onClearObserver;
  17789. /**
  17790. * Set a clear callback in the texture.
  17791. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17792. */
  17793. onClear: (Engine: Engine) => void;
  17794. /**
  17795. * Define the clear color of the Render Target if it should be different from the scene.
  17796. */
  17797. clearColor: Color4;
  17798. protected _size: number | {
  17799. width: number;
  17800. height: number;
  17801. };
  17802. protected _initialSizeParameter: number | {
  17803. width: number;
  17804. height: number;
  17805. } | {
  17806. ratio: number;
  17807. };
  17808. protected _sizeRatio: Nullable<number>;
  17809. /** @hidden */
  17810. _generateMipMaps: boolean;
  17811. protected _renderingManager: RenderingManager;
  17812. /** @hidden */
  17813. _waitingRenderList: string[];
  17814. protected _doNotChangeAspectRatio: boolean;
  17815. protected _currentRefreshId: number;
  17816. protected _refreshRate: number;
  17817. protected _textureMatrix: Matrix;
  17818. protected _samples: number;
  17819. protected _renderTargetOptions: RenderTargetCreationOptions;
  17820. /**
  17821. * Gets render target creation options that were used.
  17822. */
  17823. readonly renderTargetOptions: RenderTargetCreationOptions;
  17824. protected _engine: Engine;
  17825. protected _onRatioRescale(): void;
  17826. /**
  17827. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17828. * It must define where the camera used to render the texture is set
  17829. */
  17830. boundingBoxPosition: Vector3;
  17831. private _boundingBoxSize;
  17832. /**
  17833. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17834. * When defined, the cubemap will switch to local mode
  17835. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17836. * @example https://www.babylonjs-playground.com/#RNASML
  17837. */
  17838. boundingBoxSize: Vector3;
  17839. /**
  17840. * In case the RTT has been created with a depth texture, get the associated
  17841. * depth texture.
  17842. * Otherwise, return null.
  17843. */
  17844. depthStencilTexture: Nullable<InternalTexture>;
  17845. /**
  17846. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17847. * or used a shadow, depth texture...
  17848. * @param name The friendly name of the texture
  17849. * @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)
  17850. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17851. * @param generateMipMaps True if mip maps need to be generated after render.
  17852. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17853. * @param type The type of the buffer in the RTT (int, half float, float...)
  17854. * @param isCube True if a cube texture needs to be created
  17855. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17856. * @param generateDepthBuffer True to generate a depth buffer
  17857. * @param generateStencilBuffer True to generate a stencil buffer
  17858. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17859. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17860. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17861. */
  17862. constructor(name: string, size: number | {
  17863. width: number;
  17864. height: number;
  17865. } | {
  17866. ratio: number;
  17867. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17868. /**
  17869. * Creates a depth stencil texture.
  17870. * This is only available in WebGL 2 or with the depth texture extension available.
  17871. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17872. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17873. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17874. */
  17875. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17876. private _processSizeParameter;
  17877. /**
  17878. * Define the number of samples to use in case of MSAA.
  17879. * It defaults to one meaning no MSAA has been enabled.
  17880. */
  17881. samples: number;
  17882. /**
  17883. * Resets the refresh counter of the texture and start bak from scratch.
  17884. * Could be useful to regenerate the texture if it is setup to render only once.
  17885. */
  17886. resetRefreshCounter(): void;
  17887. /**
  17888. * Define the refresh rate of the texture or the rendering frequency.
  17889. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17890. */
  17891. refreshRate: number;
  17892. /**
  17893. * Adds a post process to the render target rendering passes.
  17894. * @param postProcess define the post process to add
  17895. */
  17896. addPostProcess(postProcess: PostProcess): void;
  17897. /**
  17898. * Clear all the post processes attached to the render target
  17899. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17900. */
  17901. clearPostProcesses(dispose?: boolean): void;
  17902. /**
  17903. * Remove one of the post process from the list of attached post processes to the texture
  17904. * @param postProcess define the post process to remove from the list
  17905. */
  17906. removePostProcess(postProcess: PostProcess): void;
  17907. /** @hidden */
  17908. _shouldRender(): boolean;
  17909. /**
  17910. * Gets the actual render size of the texture.
  17911. * @returns the width of the render size
  17912. */
  17913. getRenderSize(): number;
  17914. /**
  17915. * Gets the actual render width of the texture.
  17916. * @returns the width of the render size
  17917. */
  17918. getRenderWidth(): number;
  17919. /**
  17920. * Gets the actual render height of the texture.
  17921. * @returns the height of the render size
  17922. */
  17923. getRenderHeight(): number;
  17924. /**
  17925. * Get if the texture can be rescaled or not.
  17926. */
  17927. readonly canRescale: boolean;
  17928. /**
  17929. * Resize the texture using a ratio.
  17930. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17931. */
  17932. scale(ratio: number): void;
  17933. /**
  17934. * Get the texture reflection matrix used to rotate/transform the reflection.
  17935. * @returns the reflection matrix
  17936. */
  17937. getReflectionTextureMatrix(): Matrix;
  17938. /**
  17939. * Resize the texture to a new desired size.
  17940. * Be carrefull as it will recreate all the data in the new texture.
  17941. * @param size Define the new size. It can be:
  17942. * - a number for squared texture,
  17943. * - an object containing { width: number, height: number }
  17944. * - or an object containing a ratio { ratio: number }
  17945. */
  17946. resize(size: number | {
  17947. width: number;
  17948. height: number;
  17949. } | {
  17950. ratio: number;
  17951. }): void;
  17952. /**
  17953. * Renders all the objects from the render list into the texture.
  17954. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17955. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17956. */
  17957. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17958. private _bestReflectionRenderTargetDimension;
  17959. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17960. private renderToTarget;
  17961. /**
  17962. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17963. * This allowed control for front to back rendering or reversly depending of the special needs.
  17964. *
  17965. * @param renderingGroupId The rendering group id corresponding to its index
  17966. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17967. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17968. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17969. */
  17970. 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;
  17971. /**
  17972. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17973. *
  17974. * @param renderingGroupId The rendering group id corresponding to its index
  17975. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17976. */
  17977. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17978. /**
  17979. * Clones the texture.
  17980. * @returns the cloned texture
  17981. */
  17982. clone(): RenderTargetTexture;
  17983. /**
  17984. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17985. * @returns The JSON representation of the texture
  17986. */
  17987. serialize(): any;
  17988. /**
  17989. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17990. */
  17991. disposeFramebufferObjects(): void;
  17992. /**
  17993. * Dispose the texture and release its associated resources.
  17994. */
  17995. dispose(): void;
  17996. /** @hidden */
  17997. _rebuild(): void;
  17998. /**
  17999. * Clear the info related to rendering groups preventing retention point in material dispose.
  18000. */
  18001. freeRenderingGroups(): void;
  18002. }
  18003. }
  18004. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18005. import { Scene } from "babylonjs/scene";
  18006. import { Plane } from "babylonjs/Maths/math";
  18007. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18008. /**
  18009. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18010. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18011. * You can then easily use it as a reflectionTexture on a flat surface.
  18012. * In case the surface is not a plane, please consider relying on reflection probes.
  18013. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18014. */
  18015. export class MirrorTexture extends RenderTargetTexture {
  18016. private scene;
  18017. /**
  18018. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18019. * 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.
  18020. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18021. */
  18022. mirrorPlane: Plane;
  18023. /**
  18024. * Define the blur ratio used to blur the reflection if needed.
  18025. */
  18026. blurRatio: number;
  18027. /**
  18028. * Define the adaptive blur kernel used to blur the reflection if needed.
  18029. * This will autocompute the closest best match for the `blurKernel`
  18030. */
  18031. adaptiveBlurKernel: number;
  18032. /**
  18033. * Define the blur kernel used to blur the reflection if needed.
  18034. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18035. */
  18036. blurKernel: number;
  18037. /**
  18038. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18039. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18040. */
  18041. blurKernelX: number;
  18042. /**
  18043. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18044. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18045. */
  18046. blurKernelY: number;
  18047. private _autoComputeBlurKernel;
  18048. protected _onRatioRescale(): void;
  18049. private _updateGammaSpace;
  18050. private _imageProcessingConfigChangeObserver;
  18051. private _transformMatrix;
  18052. private _mirrorMatrix;
  18053. private _savedViewMatrix;
  18054. private _blurX;
  18055. private _blurY;
  18056. private _adaptiveBlurKernel;
  18057. private _blurKernelX;
  18058. private _blurKernelY;
  18059. private _blurRatio;
  18060. /**
  18061. * Instantiates a Mirror Texture.
  18062. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18063. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18064. * You can then easily use it as a reflectionTexture on a flat surface.
  18065. * In case the surface is not a plane, please consider relying on reflection probes.
  18066. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18067. * @param name
  18068. * @param size
  18069. * @param scene
  18070. * @param generateMipMaps
  18071. * @param type
  18072. * @param samplingMode
  18073. * @param generateDepthBuffer
  18074. */
  18075. constructor(name: string, size: number | {
  18076. width: number;
  18077. height: number;
  18078. } | {
  18079. ratio: number;
  18080. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18081. private _preparePostProcesses;
  18082. /**
  18083. * Clone the mirror texture.
  18084. * @returns the cloned texture
  18085. */
  18086. clone(): MirrorTexture;
  18087. /**
  18088. * Serialize the texture to a JSON representation you could use in Parse later on
  18089. * @returns the serialized JSON representation
  18090. */
  18091. serialize(): any;
  18092. /**
  18093. * Dispose the texture and release its associated resources.
  18094. */
  18095. dispose(): void;
  18096. }
  18097. }
  18098. declare module "babylonjs/Materials/Textures/texture" {
  18099. import { Observable } from "babylonjs/Misc/observable";
  18100. import { Nullable } from "babylonjs/types";
  18101. import { Scene } from "babylonjs/scene";
  18102. import { Matrix } from "babylonjs/Maths/math";
  18103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18104. /**
  18105. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18106. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18107. */
  18108. export class Texture extends BaseTexture {
  18109. /** @hidden */
  18110. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18111. /** @hidden */
  18112. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18113. /** @hidden */
  18114. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18115. /** nearest is mag = nearest and min = nearest and mip = linear */
  18116. static readonly NEAREST_SAMPLINGMODE: number;
  18117. /** nearest is mag = nearest and min = nearest and mip = linear */
  18118. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18119. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18120. static readonly BILINEAR_SAMPLINGMODE: number;
  18121. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18122. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18123. /** Trilinear is mag = linear and min = linear and mip = linear */
  18124. static readonly TRILINEAR_SAMPLINGMODE: number;
  18125. /** Trilinear is mag = linear and min = linear and mip = linear */
  18126. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18127. /** mag = nearest and min = nearest and mip = nearest */
  18128. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18129. /** mag = nearest and min = linear and mip = nearest */
  18130. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18131. /** mag = nearest and min = linear and mip = linear */
  18132. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18133. /** mag = nearest and min = linear and mip = none */
  18134. static readonly NEAREST_LINEAR: number;
  18135. /** mag = nearest and min = nearest and mip = none */
  18136. static readonly NEAREST_NEAREST: number;
  18137. /** mag = linear and min = nearest and mip = nearest */
  18138. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18139. /** mag = linear and min = nearest and mip = linear */
  18140. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18141. /** mag = linear and min = linear and mip = none */
  18142. static readonly LINEAR_LINEAR: number;
  18143. /** mag = linear and min = nearest and mip = none */
  18144. static readonly LINEAR_NEAREST: number;
  18145. /** Explicit coordinates mode */
  18146. static readonly EXPLICIT_MODE: number;
  18147. /** Spherical coordinates mode */
  18148. static readonly SPHERICAL_MODE: number;
  18149. /** Planar coordinates mode */
  18150. static readonly PLANAR_MODE: number;
  18151. /** Cubic coordinates mode */
  18152. static readonly CUBIC_MODE: number;
  18153. /** Projection coordinates mode */
  18154. static readonly PROJECTION_MODE: number;
  18155. /** Inverse Cubic coordinates mode */
  18156. static readonly SKYBOX_MODE: number;
  18157. /** Inverse Cubic coordinates mode */
  18158. static readonly INVCUBIC_MODE: number;
  18159. /** Equirectangular coordinates mode */
  18160. static readonly EQUIRECTANGULAR_MODE: number;
  18161. /** Equirectangular Fixed coordinates mode */
  18162. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18163. /** Equirectangular Fixed Mirrored coordinates mode */
  18164. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18165. /** Texture is not repeating outside of 0..1 UVs */
  18166. static readonly CLAMP_ADDRESSMODE: number;
  18167. /** Texture is repeating outside of 0..1 UVs */
  18168. static readonly WRAP_ADDRESSMODE: number;
  18169. /** Texture is repeating and mirrored */
  18170. static readonly MIRROR_ADDRESSMODE: number;
  18171. /**
  18172. * 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
  18173. */
  18174. static UseSerializedUrlIfAny: boolean;
  18175. /**
  18176. * Define the url of the texture.
  18177. */
  18178. url: Nullable<string>;
  18179. /**
  18180. * Define an offset on the texture to offset the u coordinates of the UVs
  18181. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18182. */
  18183. uOffset: number;
  18184. /**
  18185. * Define an offset on the texture to offset the v coordinates of the UVs
  18186. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18187. */
  18188. vOffset: number;
  18189. /**
  18190. * Define an offset on the texture to scale the u coordinates of the UVs
  18191. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18192. */
  18193. uScale: number;
  18194. /**
  18195. * Define an offset on the texture to scale the v coordinates of the UVs
  18196. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18197. */
  18198. vScale: number;
  18199. /**
  18200. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18201. * @see http://doc.babylonjs.com/how_to/more_materials
  18202. */
  18203. uAng: number;
  18204. /**
  18205. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18206. * @see http://doc.babylonjs.com/how_to/more_materials
  18207. */
  18208. vAng: number;
  18209. /**
  18210. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18211. * @see http://doc.babylonjs.com/how_to/more_materials
  18212. */
  18213. wAng: number;
  18214. /**
  18215. * Defines the center of rotation (U)
  18216. */
  18217. uRotationCenter: number;
  18218. /**
  18219. * Defines the center of rotation (V)
  18220. */
  18221. vRotationCenter: number;
  18222. /**
  18223. * Defines the center of rotation (W)
  18224. */
  18225. wRotationCenter: number;
  18226. /**
  18227. * Are mip maps generated for this texture or not.
  18228. */
  18229. readonly noMipmap: boolean;
  18230. private _noMipmap;
  18231. /** @hidden */
  18232. _invertY: boolean;
  18233. private _rowGenerationMatrix;
  18234. private _cachedTextureMatrix;
  18235. private _projectionModeMatrix;
  18236. private _t0;
  18237. private _t1;
  18238. private _t2;
  18239. private _cachedUOffset;
  18240. private _cachedVOffset;
  18241. private _cachedUScale;
  18242. private _cachedVScale;
  18243. private _cachedUAng;
  18244. private _cachedVAng;
  18245. private _cachedWAng;
  18246. private _cachedProjectionMatrixId;
  18247. private _cachedCoordinatesMode;
  18248. /** @hidden */
  18249. protected _initialSamplingMode: number;
  18250. /** @hidden */
  18251. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18252. private _deleteBuffer;
  18253. protected _format: Nullable<number>;
  18254. private _delayedOnLoad;
  18255. private _delayedOnError;
  18256. /**
  18257. * Observable triggered once the texture has been loaded.
  18258. */
  18259. onLoadObservable: Observable<Texture>;
  18260. protected _isBlocking: boolean;
  18261. /**
  18262. * Is the texture preventing material to render while loading.
  18263. * If false, a default texture will be used instead of the loading one during the preparation step.
  18264. */
  18265. isBlocking: boolean;
  18266. /**
  18267. * Get the current sampling mode associated with the texture.
  18268. */
  18269. readonly samplingMode: number;
  18270. /**
  18271. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18272. */
  18273. readonly invertY: boolean;
  18274. /**
  18275. * Instantiates a new texture.
  18276. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18277. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18278. * @param url define the url of the picture to load as a texture
  18279. * @param scene define the scene the texture will belong to
  18280. * @param noMipmap define if the texture will require mip maps or not
  18281. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18282. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18283. * @param onLoad define a callback triggered when the texture has been loaded
  18284. * @param onError define a callback triggered when an error occurred during the loading session
  18285. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18286. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18287. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18288. */
  18289. 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);
  18290. /**
  18291. * Update the url (and optional buffer) of this texture if url was null during construction.
  18292. * @param url the url of the texture
  18293. * @param buffer the buffer of the texture (defaults to null)
  18294. * @param onLoad callback called when the texture is loaded (defaults to null)
  18295. */
  18296. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18297. /**
  18298. * Finish the loading sequence of a texture flagged as delayed load.
  18299. * @hidden
  18300. */
  18301. delayLoad(): void;
  18302. private _prepareRowForTextureGeneration;
  18303. /**
  18304. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18305. * @returns the transform matrix of the texture.
  18306. */
  18307. getTextureMatrix(): Matrix;
  18308. /**
  18309. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18310. * @returns The reflection texture transform
  18311. */
  18312. getReflectionTextureMatrix(): Matrix;
  18313. /**
  18314. * Clones the texture.
  18315. * @returns the cloned texture
  18316. */
  18317. clone(): Texture;
  18318. /**
  18319. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18320. * @returns The JSON representation of the texture
  18321. */
  18322. serialize(): any;
  18323. /**
  18324. * Get the current class name of the texture useful for serialization or dynamic coding.
  18325. * @returns "Texture"
  18326. */
  18327. getClassName(): string;
  18328. /**
  18329. * Dispose the texture and release its associated resources.
  18330. */
  18331. dispose(): void;
  18332. /**
  18333. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18334. * @param parsedTexture Define the JSON representation of the texture
  18335. * @param scene Define the scene the parsed texture should be instantiated in
  18336. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18337. * @returns The parsed texture if successful
  18338. */
  18339. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18340. /**
  18341. * Creates a texture from its base 64 representation.
  18342. * @param data Define the base64 payload without the data: prefix
  18343. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18344. * @param scene Define the scene the texture should belong to
  18345. * @param noMipmap Forces the texture to not create mip map information if true
  18346. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18347. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18348. * @param onLoad define a callback triggered when the texture has been loaded
  18349. * @param onError define a callback triggered when an error occurred during the loading session
  18350. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18351. * @returns the created texture
  18352. */
  18353. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18354. /**
  18355. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18356. * @param data Define the base64 payload without the data: prefix
  18357. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18358. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18359. * @param scene Define the scene the texture should belong to
  18360. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18361. * @param noMipmap Forces the texture to not create mip map information if true
  18362. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18363. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18364. * @param onLoad define a callback triggered when the texture has been loaded
  18365. * @param onError define a callback triggered when an error occurred during the loading session
  18366. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18367. * @returns the created texture
  18368. */
  18369. 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;
  18370. }
  18371. }
  18372. declare module "babylonjs/Materials/Textures/rawTexture" {
  18373. import { Scene } from "babylonjs/scene";
  18374. import { Texture } from "babylonjs/Materials/Textures/texture";
  18375. /**
  18376. * Raw texture can help creating a texture directly from an array of data.
  18377. * This can be super useful if you either get the data from an uncompressed source or
  18378. * if you wish to create your texture pixel by pixel.
  18379. */
  18380. export class RawTexture extends Texture {
  18381. /**
  18382. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18383. */
  18384. format: number;
  18385. private _engine;
  18386. /**
  18387. * Instantiates a new RawTexture.
  18388. * Raw texture can help creating a texture directly from an array of data.
  18389. * This can be super useful if you either get the data from an uncompressed source or
  18390. * if you wish to create your texture pixel by pixel.
  18391. * @param data define the array of data to use to create the texture
  18392. * @param width define the width of the texture
  18393. * @param height define the height of the texture
  18394. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18395. * @param scene define the scene the texture belongs to
  18396. * @param generateMipMaps define whether mip maps should be generated or not
  18397. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18398. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18399. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18400. */
  18401. constructor(data: ArrayBufferView, width: number, height: number,
  18402. /**
  18403. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18404. */
  18405. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18406. /**
  18407. * Updates the texture underlying data.
  18408. * @param data Define the new data of the texture
  18409. */
  18410. update(data: ArrayBufferView): void;
  18411. /**
  18412. * Creates a luminance texture from some data.
  18413. * @param data Define the texture data
  18414. * @param width Define the width of the texture
  18415. * @param height Define the height of the texture
  18416. * @param scene Define the scene the texture belongs to
  18417. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18418. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18419. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18420. * @returns the luminance texture
  18421. */
  18422. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18423. /**
  18424. * Creates a luminance alpha texture from some data.
  18425. * @param data Define the texture data
  18426. * @param width Define the width of the texture
  18427. * @param height Define the height of the texture
  18428. * @param scene Define the scene the texture belongs to
  18429. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18430. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18431. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18432. * @returns the luminance alpha texture
  18433. */
  18434. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18435. /**
  18436. * Creates an alpha texture from some data.
  18437. * @param data Define the texture data
  18438. * @param width Define the width of the texture
  18439. * @param height Define the height of the texture
  18440. * @param scene Define the scene the texture belongs to
  18441. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18442. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18443. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18444. * @returns the alpha texture
  18445. */
  18446. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18447. /**
  18448. * Creates a RGB texture from some data.
  18449. * @param data Define the texture data
  18450. * @param width Define the width of the texture
  18451. * @param height Define the height of the texture
  18452. * @param scene Define the scene the texture belongs to
  18453. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18454. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18455. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18456. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18457. * @returns the RGB alpha texture
  18458. */
  18459. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18460. /**
  18461. * Creates a RGBA texture from some data.
  18462. * @param data Define the texture data
  18463. * @param width Define the width of the texture
  18464. * @param height Define the height of the texture
  18465. * @param scene Define the scene the texture belongs to
  18466. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18467. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18468. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18469. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18470. * @returns the RGBA texture
  18471. */
  18472. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18473. /**
  18474. * Creates a R texture from some data.
  18475. * @param data Define the texture data
  18476. * @param width Define the width of the texture
  18477. * @param height Define the height of the texture
  18478. * @param scene Define the scene the texture belongs to
  18479. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18480. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18481. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18482. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18483. * @returns the R texture
  18484. */
  18485. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18486. }
  18487. }
  18488. declare module "babylonjs/Animations/runtimeAnimation" {
  18489. import { Animation } from "babylonjs/Animations/animation";
  18490. import { Animatable } from "babylonjs/Animations/animatable";
  18491. import { Scene } from "babylonjs/scene";
  18492. /**
  18493. * Defines a runtime animation
  18494. */
  18495. export class RuntimeAnimation {
  18496. private _events;
  18497. /**
  18498. * The current frame of the runtime animation
  18499. */
  18500. private _currentFrame;
  18501. /**
  18502. * The animation used by the runtime animation
  18503. */
  18504. private _animation;
  18505. /**
  18506. * The target of the runtime animation
  18507. */
  18508. private _target;
  18509. /**
  18510. * The initiating animatable
  18511. */
  18512. private _host;
  18513. /**
  18514. * The original value of the runtime animation
  18515. */
  18516. private _originalValue;
  18517. /**
  18518. * The original blend value of the runtime animation
  18519. */
  18520. private _originalBlendValue;
  18521. /**
  18522. * The offsets cache of the runtime animation
  18523. */
  18524. private _offsetsCache;
  18525. /**
  18526. * The high limits cache of the runtime animation
  18527. */
  18528. private _highLimitsCache;
  18529. /**
  18530. * Specifies if the runtime animation has been stopped
  18531. */
  18532. private _stopped;
  18533. /**
  18534. * The blending factor of the runtime animation
  18535. */
  18536. private _blendingFactor;
  18537. /**
  18538. * The BabylonJS scene
  18539. */
  18540. private _scene;
  18541. /**
  18542. * The current value of the runtime animation
  18543. */
  18544. private _currentValue;
  18545. /** @hidden */
  18546. _workValue: any;
  18547. /**
  18548. * The active target of the runtime animation
  18549. */
  18550. private _activeTarget;
  18551. /**
  18552. * The target path of the runtime animation
  18553. */
  18554. private _targetPath;
  18555. /**
  18556. * The weight of the runtime animation
  18557. */
  18558. private _weight;
  18559. /**
  18560. * The ratio offset of the runtime animation
  18561. */
  18562. private _ratioOffset;
  18563. /**
  18564. * The previous delay of the runtime animation
  18565. */
  18566. private _previousDelay;
  18567. /**
  18568. * The previous ratio of the runtime animation
  18569. */
  18570. private _previousRatio;
  18571. /**
  18572. * Gets the current frame of the runtime animation
  18573. */
  18574. readonly currentFrame: number;
  18575. /**
  18576. * Gets the weight of the runtime animation
  18577. */
  18578. readonly weight: number;
  18579. /**
  18580. * Gets the current value of the runtime animation
  18581. */
  18582. readonly currentValue: any;
  18583. /**
  18584. * Gets the target path of the runtime animation
  18585. */
  18586. readonly targetPath: string;
  18587. /**
  18588. * Gets the actual target of the runtime animation
  18589. */
  18590. readonly target: any;
  18591. /**
  18592. * Create a new RuntimeAnimation object
  18593. * @param target defines the target of the animation
  18594. * @param animation defines the source animation object
  18595. * @param scene defines the hosting scene
  18596. * @param host defines the initiating Animatable
  18597. */
  18598. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18599. /**
  18600. * Gets the animation from the runtime animation
  18601. */
  18602. readonly animation: Animation;
  18603. /**
  18604. * Resets the runtime animation to the beginning
  18605. * @param restoreOriginal defines whether to restore the target property to the original value
  18606. */
  18607. reset(restoreOriginal?: boolean): void;
  18608. /**
  18609. * Specifies if the runtime animation is stopped
  18610. * @returns Boolean specifying if the runtime animation is stopped
  18611. */
  18612. isStopped(): boolean;
  18613. /**
  18614. * Disposes of the runtime animation
  18615. */
  18616. dispose(): void;
  18617. /**
  18618. * Interpolates the animation from the current frame
  18619. * @param currentFrame The frame to interpolate the animation to
  18620. * @param repeatCount The number of times that the animation should loop
  18621. * @param loopMode The type of looping mode to use
  18622. * @param offsetValue Animation offset value
  18623. * @param highLimitValue The high limit value
  18624. * @returns The interpolated value
  18625. */
  18626. private _interpolate;
  18627. /**
  18628. * Apply the interpolated value to the target
  18629. * @param currentValue defines the value computed by the animation
  18630. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18631. */
  18632. setValue(currentValue: any, weight?: number): void;
  18633. private _setValue;
  18634. /**
  18635. * Gets the loop pmode of the runtime animation
  18636. * @returns Loop Mode
  18637. */
  18638. private _getCorrectLoopMode;
  18639. /**
  18640. * Move the current animation to a given frame
  18641. * @param frame defines the frame to move to
  18642. */
  18643. goToFrame(frame: number): void;
  18644. /**
  18645. * @hidden Internal use only
  18646. */
  18647. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18648. /**
  18649. * Execute the current animation
  18650. * @param delay defines the delay to add to the current frame
  18651. * @param from defines the lower bound of the animation range
  18652. * @param to defines the upper bound of the animation range
  18653. * @param loop defines if the current animation must loop
  18654. * @param speedRatio defines the current speed ratio
  18655. * @param weight defines the weight of the animation (default is -1 so no weight)
  18656. * @param onLoop optional callback called when animation loops
  18657. * @returns a boolean indicating if the animation is running
  18658. */
  18659. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18660. }
  18661. }
  18662. declare module "babylonjs/Animations/animatable" {
  18663. import { Animation } from "babylonjs/Animations/animation";
  18664. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18665. import { Nullable } from "babylonjs/types";
  18666. import { Observable } from "babylonjs/Misc/observable";
  18667. import { Scene } from "babylonjs/scene";
  18668. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18669. import { Node } from "babylonjs/node";
  18670. /**
  18671. * Class used to store an actual running animation
  18672. */
  18673. export class Animatable {
  18674. /** defines the target object */
  18675. target: any;
  18676. /** defines the starting frame number (default is 0) */
  18677. fromFrame: number;
  18678. /** defines the ending frame number (default is 100) */
  18679. toFrame: number;
  18680. /** defines if the animation must loop (default is false) */
  18681. loopAnimation: boolean;
  18682. /** defines a callback to call when animation ends if it is not looping */
  18683. onAnimationEnd?: (() => void) | null | undefined;
  18684. /** defines a callback to call when animation loops */
  18685. onAnimationLoop?: (() => void) | null | undefined;
  18686. private _localDelayOffset;
  18687. private _pausedDelay;
  18688. private _runtimeAnimations;
  18689. private _paused;
  18690. private _scene;
  18691. private _speedRatio;
  18692. private _weight;
  18693. private _syncRoot;
  18694. /**
  18695. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18696. * This will only apply for non looping animation (default is true)
  18697. */
  18698. disposeOnEnd: boolean;
  18699. /**
  18700. * Gets a boolean indicating if the animation has started
  18701. */
  18702. animationStarted: boolean;
  18703. /**
  18704. * Observer raised when the animation ends
  18705. */
  18706. onAnimationEndObservable: Observable<Animatable>;
  18707. /**
  18708. * Observer raised when the animation loops
  18709. */
  18710. onAnimationLoopObservable: Observable<Animatable>;
  18711. /**
  18712. * Gets the root Animatable used to synchronize and normalize animations
  18713. */
  18714. readonly syncRoot: Animatable;
  18715. /**
  18716. * Gets the current frame of the first RuntimeAnimation
  18717. * Used to synchronize Animatables
  18718. */
  18719. readonly masterFrame: number;
  18720. /**
  18721. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18722. */
  18723. weight: number;
  18724. /**
  18725. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18726. */
  18727. speedRatio: number;
  18728. /**
  18729. * Creates a new Animatable
  18730. * @param scene defines the hosting scene
  18731. * @param target defines the target object
  18732. * @param fromFrame defines the starting frame number (default is 0)
  18733. * @param toFrame defines the ending frame number (default is 100)
  18734. * @param loopAnimation defines if the animation must loop (default is false)
  18735. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18736. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18737. * @param animations defines a group of animation to add to the new Animatable
  18738. * @param onAnimationLoop defines a callback to call when animation loops
  18739. */
  18740. constructor(scene: Scene,
  18741. /** defines the target object */
  18742. target: any,
  18743. /** defines the starting frame number (default is 0) */
  18744. fromFrame?: number,
  18745. /** defines the ending frame number (default is 100) */
  18746. toFrame?: number,
  18747. /** defines if the animation must loop (default is false) */
  18748. loopAnimation?: boolean, speedRatio?: number,
  18749. /** defines a callback to call when animation ends if it is not looping */
  18750. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18751. /** defines a callback to call when animation loops */
  18752. onAnimationLoop?: (() => void) | null | undefined);
  18753. /**
  18754. * Synchronize and normalize current Animatable with a source Animatable
  18755. * This is useful when using animation weights and when animations are not of the same length
  18756. * @param root defines the root Animatable to synchronize with
  18757. * @returns the current Animatable
  18758. */
  18759. syncWith(root: Animatable): Animatable;
  18760. /**
  18761. * Gets the list of runtime animations
  18762. * @returns an array of RuntimeAnimation
  18763. */
  18764. getAnimations(): RuntimeAnimation[];
  18765. /**
  18766. * Adds more animations to the current animatable
  18767. * @param target defines the target of the animations
  18768. * @param animations defines the new animations to add
  18769. */
  18770. appendAnimations(target: any, animations: Animation[]): void;
  18771. /**
  18772. * Gets the source animation for a specific property
  18773. * @param property defines the propertyu to look for
  18774. * @returns null or the source animation for the given property
  18775. */
  18776. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18777. /**
  18778. * Gets the runtime animation for a specific property
  18779. * @param property defines the propertyu to look for
  18780. * @returns null or the runtime animation for the given property
  18781. */
  18782. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18783. /**
  18784. * Resets the animatable to its original state
  18785. */
  18786. reset(): void;
  18787. /**
  18788. * Allows the animatable to blend with current running animations
  18789. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18790. * @param blendingSpeed defines the blending speed to use
  18791. */
  18792. enableBlending(blendingSpeed: number): void;
  18793. /**
  18794. * Disable animation blending
  18795. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18796. */
  18797. disableBlending(): void;
  18798. /**
  18799. * Jump directly to a given frame
  18800. * @param frame defines the frame to jump to
  18801. */
  18802. goToFrame(frame: number): void;
  18803. /**
  18804. * Pause the animation
  18805. */
  18806. pause(): void;
  18807. /**
  18808. * Restart the animation
  18809. */
  18810. restart(): void;
  18811. private _raiseOnAnimationEnd;
  18812. /**
  18813. * Stop and delete the current animation
  18814. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18815. * @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)
  18816. */
  18817. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18818. /**
  18819. * Wait asynchronously for the animation to end
  18820. * @returns a promise which will be fullfilled when the animation ends
  18821. */
  18822. waitAsync(): Promise<Animatable>;
  18823. /** @hidden */
  18824. _animate(delay: number): boolean;
  18825. }
  18826. module "babylonjs/scene" {
  18827. interface Scene {
  18828. /** @hidden */
  18829. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18830. /** @hidden */
  18831. _processLateAnimationBindingsForMatrices(holder: {
  18832. totalWeight: number;
  18833. animations: RuntimeAnimation[];
  18834. originalValue: Matrix;
  18835. }): any;
  18836. /** @hidden */
  18837. _processLateAnimationBindingsForQuaternions(holder: {
  18838. totalWeight: number;
  18839. animations: RuntimeAnimation[];
  18840. originalValue: Quaternion;
  18841. }, refQuaternion: Quaternion): Quaternion;
  18842. /** @hidden */
  18843. _processLateAnimationBindings(): void;
  18844. /**
  18845. * Will start the animation sequence of a given target
  18846. * @param target defines the target
  18847. * @param from defines from which frame should animation start
  18848. * @param to defines until which frame should animation run.
  18849. * @param weight defines the weight to apply to the animation (1.0 by default)
  18850. * @param loop defines if the animation loops
  18851. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18852. * @param onAnimationEnd defines the function to be executed when the animation ends
  18853. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18854. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18855. * @param onAnimationLoop defines the callback to call when an animation loops
  18856. * @returns the animatable object created for this animation
  18857. */
  18858. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18859. /**
  18860. * Will start the animation sequence of a given target
  18861. * @param target defines the target
  18862. * @param from defines from which frame should animation start
  18863. * @param to defines until which frame should animation run.
  18864. * @param loop defines if the animation loops
  18865. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18866. * @param onAnimationEnd defines the function to be executed when the animation ends
  18867. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18868. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18869. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18870. * @param onAnimationLoop defines the callback to call when an animation loops
  18871. * @returns the animatable object created for this animation
  18872. */
  18873. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18874. /**
  18875. * Will start the animation sequence of a given target and its hierarchy
  18876. * @param target defines the target
  18877. * @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.
  18878. * @param from defines from which frame should animation start
  18879. * @param to defines until which frame should animation run.
  18880. * @param loop defines if the animation loops
  18881. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18882. * @param onAnimationEnd defines the function to be executed when the animation ends
  18883. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18884. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18885. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18886. * @param onAnimationLoop defines the callback to call when an animation loops
  18887. * @returns the list of created animatables
  18888. */
  18889. 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[];
  18890. /**
  18891. * Begin a new animation on a given node
  18892. * @param target defines the target where the animation will take place
  18893. * @param animations defines the list of animations to start
  18894. * @param from defines the initial value
  18895. * @param to defines the final value
  18896. * @param loop defines if you want animation to loop (off by default)
  18897. * @param speedRatio defines the speed ratio to apply to all animations
  18898. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18899. * @param onAnimationLoop defines the callback to call when an animation loops
  18900. * @returns the list of created animatables
  18901. */
  18902. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18903. /**
  18904. * Begin a new animation on a given node and its hierarchy
  18905. * @param target defines the root node where the animation will take place
  18906. * @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.
  18907. * @param animations defines the list of animations to start
  18908. * @param from defines the initial value
  18909. * @param to defines the final value
  18910. * @param loop defines if you want animation to loop (off by default)
  18911. * @param speedRatio defines the speed ratio to apply to all animations
  18912. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18913. * @param onAnimationLoop defines the callback to call when an animation loops
  18914. * @returns the list of animatables created for all nodes
  18915. */
  18916. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18917. /**
  18918. * Gets the animatable associated with a specific target
  18919. * @param target defines the target of the animatable
  18920. * @returns the required animatable if found
  18921. */
  18922. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18923. /**
  18924. * Gets all animatables associated with a given target
  18925. * @param target defines the target to look animatables for
  18926. * @returns an array of Animatables
  18927. */
  18928. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18929. /**
  18930. * Will stop the animation of the given target
  18931. * @param target - the target
  18932. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18933. * @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)
  18934. */
  18935. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18936. /**
  18937. * Stops and removes all animations that have been applied to the scene
  18938. */
  18939. stopAllAnimations(): void;
  18940. }
  18941. }
  18942. module "babylonjs/Bones/bone" {
  18943. interface Bone {
  18944. /**
  18945. * Copy an animation range from another bone
  18946. * @param source defines the source bone
  18947. * @param rangeName defines the range name to copy
  18948. * @param frameOffset defines the frame offset
  18949. * @param rescaleAsRequired defines if rescaling must be applied if required
  18950. * @param skelDimensionsRatio defines the scaling ratio
  18951. * @returns true if operation was successful
  18952. */
  18953. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18954. }
  18955. }
  18956. }
  18957. declare module "babylonjs/Bones/skeleton" {
  18958. import { Bone } from "babylonjs/Bones/bone";
  18959. import { IAnimatable } from "babylonjs/Misc/tools";
  18960. import { Observable } from "babylonjs/Misc/observable";
  18961. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18962. import { Scene } from "babylonjs/scene";
  18963. import { Nullable } from "babylonjs/types";
  18964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18965. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18966. import { Animatable } from "babylonjs/Animations/animatable";
  18967. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18968. import { Animation } from "babylonjs/Animations/animation";
  18969. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18970. /**
  18971. * Class used to handle skinning animations
  18972. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18973. */
  18974. export class Skeleton implements IAnimatable {
  18975. /** defines the skeleton name */
  18976. name: string;
  18977. /** defines the skeleton Id */
  18978. id: string;
  18979. /**
  18980. * Defines the list of child bones
  18981. */
  18982. bones: Bone[];
  18983. /**
  18984. * Defines an estimate of the dimension of the skeleton at rest
  18985. */
  18986. dimensionsAtRest: Vector3;
  18987. /**
  18988. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18989. */
  18990. needInitialSkinMatrix: boolean;
  18991. /**
  18992. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18993. */
  18994. overrideMesh: Nullable<AbstractMesh>;
  18995. /**
  18996. * Gets the list of animations attached to this skeleton
  18997. */
  18998. animations: Array<Animation>;
  18999. private _scene;
  19000. private _isDirty;
  19001. private _transformMatrices;
  19002. private _transformMatrixTexture;
  19003. private _meshesWithPoseMatrix;
  19004. private _animatables;
  19005. private _identity;
  19006. private _synchronizedWithMesh;
  19007. private _ranges;
  19008. private _lastAbsoluteTransformsUpdateId;
  19009. private _canUseTextureForBones;
  19010. /** @hidden */
  19011. _numBonesWithLinkedTransformNode: number;
  19012. /**
  19013. * Specifies if the skeleton should be serialized
  19014. */
  19015. doNotSerialize: boolean;
  19016. private _useTextureToStoreBoneMatrices;
  19017. /**
  19018. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19019. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19020. */
  19021. useTextureToStoreBoneMatrices: boolean;
  19022. private _animationPropertiesOverride;
  19023. /**
  19024. * Gets or sets the animation properties override
  19025. */
  19026. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19027. /**
  19028. * An observable triggered before computing the skeleton's matrices
  19029. */
  19030. onBeforeComputeObservable: Observable<Skeleton>;
  19031. /**
  19032. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19033. */
  19034. readonly isUsingTextureForMatrices: boolean;
  19035. /**
  19036. * Creates a new skeleton
  19037. * @param name defines the skeleton name
  19038. * @param id defines the skeleton Id
  19039. * @param scene defines the hosting scene
  19040. */
  19041. constructor(
  19042. /** defines the skeleton name */
  19043. name: string,
  19044. /** defines the skeleton Id */
  19045. id: string, scene: Scene);
  19046. /**
  19047. * Gets the current object class name.
  19048. * @return the class name
  19049. */
  19050. getClassName(): string;
  19051. /**
  19052. * Returns an array containing the root bones
  19053. * @returns an array containing the root bones
  19054. */
  19055. getChildren(): Array<Bone>;
  19056. /**
  19057. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19058. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19059. * @returns a Float32Array containing matrices data
  19060. */
  19061. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19062. /**
  19063. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19064. * @returns a raw texture containing the data
  19065. */
  19066. getTransformMatrixTexture(): Nullable<RawTexture>;
  19067. /**
  19068. * Gets the current hosting scene
  19069. * @returns a scene object
  19070. */
  19071. getScene(): Scene;
  19072. /**
  19073. * Gets a string representing the current skeleton data
  19074. * @param fullDetails defines a boolean indicating if we want a verbose version
  19075. * @returns a string representing the current skeleton data
  19076. */
  19077. toString(fullDetails?: boolean): string;
  19078. /**
  19079. * Get bone's index searching by name
  19080. * @param name defines bone's name to search for
  19081. * @return the indice of the bone. Returns -1 if not found
  19082. */
  19083. getBoneIndexByName(name: string): number;
  19084. /**
  19085. * Creater a new animation range
  19086. * @param name defines the name of the range
  19087. * @param from defines the start key
  19088. * @param to defines the end key
  19089. */
  19090. createAnimationRange(name: string, from: number, to: number): void;
  19091. /**
  19092. * Delete a specific animation range
  19093. * @param name defines the name of the range
  19094. * @param deleteFrames defines if frames must be removed as well
  19095. */
  19096. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19097. /**
  19098. * Gets a specific animation range
  19099. * @param name defines the name of the range to look for
  19100. * @returns the requested animation range or null if not found
  19101. */
  19102. getAnimationRange(name: string): Nullable<AnimationRange>;
  19103. /**
  19104. * Gets the list of all animation ranges defined on this skeleton
  19105. * @returns an array
  19106. */
  19107. getAnimationRanges(): Nullable<AnimationRange>[];
  19108. /**
  19109. * Copy animation range from a source skeleton.
  19110. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19111. * @param source defines the source skeleton
  19112. * @param name defines the name of the range to copy
  19113. * @param rescaleAsRequired defines if rescaling must be applied if required
  19114. * @returns true if operation was successful
  19115. */
  19116. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19117. /**
  19118. * Forces the skeleton to go to rest pose
  19119. */
  19120. returnToRest(): void;
  19121. private _getHighestAnimationFrame;
  19122. /**
  19123. * Begin a specific animation range
  19124. * @param name defines the name of the range to start
  19125. * @param loop defines if looping must be turned on (false by default)
  19126. * @param speedRatio defines the speed ratio to apply (1 by default)
  19127. * @param onAnimationEnd defines a callback which will be called when animation will end
  19128. * @returns a new animatable
  19129. */
  19130. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19131. /** @hidden */
  19132. _markAsDirty(): void;
  19133. /** @hidden */
  19134. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19135. /** @hidden */
  19136. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19137. private _computeTransformMatrices;
  19138. /**
  19139. * Build all resources required to render a skeleton
  19140. */
  19141. prepare(): void;
  19142. /**
  19143. * Gets the list of animatables currently running for this skeleton
  19144. * @returns an array of animatables
  19145. */
  19146. getAnimatables(): IAnimatable[];
  19147. /**
  19148. * Clone the current skeleton
  19149. * @param name defines the name of the new skeleton
  19150. * @param id defines the id of the enw skeleton
  19151. * @returns the new skeleton
  19152. */
  19153. clone(name: string, id: string): Skeleton;
  19154. /**
  19155. * Enable animation blending for this skeleton
  19156. * @param blendingSpeed defines the blending speed to apply
  19157. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19158. */
  19159. enableBlending(blendingSpeed?: number): void;
  19160. /**
  19161. * Releases all resources associated with the current skeleton
  19162. */
  19163. dispose(): void;
  19164. /**
  19165. * Serialize the skeleton in a JSON object
  19166. * @returns a JSON object
  19167. */
  19168. serialize(): any;
  19169. /**
  19170. * Creates a new skeleton from serialized data
  19171. * @param parsedSkeleton defines the serialized data
  19172. * @param scene defines the hosting scene
  19173. * @returns a new skeleton
  19174. */
  19175. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19176. /**
  19177. * Compute all node absolute transforms
  19178. * @param forceUpdate defines if computation must be done even if cache is up to date
  19179. */
  19180. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19181. /**
  19182. * Gets the root pose matrix
  19183. * @returns a matrix
  19184. */
  19185. getPoseMatrix(): Nullable<Matrix>;
  19186. /**
  19187. * Sorts bones per internal index
  19188. */
  19189. sortBones(): void;
  19190. private _sortBones;
  19191. }
  19192. }
  19193. declare module "babylonjs/Morph/morphTarget" {
  19194. import { IAnimatable } from "babylonjs/Misc/tools";
  19195. import { Observable } from "babylonjs/Misc/observable";
  19196. import { Nullable, FloatArray } from "babylonjs/types";
  19197. import { Scene } from "babylonjs/scene";
  19198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19199. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19200. /**
  19201. * Defines a target to use with MorphTargetManager
  19202. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19203. */
  19204. export class MorphTarget implements IAnimatable {
  19205. /** defines the name of the target */
  19206. name: string;
  19207. /**
  19208. * Gets or sets the list of animations
  19209. */
  19210. animations: import("babylonjs/Animations/animation").Animation[];
  19211. private _scene;
  19212. private _positions;
  19213. private _normals;
  19214. private _tangents;
  19215. private _influence;
  19216. /**
  19217. * Observable raised when the influence changes
  19218. */
  19219. onInfluenceChanged: Observable<boolean>;
  19220. /** @hidden */
  19221. _onDataLayoutChanged: Observable<void>;
  19222. /**
  19223. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19224. */
  19225. influence: number;
  19226. /**
  19227. * Gets or sets the id of the morph Target
  19228. */
  19229. id: string;
  19230. private _animationPropertiesOverride;
  19231. /**
  19232. * Gets or sets the animation properties override
  19233. */
  19234. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19235. /**
  19236. * Creates a new MorphTarget
  19237. * @param name defines the name of the target
  19238. * @param influence defines the influence to use
  19239. * @param scene defines the scene the morphtarget belongs to
  19240. */
  19241. constructor(
  19242. /** defines the name of the target */
  19243. name: string, influence?: number, scene?: Nullable<Scene>);
  19244. /**
  19245. * Gets a boolean defining if the target contains position data
  19246. */
  19247. readonly hasPositions: boolean;
  19248. /**
  19249. * Gets a boolean defining if the target contains normal data
  19250. */
  19251. readonly hasNormals: boolean;
  19252. /**
  19253. * Gets a boolean defining if the target contains tangent data
  19254. */
  19255. readonly hasTangents: boolean;
  19256. /**
  19257. * Affects position data to this target
  19258. * @param data defines the position data to use
  19259. */
  19260. setPositions(data: Nullable<FloatArray>): void;
  19261. /**
  19262. * Gets the position data stored in this target
  19263. * @returns a FloatArray containing the position data (or null if not present)
  19264. */
  19265. getPositions(): Nullable<FloatArray>;
  19266. /**
  19267. * Affects normal data to this target
  19268. * @param data defines the normal data to use
  19269. */
  19270. setNormals(data: Nullable<FloatArray>): void;
  19271. /**
  19272. * Gets the normal data stored in this target
  19273. * @returns a FloatArray containing the normal data (or null if not present)
  19274. */
  19275. getNormals(): Nullable<FloatArray>;
  19276. /**
  19277. * Affects tangent data to this target
  19278. * @param data defines the tangent data to use
  19279. */
  19280. setTangents(data: Nullable<FloatArray>): void;
  19281. /**
  19282. * Gets the tangent data stored in this target
  19283. * @returns a FloatArray containing the tangent data (or null if not present)
  19284. */
  19285. getTangents(): Nullable<FloatArray>;
  19286. /**
  19287. * Serializes the current target into a Serialization object
  19288. * @returns the serialized object
  19289. */
  19290. serialize(): any;
  19291. /**
  19292. * Returns the string "MorphTarget"
  19293. * @returns "MorphTarget"
  19294. */
  19295. getClassName(): string;
  19296. /**
  19297. * Creates a new target from serialized data
  19298. * @param serializationObject defines the serialized data to use
  19299. * @returns a new MorphTarget
  19300. */
  19301. static Parse(serializationObject: any): MorphTarget;
  19302. /**
  19303. * Creates a MorphTarget from mesh data
  19304. * @param mesh defines the source mesh
  19305. * @param name defines the name to use for the new target
  19306. * @param influence defines the influence to attach to the target
  19307. * @returns a new MorphTarget
  19308. */
  19309. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19310. }
  19311. }
  19312. declare module "babylonjs/Morph/morphTargetManager" {
  19313. import { Nullable } from "babylonjs/types";
  19314. import { Scene } from "babylonjs/scene";
  19315. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19316. /**
  19317. * This class is used to deform meshes using morphing between different targets
  19318. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19319. */
  19320. export class MorphTargetManager {
  19321. private _targets;
  19322. private _targetInfluenceChangedObservers;
  19323. private _targetDataLayoutChangedObservers;
  19324. private _activeTargets;
  19325. private _scene;
  19326. private _influences;
  19327. private _supportsNormals;
  19328. private _supportsTangents;
  19329. private _vertexCount;
  19330. private _uniqueId;
  19331. private _tempInfluences;
  19332. /**
  19333. * Creates a new MorphTargetManager
  19334. * @param scene defines the current scene
  19335. */
  19336. constructor(scene?: Nullable<Scene>);
  19337. /**
  19338. * Gets the unique ID of this manager
  19339. */
  19340. readonly uniqueId: number;
  19341. /**
  19342. * Gets the number of vertices handled by this manager
  19343. */
  19344. readonly vertexCount: number;
  19345. /**
  19346. * Gets a boolean indicating if this manager supports morphing of normals
  19347. */
  19348. readonly supportsNormals: boolean;
  19349. /**
  19350. * Gets a boolean indicating if this manager supports morphing of tangents
  19351. */
  19352. readonly supportsTangents: boolean;
  19353. /**
  19354. * Gets the number of targets stored in this manager
  19355. */
  19356. readonly numTargets: number;
  19357. /**
  19358. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19359. */
  19360. readonly numInfluencers: number;
  19361. /**
  19362. * Gets the list of influences (one per target)
  19363. */
  19364. readonly influences: Float32Array;
  19365. /**
  19366. * Gets the active target at specified index. An active target is a target with an influence > 0
  19367. * @param index defines the index to check
  19368. * @returns the requested target
  19369. */
  19370. getActiveTarget(index: number): MorphTarget;
  19371. /**
  19372. * Gets the target at specified index
  19373. * @param index defines the index to check
  19374. * @returns the requested target
  19375. */
  19376. getTarget(index: number): MorphTarget;
  19377. /**
  19378. * Add a new target to this manager
  19379. * @param target defines the target to add
  19380. */
  19381. addTarget(target: MorphTarget): void;
  19382. /**
  19383. * Removes a target from the manager
  19384. * @param target defines the target to remove
  19385. */
  19386. removeTarget(target: MorphTarget): void;
  19387. /**
  19388. * Serializes the current manager into a Serialization object
  19389. * @returns the serialized object
  19390. */
  19391. serialize(): any;
  19392. private _syncActiveTargets;
  19393. /**
  19394. * Syncrhonize the targets with all the meshes using this morph target manager
  19395. */
  19396. synchronize(): void;
  19397. /**
  19398. * Creates a new MorphTargetManager from serialized data
  19399. * @param serializationObject defines the serialized data
  19400. * @param scene defines the hosting scene
  19401. * @returns the new MorphTargetManager
  19402. */
  19403. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19404. }
  19405. }
  19406. declare module "babylonjs/Meshes/groundMesh" {
  19407. import { Scene } from "babylonjs/scene";
  19408. import { Vector3 } from "babylonjs/Maths/math";
  19409. import { Mesh } from "babylonjs/Meshes/mesh";
  19410. /**
  19411. * Mesh representing the gorund
  19412. */
  19413. export class GroundMesh extends Mesh {
  19414. /** If octree should be generated */
  19415. generateOctree: boolean;
  19416. private _heightQuads;
  19417. /** @hidden */
  19418. _subdivisionsX: number;
  19419. /** @hidden */
  19420. _subdivisionsY: number;
  19421. /** @hidden */
  19422. _width: number;
  19423. /** @hidden */
  19424. _height: number;
  19425. /** @hidden */
  19426. _minX: number;
  19427. /** @hidden */
  19428. _maxX: number;
  19429. /** @hidden */
  19430. _minZ: number;
  19431. /** @hidden */
  19432. _maxZ: number;
  19433. constructor(name: string, scene: Scene);
  19434. /**
  19435. * "GroundMesh"
  19436. * @returns "GroundMesh"
  19437. */
  19438. getClassName(): string;
  19439. /**
  19440. * The minimum of x and y subdivisions
  19441. */
  19442. readonly subdivisions: number;
  19443. /**
  19444. * X subdivisions
  19445. */
  19446. readonly subdivisionsX: number;
  19447. /**
  19448. * Y subdivisions
  19449. */
  19450. readonly subdivisionsY: number;
  19451. /**
  19452. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19453. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19454. * @param chunksCount the number of subdivisions for x and y
  19455. * @param octreeBlocksSize (Default: 32)
  19456. */
  19457. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19458. /**
  19459. * Returns a height (y) value in the Worl system :
  19460. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19461. * @param x x coordinate
  19462. * @param z z coordinate
  19463. * @returns the ground y position if (x, z) are outside the ground surface.
  19464. */
  19465. getHeightAtCoordinates(x: number, z: number): number;
  19466. /**
  19467. * Returns a normalized vector (Vector3) orthogonal to the ground
  19468. * at the ground coordinates (x, z) expressed in the World system.
  19469. * @param x x coordinate
  19470. * @param z z coordinate
  19471. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19472. */
  19473. getNormalAtCoordinates(x: number, z: number): Vector3;
  19474. /**
  19475. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19476. * at the ground coordinates (x, z) expressed in the World system.
  19477. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19478. * @param x x coordinate
  19479. * @param z z coordinate
  19480. * @param ref vector to store the result
  19481. * @returns the GroundMesh.
  19482. */
  19483. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19484. /**
  19485. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19486. * if the ground has been updated.
  19487. * This can be used in the render loop.
  19488. * @returns the GroundMesh.
  19489. */
  19490. updateCoordinateHeights(): GroundMesh;
  19491. private _getFacetAt;
  19492. private _initHeightQuads;
  19493. private _computeHeightQuads;
  19494. /**
  19495. * Serializes this ground mesh
  19496. * @param serializationObject object to write serialization to
  19497. */
  19498. serialize(serializationObject: any): void;
  19499. /**
  19500. * Parses a serialized ground mesh
  19501. * @param parsedMesh the serialized mesh
  19502. * @param scene the scene to create the ground mesh in
  19503. * @returns the created ground mesh
  19504. */
  19505. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19506. }
  19507. }
  19508. declare module "babylonjs/Physics/physicsJoint" {
  19509. import { Vector3 } from "babylonjs/Maths/math";
  19510. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19511. /**
  19512. * Interface for Physics-Joint data
  19513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19514. */
  19515. export interface PhysicsJointData {
  19516. /**
  19517. * The main pivot of the joint
  19518. */
  19519. mainPivot?: Vector3;
  19520. /**
  19521. * The connected pivot of the joint
  19522. */
  19523. connectedPivot?: Vector3;
  19524. /**
  19525. * The main axis of the joint
  19526. */
  19527. mainAxis?: Vector3;
  19528. /**
  19529. * The connected axis of the joint
  19530. */
  19531. connectedAxis?: Vector3;
  19532. /**
  19533. * The collision of the joint
  19534. */
  19535. collision?: boolean;
  19536. /**
  19537. * Native Oimo/Cannon/Energy data
  19538. */
  19539. nativeParams?: any;
  19540. }
  19541. /**
  19542. * This is a holder class for the physics joint created by the physics plugin
  19543. * It holds a set of functions to control the underlying joint
  19544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19545. */
  19546. export class PhysicsJoint {
  19547. /**
  19548. * The type of the physics joint
  19549. */
  19550. type: number;
  19551. /**
  19552. * The data for the physics joint
  19553. */
  19554. jointData: PhysicsJointData;
  19555. private _physicsJoint;
  19556. protected _physicsPlugin: IPhysicsEnginePlugin;
  19557. /**
  19558. * Initializes the physics joint
  19559. * @param type The type of the physics joint
  19560. * @param jointData The data for the physics joint
  19561. */
  19562. constructor(
  19563. /**
  19564. * The type of the physics joint
  19565. */
  19566. type: number,
  19567. /**
  19568. * The data for the physics joint
  19569. */
  19570. jointData: PhysicsJointData);
  19571. /**
  19572. * Gets the physics joint
  19573. */
  19574. /**
  19575. * Sets the physics joint
  19576. */
  19577. physicsJoint: any;
  19578. /**
  19579. * Sets the physics plugin
  19580. */
  19581. physicsPlugin: IPhysicsEnginePlugin;
  19582. /**
  19583. * Execute a function that is physics-plugin specific.
  19584. * @param {Function} func the function that will be executed.
  19585. * It accepts two parameters: the physics world and the physics joint
  19586. */
  19587. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19588. /**
  19589. * Distance-Joint type
  19590. */
  19591. static DistanceJoint: number;
  19592. /**
  19593. * Hinge-Joint type
  19594. */
  19595. static HingeJoint: number;
  19596. /**
  19597. * Ball-and-Socket joint type
  19598. */
  19599. static BallAndSocketJoint: number;
  19600. /**
  19601. * Wheel-Joint type
  19602. */
  19603. static WheelJoint: number;
  19604. /**
  19605. * Slider-Joint type
  19606. */
  19607. static SliderJoint: number;
  19608. /**
  19609. * Prismatic-Joint type
  19610. */
  19611. static PrismaticJoint: number;
  19612. /**
  19613. * Universal-Joint type
  19614. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19615. */
  19616. static UniversalJoint: number;
  19617. /**
  19618. * Hinge-Joint 2 type
  19619. */
  19620. static Hinge2Joint: number;
  19621. /**
  19622. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19623. */
  19624. static PointToPointJoint: number;
  19625. /**
  19626. * Spring-Joint type
  19627. */
  19628. static SpringJoint: number;
  19629. /**
  19630. * Lock-Joint type
  19631. */
  19632. static LockJoint: number;
  19633. }
  19634. /**
  19635. * A class representing a physics distance joint
  19636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19637. */
  19638. export class DistanceJoint extends PhysicsJoint {
  19639. /**
  19640. *
  19641. * @param jointData The data for the Distance-Joint
  19642. */
  19643. constructor(jointData: DistanceJointData);
  19644. /**
  19645. * Update the predefined distance.
  19646. * @param maxDistance The maximum preferred distance
  19647. * @param minDistance The minimum preferred distance
  19648. */
  19649. updateDistance(maxDistance: number, minDistance?: number): void;
  19650. }
  19651. /**
  19652. * Represents a Motor-Enabled Joint
  19653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19654. */
  19655. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19656. /**
  19657. * Initializes the Motor-Enabled Joint
  19658. * @param type The type of the joint
  19659. * @param jointData The physica joint data for the joint
  19660. */
  19661. constructor(type: number, jointData: PhysicsJointData);
  19662. /**
  19663. * Set the motor values.
  19664. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19665. * @param force the force to apply
  19666. * @param maxForce max force for this motor.
  19667. */
  19668. setMotor(force?: number, maxForce?: number): void;
  19669. /**
  19670. * Set the motor's limits.
  19671. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19672. * @param upperLimit The upper limit of the motor
  19673. * @param lowerLimit The lower limit of the motor
  19674. */
  19675. setLimit(upperLimit: number, lowerLimit?: number): void;
  19676. }
  19677. /**
  19678. * This class represents a single physics Hinge-Joint
  19679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19680. */
  19681. export class HingeJoint extends MotorEnabledJoint {
  19682. /**
  19683. * Initializes the Hinge-Joint
  19684. * @param jointData The joint data for the Hinge-Joint
  19685. */
  19686. constructor(jointData: PhysicsJointData);
  19687. /**
  19688. * Set the motor values.
  19689. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19690. * @param {number} force the force to apply
  19691. * @param {number} maxForce max force for this motor.
  19692. */
  19693. setMotor(force?: number, maxForce?: number): void;
  19694. /**
  19695. * Set the motor's limits.
  19696. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19697. * @param upperLimit The upper limit of the motor
  19698. * @param lowerLimit The lower limit of the motor
  19699. */
  19700. setLimit(upperLimit: number, lowerLimit?: number): void;
  19701. }
  19702. /**
  19703. * This class represents a dual hinge physics joint (same as wheel joint)
  19704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19705. */
  19706. export class Hinge2Joint extends MotorEnabledJoint {
  19707. /**
  19708. * Initializes the Hinge2-Joint
  19709. * @param jointData The joint data for the Hinge2-Joint
  19710. */
  19711. constructor(jointData: PhysicsJointData);
  19712. /**
  19713. * Set the motor values.
  19714. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19715. * @param {number} targetSpeed the speed the motor is to reach
  19716. * @param {number} maxForce max force for this motor.
  19717. * @param {motorIndex} the motor's index, 0 or 1.
  19718. */
  19719. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19720. /**
  19721. * Set the motor limits.
  19722. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19723. * @param {number} upperLimit the upper limit
  19724. * @param {number} lowerLimit lower limit
  19725. * @param {motorIndex} the motor's index, 0 or 1.
  19726. */
  19727. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19728. }
  19729. /**
  19730. * Interface for a motor enabled joint
  19731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19732. */
  19733. export interface IMotorEnabledJoint {
  19734. /**
  19735. * Physics joint
  19736. */
  19737. physicsJoint: any;
  19738. /**
  19739. * Sets the motor of the motor-enabled joint
  19740. * @param force The force of the motor
  19741. * @param maxForce The maximum force of the motor
  19742. * @param motorIndex The index of the motor
  19743. */
  19744. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19745. /**
  19746. * Sets the limit of the motor
  19747. * @param upperLimit The upper limit of the motor
  19748. * @param lowerLimit The lower limit of the motor
  19749. * @param motorIndex The index of the motor
  19750. */
  19751. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19752. }
  19753. /**
  19754. * Joint data for a Distance-Joint
  19755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19756. */
  19757. export interface DistanceJointData extends PhysicsJointData {
  19758. /**
  19759. * Max distance the 2 joint objects can be apart
  19760. */
  19761. maxDistance: number;
  19762. }
  19763. /**
  19764. * Joint data from a spring joint
  19765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19766. */
  19767. export interface SpringJointData extends PhysicsJointData {
  19768. /**
  19769. * Length of the spring
  19770. */
  19771. length: number;
  19772. /**
  19773. * Stiffness of the spring
  19774. */
  19775. stiffness: number;
  19776. /**
  19777. * Damping of the spring
  19778. */
  19779. damping: number;
  19780. /** this callback will be called when applying the force to the impostors. */
  19781. forceApplicationCallback: () => void;
  19782. }
  19783. }
  19784. declare module "babylonjs/Physics/IPhysicsEngine" {
  19785. import { Nullable } from "babylonjs/types";
  19786. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19788. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19789. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19790. /**
  19791. * Interface used to describe a physics joint
  19792. */
  19793. export interface PhysicsImpostorJoint {
  19794. /** Defines the main impostor to which the joint is linked */
  19795. mainImpostor: PhysicsImpostor;
  19796. /** Defines the impostor that is connected to the main impostor using this joint */
  19797. connectedImpostor: PhysicsImpostor;
  19798. /** Defines the joint itself */
  19799. joint: PhysicsJoint;
  19800. }
  19801. /** @hidden */
  19802. export interface IPhysicsEnginePlugin {
  19803. world: any;
  19804. name: string;
  19805. setGravity(gravity: Vector3): void;
  19806. setTimeStep(timeStep: number): void;
  19807. getTimeStep(): number;
  19808. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19809. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19810. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19811. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19812. removePhysicsBody(impostor: PhysicsImpostor): void;
  19813. generateJoint(joint: PhysicsImpostorJoint): void;
  19814. removeJoint(joint: PhysicsImpostorJoint): void;
  19815. isSupported(): boolean;
  19816. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19817. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19818. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19819. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19820. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19821. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19822. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19823. getBodyMass(impostor: PhysicsImpostor): number;
  19824. getBodyFriction(impostor: PhysicsImpostor): number;
  19825. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19826. getBodyRestitution(impostor: PhysicsImpostor): number;
  19827. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19828. sleepBody(impostor: PhysicsImpostor): void;
  19829. wakeUpBody(impostor: PhysicsImpostor): void;
  19830. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19831. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19832. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19833. getRadius(impostor: PhysicsImpostor): number;
  19834. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19835. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19836. dispose(): void;
  19837. }
  19838. /**
  19839. * Interface used to define a physics engine
  19840. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19841. */
  19842. export interface IPhysicsEngine {
  19843. /**
  19844. * Gets the gravity vector used by the simulation
  19845. */
  19846. gravity: Vector3;
  19847. /**
  19848. * Sets the gravity vector used by the simulation
  19849. * @param gravity defines the gravity vector to use
  19850. */
  19851. setGravity(gravity: Vector3): void;
  19852. /**
  19853. * Set the time step of the physics engine.
  19854. * Default is 1/60.
  19855. * To slow it down, enter 1/600 for example.
  19856. * To speed it up, 1/30
  19857. * @param newTimeStep the new timestep to apply to this world.
  19858. */
  19859. setTimeStep(newTimeStep: number): void;
  19860. /**
  19861. * Get the time step of the physics engine.
  19862. * @returns the current time step
  19863. */
  19864. getTimeStep(): number;
  19865. /**
  19866. * Release all resources
  19867. */
  19868. dispose(): void;
  19869. /**
  19870. * Gets the name of the current physics plugin
  19871. * @returns the name of the plugin
  19872. */
  19873. getPhysicsPluginName(): string;
  19874. /**
  19875. * Adding a new impostor for the impostor tracking.
  19876. * This will be done by the impostor itself.
  19877. * @param impostor the impostor to add
  19878. */
  19879. addImpostor(impostor: PhysicsImpostor): void;
  19880. /**
  19881. * Remove an impostor from the engine.
  19882. * This impostor and its mesh will not longer be updated by the physics engine.
  19883. * @param impostor the impostor to remove
  19884. */
  19885. removeImpostor(impostor: PhysicsImpostor): void;
  19886. /**
  19887. * Add a joint to the physics engine
  19888. * @param mainImpostor defines the main impostor to which the joint is added.
  19889. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19890. * @param joint defines the joint that will connect both impostors.
  19891. */
  19892. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19893. /**
  19894. * Removes a joint from the simulation
  19895. * @param mainImpostor defines the impostor used with the joint
  19896. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19897. * @param joint defines the joint to remove
  19898. */
  19899. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19900. /**
  19901. * Gets the current plugin used to run the simulation
  19902. * @returns current plugin
  19903. */
  19904. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19905. /**
  19906. * Gets the list of physic impostors
  19907. * @returns an array of PhysicsImpostor
  19908. */
  19909. getImpostors(): Array<PhysicsImpostor>;
  19910. /**
  19911. * Gets the impostor for a physics enabled object
  19912. * @param object defines the object impersonated by the impostor
  19913. * @returns the PhysicsImpostor or null if not found
  19914. */
  19915. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19916. /**
  19917. * Gets the impostor for a physics body object
  19918. * @param body defines physics body used by the impostor
  19919. * @returns the PhysicsImpostor or null if not found
  19920. */
  19921. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19922. /**
  19923. * Called by the scene. No need to call it.
  19924. * @param delta defines the timespam between frames
  19925. */
  19926. _step(delta: number): void;
  19927. }
  19928. }
  19929. declare module "babylonjs/Physics/physicsImpostor" {
  19930. import { Nullable, IndicesArray } from "babylonjs/types";
  19931. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19932. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19934. import { Scene } from "babylonjs/scene";
  19935. import { Bone } from "babylonjs/Bones/bone";
  19936. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19937. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19938. /**
  19939. * The interface for the physics imposter parameters
  19940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19941. */
  19942. export interface PhysicsImpostorParameters {
  19943. /**
  19944. * The mass of the physics imposter
  19945. */
  19946. mass: number;
  19947. /**
  19948. * The friction of the physics imposter
  19949. */
  19950. friction?: number;
  19951. /**
  19952. * The coefficient of restitution of the physics imposter
  19953. */
  19954. restitution?: number;
  19955. /**
  19956. * The native options of the physics imposter
  19957. */
  19958. nativeOptions?: any;
  19959. /**
  19960. * Specifies if the parent should be ignored
  19961. */
  19962. ignoreParent?: boolean;
  19963. /**
  19964. * Specifies if bi-directional transformations should be disabled
  19965. */
  19966. disableBidirectionalTransformation?: boolean;
  19967. }
  19968. /**
  19969. * Interface for a physics-enabled object
  19970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19971. */
  19972. export interface IPhysicsEnabledObject {
  19973. /**
  19974. * The position of the physics-enabled object
  19975. */
  19976. position: Vector3;
  19977. /**
  19978. * The rotation of the physics-enabled object
  19979. */
  19980. rotationQuaternion: Nullable<Quaternion>;
  19981. /**
  19982. * The scale of the physics-enabled object
  19983. */
  19984. scaling: Vector3;
  19985. /**
  19986. * The rotation of the physics-enabled object
  19987. */
  19988. rotation?: Vector3;
  19989. /**
  19990. * The parent of the physics-enabled object
  19991. */
  19992. parent?: any;
  19993. /**
  19994. * The bounding info of the physics-enabled object
  19995. * @returns The bounding info of the physics-enabled object
  19996. */
  19997. getBoundingInfo(): BoundingInfo;
  19998. /**
  19999. * Computes the world matrix
  20000. * @param force Specifies if the world matrix should be computed by force
  20001. * @returns A world matrix
  20002. */
  20003. computeWorldMatrix(force: boolean): Matrix;
  20004. /**
  20005. * Gets the world matrix
  20006. * @returns A world matrix
  20007. */
  20008. getWorldMatrix?(): Matrix;
  20009. /**
  20010. * Gets the child meshes
  20011. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20012. * @returns An array of abstract meshes
  20013. */
  20014. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20015. /**
  20016. * Gets the vertex data
  20017. * @param kind The type of vertex data
  20018. * @returns A nullable array of numbers, or a float32 array
  20019. */
  20020. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20021. /**
  20022. * Gets the indices from the mesh
  20023. * @returns A nullable array of index arrays
  20024. */
  20025. getIndices?(): Nullable<IndicesArray>;
  20026. /**
  20027. * Gets the scene from the mesh
  20028. * @returns the indices array or null
  20029. */
  20030. getScene?(): Scene;
  20031. /**
  20032. * Gets the absolute position from the mesh
  20033. * @returns the absolute position
  20034. */
  20035. getAbsolutePosition(): Vector3;
  20036. /**
  20037. * Gets the absolute pivot point from the mesh
  20038. * @returns the absolute pivot point
  20039. */
  20040. getAbsolutePivotPoint(): Vector3;
  20041. /**
  20042. * Rotates the mesh
  20043. * @param axis The axis of rotation
  20044. * @param amount The amount of rotation
  20045. * @param space The space of the rotation
  20046. * @returns The rotation transform node
  20047. */
  20048. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20049. /**
  20050. * Translates the mesh
  20051. * @param axis The axis of translation
  20052. * @param distance The distance of translation
  20053. * @param space The space of the translation
  20054. * @returns The transform node
  20055. */
  20056. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20057. /**
  20058. * Sets the absolute position of the mesh
  20059. * @param absolutePosition The absolute position of the mesh
  20060. * @returns The transform node
  20061. */
  20062. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20063. /**
  20064. * Gets the class name of the mesh
  20065. * @returns The class name
  20066. */
  20067. getClassName(): string;
  20068. }
  20069. /**
  20070. * Represents a physics imposter
  20071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20072. */
  20073. export class PhysicsImpostor {
  20074. /**
  20075. * The physics-enabled object used as the physics imposter
  20076. */
  20077. object: IPhysicsEnabledObject;
  20078. /**
  20079. * The type of the physics imposter
  20080. */
  20081. type: number;
  20082. private _options;
  20083. private _scene?;
  20084. /**
  20085. * The default object size of the imposter
  20086. */
  20087. static DEFAULT_OBJECT_SIZE: Vector3;
  20088. /**
  20089. * The identity quaternion of the imposter
  20090. */
  20091. static IDENTITY_QUATERNION: Quaternion;
  20092. /** @hidden */
  20093. _pluginData: any;
  20094. private _physicsEngine;
  20095. private _physicsBody;
  20096. private _bodyUpdateRequired;
  20097. private _onBeforePhysicsStepCallbacks;
  20098. private _onAfterPhysicsStepCallbacks;
  20099. /** @hidden */
  20100. _onPhysicsCollideCallbacks: Array<{
  20101. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20102. otherImpostors: Array<PhysicsImpostor>;
  20103. }>;
  20104. private _deltaPosition;
  20105. private _deltaRotation;
  20106. private _deltaRotationConjugated;
  20107. private _parent;
  20108. private _isDisposed;
  20109. private static _tmpVecs;
  20110. private static _tmpQuat;
  20111. /**
  20112. * Specifies if the physics imposter is disposed
  20113. */
  20114. readonly isDisposed: boolean;
  20115. /**
  20116. * Gets the mass of the physics imposter
  20117. */
  20118. mass: number;
  20119. /**
  20120. * Gets the coefficient of friction
  20121. */
  20122. /**
  20123. * Sets the coefficient of friction
  20124. */
  20125. friction: number;
  20126. /**
  20127. * Gets the coefficient of restitution
  20128. */
  20129. /**
  20130. * Sets the coefficient of restitution
  20131. */
  20132. restitution: number;
  20133. /**
  20134. * The unique id of the physics imposter
  20135. * set by the physics engine when adding this impostor to the array
  20136. */
  20137. uniqueId: number;
  20138. private _joints;
  20139. /**
  20140. * Initializes the physics imposter
  20141. * @param object The physics-enabled object used as the physics imposter
  20142. * @param type The type of the physics imposter
  20143. * @param _options The options for the physics imposter
  20144. * @param _scene The Babylon scene
  20145. */
  20146. constructor(
  20147. /**
  20148. * The physics-enabled object used as the physics imposter
  20149. */
  20150. object: IPhysicsEnabledObject,
  20151. /**
  20152. * The type of the physics imposter
  20153. */
  20154. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20155. /**
  20156. * This function will completly initialize this impostor.
  20157. * It will create a new body - but only if this mesh has no parent.
  20158. * If it has, this impostor will not be used other than to define the impostor
  20159. * of the child mesh.
  20160. * @hidden
  20161. */
  20162. _init(): void;
  20163. private _getPhysicsParent;
  20164. /**
  20165. * Should a new body be generated.
  20166. * @returns boolean specifying if body initialization is required
  20167. */
  20168. isBodyInitRequired(): boolean;
  20169. /**
  20170. * Sets the updated scaling
  20171. * @param updated Specifies if the scaling is updated
  20172. */
  20173. setScalingUpdated(): void;
  20174. /**
  20175. * Force a regeneration of this or the parent's impostor's body.
  20176. * Use under cautious - This will remove all joints already implemented.
  20177. */
  20178. forceUpdate(): void;
  20179. /**
  20180. * Gets the body that holds this impostor. Either its own, or its parent.
  20181. */
  20182. /**
  20183. * Set the physics body. Used mainly by the physics engine/plugin
  20184. */
  20185. physicsBody: any;
  20186. /**
  20187. * Get the parent of the physics imposter
  20188. * @returns Physics imposter or null
  20189. */
  20190. /**
  20191. * Sets the parent of the physics imposter
  20192. */
  20193. parent: Nullable<PhysicsImpostor>;
  20194. /**
  20195. * Resets the update flags
  20196. */
  20197. resetUpdateFlags(): void;
  20198. /**
  20199. * Gets the object extend size
  20200. * @returns the object extend size
  20201. */
  20202. getObjectExtendSize(): Vector3;
  20203. /**
  20204. * Gets the object center
  20205. * @returns The object center
  20206. */
  20207. getObjectCenter(): Vector3;
  20208. /**
  20209. * Get a specific parametes from the options parameter
  20210. * @param paramName The object parameter name
  20211. * @returns The object parameter
  20212. */
  20213. getParam(paramName: string): any;
  20214. /**
  20215. * Sets a specific parameter in the options given to the physics plugin
  20216. * @param paramName The parameter name
  20217. * @param value The value of the parameter
  20218. */
  20219. setParam(paramName: string, value: number): void;
  20220. /**
  20221. * Specifically change the body's mass option. Won't recreate the physics body object
  20222. * @param mass The mass of the physics imposter
  20223. */
  20224. setMass(mass: number): void;
  20225. /**
  20226. * Gets the linear velocity
  20227. * @returns linear velocity or null
  20228. */
  20229. getLinearVelocity(): Nullable<Vector3>;
  20230. /**
  20231. * Sets the linear velocity
  20232. * @param velocity linear velocity or null
  20233. */
  20234. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20235. /**
  20236. * Gets the angular velocity
  20237. * @returns angular velocity or null
  20238. */
  20239. getAngularVelocity(): Nullable<Vector3>;
  20240. /**
  20241. * Sets the angular velocity
  20242. * @param velocity The velocity or null
  20243. */
  20244. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20245. /**
  20246. * Execute a function with the physics plugin native code
  20247. * Provide a function the will have two variables - the world object and the physics body object
  20248. * @param func The function to execute with the physics plugin native code
  20249. */
  20250. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20251. /**
  20252. * Register a function that will be executed before the physics world is stepping forward
  20253. * @param func The function to execute before the physics world is stepped forward
  20254. */
  20255. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20256. /**
  20257. * Unregister a function that will be executed before the physics world is stepping forward
  20258. * @param func The function to execute before the physics world is stepped forward
  20259. */
  20260. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20261. /**
  20262. * Register a function that will be executed after the physics step
  20263. * @param func The function to execute after physics step
  20264. */
  20265. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20266. /**
  20267. * Unregisters a function that will be executed after the physics step
  20268. * @param func The function to execute after physics step
  20269. */
  20270. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20271. /**
  20272. * register a function that will be executed when this impostor collides against a different body
  20273. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20274. * @param func Callback that is executed on collision
  20275. */
  20276. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20277. /**
  20278. * Unregisters the physics imposter on contact
  20279. * @param collideAgainst The physics object to collide against
  20280. * @param func Callback to execute on collision
  20281. */
  20282. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20283. private _tmpQuat;
  20284. private _tmpQuat2;
  20285. /**
  20286. * Get the parent rotation
  20287. * @returns The parent rotation
  20288. */
  20289. getParentsRotation(): Quaternion;
  20290. /**
  20291. * this function is executed by the physics engine.
  20292. */
  20293. beforeStep: () => void;
  20294. /**
  20295. * this function is executed by the physics engine
  20296. */
  20297. afterStep: () => void;
  20298. /**
  20299. * Legacy collision detection event support
  20300. */
  20301. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20302. /**
  20303. * event and body object due to cannon's event-based architecture.
  20304. */
  20305. onCollide: (e: {
  20306. body: any;
  20307. }) => void;
  20308. /**
  20309. * Apply a force
  20310. * @param force The force to apply
  20311. * @param contactPoint The contact point for the force
  20312. * @returns The physics imposter
  20313. */
  20314. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20315. /**
  20316. * Apply an impulse
  20317. * @param force The impulse force
  20318. * @param contactPoint The contact point for the impulse force
  20319. * @returns The physics imposter
  20320. */
  20321. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20322. /**
  20323. * A help function to create a joint
  20324. * @param otherImpostor A physics imposter used to create a joint
  20325. * @param jointType The type of joint
  20326. * @param jointData The data for the joint
  20327. * @returns The physics imposter
  20328. */
  20329. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20330. /**
  20331. * Add a joint to this impostor with a different impostor
  20332. * @param otherImpostor A physics imposter used to add a joint
  20333. * @param joint The joint to add
  20334. * @returns The physics imposter
  20335. */
  20336. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20337. /**
  20338. * Will keep this body still, in a sleep mode.
  20339. * @returns the physics imposter
  20340. */
  20341. sleep(): PhysicsImpostor;
  20342. /**
  20343. * Wake the body up.
  20344. * @returns The physics imposter
  20345. */
  20346. wakeUp(): PhysicsImpostor;
  20347. /**
  20348. * Clones the physics imposter
  20349. * @param newObject The physics imposter clones to this physics-enabled object
  20350. * @returns A nullable physics imposter
  20351. */
  20352. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20353. /**
  20354. * Disposes the physics imposter
  20355. */
  20356. dispose(): void;
  20357. /**
  20358. * Sets the delta position
  20359. * @param position The delta position amount
  20360. */
  20361. setDeltaPosition(position: Vector3): void;
  20362. /**
  20363. * Sets the delta rotation
  20364. * @param rotation The delta rotation amount
  20365. */
  20366. setDeltaRotation(rotation: Quaternion): void;
  20367. /**
  20368. * Gets the box size of the physics imposter and stores the result in the input parameter
  20369. * @param result Stores the box size
  20370. * @returns The physics imposter
  20371. */
  20372. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20373. /**
  20374. * Gets the radius of the physics imposter
  20375. * @returns Radius of the physics imposter
  20376. */
  20377. getRadius(): number;
  20378. /**
  20379. * Sync a bone with this impostor
  20380. * @param bone The bone to sync to the impostor.
  20381. * @param boneMesh The mesh that the bone is influencing.
  20382. * @param jointPivot The pivot of the joint / bone in local space.
  20383. * @param distToJoint Optional distance from the impostor to the joint.
  20384. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20385. */
  20386. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20387. /**
  20388. * Sync impostor to a bone
  20389. * @param bone The bone that the impostor will be synced to.
  20390. * @param boneMesh The mesh that the bone is influencing.
  20391. * @param jointPivot The pivot of the joint / bone in local space.
  20392. * @param distToJoint Optional distance from the impostor to the joint.
  20393. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20394. * @param boneAxis Optional vector3 axis the bone is aligned with
  20395. */
  20396. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20397. /**
  20398. * No-Imposter type
  20399. */
  20400. static NoImpostor: number;
  20401. /**
  20402. * Sphere-Imposter type
  20403. */
  20404. static SphereImpostor: number;
  20405. /**
  20406. * Box-Imposter type
  20407. */
  20408. static BoxImpostor: number;
  20409. /**
  20410. * Plane-Imposter type
  20411. */
  20412. static PlaneImpostor: number;
  20413. /**
  20414. * Mesh-imposter type
  20415. */
  20416. static MeshImpostor: number;
  20417. /**
  20418. * Cylinder-Imposter type
  20419. */
  20420. static CylinderImpostor: number;
  20421. /**
  20422. * Particle-Imposter type
  20423. */
  20424. static ParticleImpostor: number;
  20425. /**
  20426. * Heightmap-Imposter type
  20427. */
  20428. static HeightmapImpostor: number;
  20429. }
  20430. }
  20431. declare module "babylonjs/Meshes/mesh" {
  20432. import { Observable } from "babylonjs/Misc/observable";
  20433. import { IAnimatable } from "babylonjs/Misc/tools";
  20434. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20435. import { Camera } from "babylonjs/Cameras/camera";
  20436. import { Scene } from "babylonjs/scene";
  20437. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20438. import { Engine } from "babylonjs/Engines/engine";
  20439. import { Node } from "babylonjs/node";
  20440. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20441. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20442. import { Buffer } from "babylonjs/Meshes/buffer";
  20443. import { Geometry } from "babylonjs/Meshes/geometry";
  20444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20446. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20447. import { Effect } from "babylonjs/Materials/effect";
  20448. import { Material } from "babylonjs/Materials/material";
  20449. import { Skeleton } from "babylonjs/Bones/skeleton";
  20450. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20451. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20452. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20453. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20454. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20455. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20456. /**
  20457. * Class used to represent a specific level of detail of a mesh
  20458. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20459. */
  20460. export class MeshLODLevel {
  20461. /** Defines the distance where this level should star being displayed */
  20462. distance: number;
  20463. /** Defines the mesh to use to render this level */
  20464. mesh: Nullable<Mesh>;
  20465. /**
  20466. * Creates a new LOD level
  20467. * @param distance defines the distance where this level should star being displayed
  20468. * @param mesh defines the mesh to use to render this level
  20469. */
  20470. constructor(
  20471. /** Defines the distance where this level should star being displayed */
  20472. distance: number,
  20473. /** Defines the mesh to use to render this level */
  20474. mesh: Nullable<Mesh>);
  20475. }
  20476. /**
  20477. * @hidden
  20478. **/
  20479. export class _CreationDataStorage {
  20480. closePath?: boolean;
  20481. closeArray?: boolean;
  20482. idx: number[];
  20483. dashSize: number;
  20484. gapSize: number;
  20485. path3D: Path3D;
  20486. pathArray: Vector3[][];
  20487. arc: number;
  20488. radius: number;
  20489. cap: number;
  20490. tessellation: number;
  20491. }
  20492. /**
  20493. * @hidden
  20494. **/
  20495. class _InstanceDataStorage {
  20496. visibleInstances: any;
  20497. renderIdForInstances: number[];
  20498. batchCache: _InstancesBatch;
  20499. instancesBufferSize: number;
  20500. instancesBuffer: Nullable<Buffer>;
  20501. instancesData: Float32Array;
  20502. overridenInstanceCount: number;
  20503. }
  20504. /**
  20505. * @hidden
  20506. **/
  20507. export class _InstancesBatch {
  20508. mustReturn: boolean;
  20509. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20510. renderSelf: boolean[];
  20511. }
  20512. /**
  20513. * Class used to represent renderable models
  20514. */
  20515. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20516. /**
  20517. * Mesh side orientation : usually the external or front surface
  20518. */
  20519. static readonly FRONTSIDE: number;
  20520. /**
  20521. * Mesh side orientation : usually the internal or back surface
  20522. */
  20523. static readonly BACKSIDE: number;
  20524. /**
  20525. * Mesh side orientation : both internal and external or front and back surfaces
  20526. */
  20527. static readonly DOUBLESIDE: number;
  20528. /**
  20529. * Mesh side orientation : by default, `FRONTSIDE`
  20530. */
  20531. static readonly DEFAULTSIDE: number;
  20532. /**
  20533. * Mesh cap setting : no cap
  20534. */
  20535. static readonly NO_CAP: number;
  20536. /**
  20537. * Mesh cap setting : one cap at the beginning of the mesh
  20538. */
  20539. static readonly CAP_START: number;
  20540. /**
  20541. * Mesh cap setting : one cap at the end of the mesh
  20542. */
  20543. static readonly CAP_END: number;
  20544. /**
  20545. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20546. */
  20547. static readonly CAP_ALL: number;
  20548. /**
  20549. * Gets the default side orientation.
  20550. * @param orientation the orientation to value to attempt to get
  20551. * @returns the default orientation
  20552. * @hidden
  20553. */
  20554. static _GetDefaultSideOrientation(orientation?: number): number;
  20555. private _onBeforeRenderObservable;
  20556. private _onBeforeBindObservable;
  20557. private _onAfterRenderObservable;
  20558. private _onBeforeDrawObservable;
  20559. /**
  20560. * An event triggered before rendering the mesh
  20561. */
  20562. readonly onBeforeRenderObservable: Observable<Mesh>;
  20563. /**
  20564. * An event triggered before binding the mesh
  20565. */
  20566. readonly onBeforeBindObservable: Observable<Mesh>;
  20567. /**
  20568. * An event triggered after rendering the mesh
  20569. */
  20570. readonly onAfterRenderObservable: Observable<Mesh>;
  20571. /**
  20572. * An event triggered before drawing the mesh
  20573. */
  20574. readonly onBeforeDrawObservable: Observable<Mesh>;
  20575. private _onBeforeDrawObserver;
  20576. /**
  20577. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20578. */
  20579. onBeforeDraw: () => void;
  20580. /**
  20581. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20582. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20583. */
  20584. delayLoadState: number;
  20585. /**
  20586. * Gets the list of instances created from this mesh
  20587. * it is not supposed to be modified manually.
  20588. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20589. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20590. */
  20591. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20592. /**
  20593. * Gets the file containing delay loading data for this mesh
  20594. */
  20595. delayLoadingFile: string;
  20596. /** @hidden */
  20597. _binaryInfo: any;
  20598. private _LODLevels;
  20599. /**
  20600. * User defined function used to change how LOD level selection is done
  20601. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20602. */
  20603. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20604. private _morphTargetManager;
  20605. /**
  20606. * Gets or sets the morph target manager
  20607. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20608. */
  20609. morphTargetManager: Nullable<MorphTargetManager>;
  20610. /** @hidden */
  20611. _creationDataStorage: Nullable<_CreationDataStorage>;
  20612. /** @hidden */
  20613. _geometry: Nullable<Geometry>;
  20614. /** @hidden */
  20615. _delayInfo: Array<string>;
  20616. /** @hidden */
  20617. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20618. /** @hidden */
  20619. _instanceDataStorage: _InstanceDataStorage;
  20620. private _effectiveMaterial;
  20621. /** @hidden */
  20622. _shouldGenerateFlatShading: boolean;
  20623. private _preActivateId;
  20624. /** @hidden */
  20625. _originalBuilderSideOrientation: number;
  20626. /**
  20627. * Use this property to change the original side orientation defined at construction time
  20628. */
  20629. overrideMaterialSideOrientation: Nullable<number>;
  20630. private _areNormalsFrozen;
  20631. private _sourcePositions;
  20632. private _sourceNormals;
  20633. private _source;
  20634. private meshMap;
  20635. /**
  20636. * Gets the source mesh (the one used to clone this one from)
  20637. */
  20638. readonly source: Nullable<Mesh>;
  20639. /**
  20640. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20641. */
  20642. isUnIndexed: boolean;
  20643. /**
  20644. * @constructor
  20645. * @param name The value used by scene.getMeshByName() to do a lookup.
  20646. * @param scene The scene to add this mesh to.
  20647. * @param parent The parent of this mesh, if it has one
  20648. * @param source An optional Mesh from which geometry is shared, cloned.
  20649. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20650. * When false, achieved by calling a clone(), also passing False.
  20651. * This will make creation of children, recursive.
  20652. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20653. */
  20654. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20655. /**
  20656. * Gets the class name
  20657. * @returns the string "Mesh".
  20658. */
  20659. getClassName(): string;
  20660. /** @hidden */
  20661. readonly _isMesh: boolean;
  20662. /**
  20663. * Returns a description of this mesh
  20664. * @param fullDetails define if full details about this mesh must be used
  20665. * @returns a descriptive string representing this mesh
  20666. */
  20667. toString(fullDetails?: boolean): string;
  20668. /** @hidden */
  20669. _unBindEffect(): void;
  20670. /**
  20671. * Gets a boolean indicating if this mesh has LOD
  20672. */
  20673. readonly hasLODLevels: boolean;
  20674. /**
  20675. * Gets the list of MeshLODLevel associated with the current mesh
  20676. * @returns an array of MeshLODLevel
  20677. */
  20678. getLODLevels(): MeshLODLevel[];
  20679. private _sortLODLevels;
  20680. /**
  20681. * Add a mesh as LOD level triggered at the given distance.
  20682. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20683. * @param distance The distance from the center of the object to show this level
  20684. * @param mesh The mesh to be added as LOD level (can be null)
  20685. * @return This mesh (for chaining)
  20686. */
  20687. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20688. /**
  20689. * Returns the LOD level mesh at the passed distance or null if not found.
  20690. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20691. * @param distance The distance from the center of the object to show this level
  20692. * @returns a Mesh or `null`
  20693. */
  20694. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20695. /**
  20696. * Remove a mesh from the LOD array
  20697. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20698. * @param mesh defines the mesh to be removed
  20699. * @return This mesh (for chaining)
  20700. */
  20701. removeLODLevel(mesh: Mesh): Mesh;
  20702. /**
  20703. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20704. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20705. * @param camera defines the camera to use to compute distance
  20706. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20707. * @return This mesh (for chaining)
  20708. */
  20709. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20710. /**
  20711. * Gets the mesh internal Geometry object
  20712. */
  20713. readonly geometry: Nullable<Geometry>;
  20714. /**
  20715. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20716. * @returns the total number of vertices
  20717. */
  20718. getTotalVertices(): number;
  20719. /**
  20720. * Returns the content of an associated vertex buffer
  20721. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20722. * - VertexBuffer.PositionKind
  20723. * - VertexBuffer.UVKind
  20724. * - VertexBuffer.UV2Kind
  20725. * - VertexBuffer.UV3Kind
  20726. * - VertexBuffer.UV4Kind
  20727. * - VertexBuffer.UV5Kind
  20728. * - VertexBuffer.UV6Kind
  20729. * - VertexBuffer.ColorKind
  20730. * - VertexBuffer.MatricesIndicesKind
  20731. * - VertexBuffer.MatricesIndicesExtraKind
  20732. * - VertexBuffer.MatricesWeightsKind
  20733. * - VertexBuffer.MatricesWeightsExtraKind
  20734. * @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
  20735. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20736. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20737. */
  20738. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20739. /**
  20740. * Returns the mesh VertexBuffer object from the requested `kind`
  20741. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20742. * - VertexBuffer.PositionKind
  20743. * - VertexBuffer.UVKind
  20744. * - VertexBuffer.UV2Kind
  20745. * - VertexBuffer.UV3Kind
  20746. * - VertexBuffer.UV4Kind
  20747. * - VertexBuffer.UV5Kind
  20748. * - VertexBuffer.UV6Kind
  20749. * - VertexBuffer.ColorKind
  20750. * - VertexBuffer.MatricesIndicesKind
  20751. * - VertexBuffer.MatricesIndicesExtraKind
  20752. * - VertexBuffer.MatricesWeightsKind
  20753. * - VertexBuffer.MatricesWeightsExtraKind
  20754. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20755. */
  20756. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20757. /**
  20758. * Tests if a specific vertex buffer is associated with this mesh
  20759. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20760. * - VertexBuffer.PositionKind
  20761. * - VertexBuffer.UVKind
  20762. * - VertexBuffer.UV2Kind
  20763. * - VertexBuffer.UV3Kind
  20764. * - VertexBuffer.UV4Kind
  20765. * - VertexBuffer.UV5Kind
  20766. * - VertexBuffer.UV6Kind
  20767. * - VertexBuffer.ColorKind
  20768. * - VertexBuffer.MatricesIndicesKind
  20769. * - VertexBuffer.MatricesIndicesExtraKind
  20770. * - VertexBuffer.MatricesWeightsKind
  20771. * - VertexBuffer.MatricesWeightsExtraKind
  20772. * @returns a boolean
  20773. */
  20774. isVerticesDataPresent(kind: string): boolean;
  20775. /**
  20776. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20777. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20778. * - VertexBuffer.PositionKind
  20779. * - VertexBuffer.UVKind
  20780. * - VertexBuffer.UV2Kind
  20781. * - VertexBuffer.UV3Kind
  20782. * - VertexBuffer.UV4Kind
  20783. * - VertexBuffer.UV5Kind
  20784. * - VertexBuffer.UV6Kind
  20785. * - VertexBuffer.ColorKind
  20786. * - VertexBuffer.MatricesIndicesKind
  20787. * - VertexBuffer.MatricesIndicesExtraKind
  20788. * - VertexBuffer.MatricesWeightsKind
  20789. * - VertexBuffer.MatricesWeightsExtraKind
  20790. * @returns a boolean
  20791. */
  20792. isVertexBufferUpdatable(kind: string): boolean;
  20793. /**
  20794. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20795. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20796. * - VertexBuffer.PositionKind
  20797. * - VertexBuffer.UVKind
  20798. * - VertexBuffer.UV2Kind
  20799. * - VertexBuffer.UV3Kind
  20800. * - VertexBuffer.UV4Kind
  20801. * - VertexBuffer.UV5Kind
  20802. * - VertexBuffer.UV6Kind
  20803. * - VertexBuffer.ColorKind
  20804. * - VertexBuffer.MatricesIndicesKind
  20805. * - VertexBuffer.MatricesIndicesExtraKind
  20806. * - VertexBuffer.MatricesWeightsKind
  20807. * - VertexBuffer.MatricesWeightsExtraKind
  20808. * @returns an array of strings
  20809. */
  20810. getVerticesDataKinds(): string[];
  20811. /**
  20812. * Returns a positive integer : the total number of indices in this mesh geometry.
  20813. * @returns the numner of indices or zero if the mesh has no geometry.
  20814. */
  20815. getTotalIndices(): number;
  20816. /**
  20817. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20818. * @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.
  20819. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20820. * @returns the indices array or an empty array if the mesh has no geometry
  20821. */
  20822. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20823. readonly isBlocked: boolean;
  20824. /**
  20825. * Determine if the current mesh is ready to be rendered
  20826. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20827. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20828. * @returns true if all associated assets are ready (material, textures, shaders)
  20829. */
  20830. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20831. /**
  20832. * 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.
  20833. */
  20834. readonly areNormalsFrozen: boolean;
  20835. /**
  20836. * 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.
  20837. * @returns the current mesh
  20838. */
  20839. freezeNormals(): Mesh;
  20840. /**
  20841. * 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
  20842. * @returns the current mesh
  20843. */
  20844. unfreezeNormals(): Mesh;
  20845. /**
  20846. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20847. */
  20848. overridenInstanceCount: number;
  20849. /** @hidden */
  20850. _preActivate(): Mesh;
  20851. /** @hidden */
  20852. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20853. /** @hidden */
  20854. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20855. /**
  20856. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20857. * This means the mesh underlying bounding box and sphere are recomputed.
  20858. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20859. * @returns the current mesh
  20860. */
  20861. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20862. /** @hidden */
  20863. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20864. /**
  20865. * This function will subdivide the mesh into multiple submeshes
  20866. * @param count defines the expected number of submeshes
  20867. */
  20868. subdivide(count: number): void;
  20869. /**
  20870. * Copy a FloatArray into a specific associated vertex buffer
  20871. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20872. * - VertexBuffer.PositionKind
  20873. * - VertexBuffer.UVKind
  20874. * - VertexBuffer.UV2Kind
  20875. * - VertexBuffer.UV3Kind
  20876. * - VertexBuffer.UV4Kind
  20877. * - VertexBuffer.UV5Kind
  20878. * - VertexBuffer.UV6Kind
  20879. * - VertexBuffer.ColorKind
  20880. * - VertexBuffer.MatricesIndicesKind
  20881. * - VertexBuffer.MatricesIndicesExtraKind
  20882. * - VertexBuffer.MatricesWeightsKind
  20883. * - VertexBuffer.MatricesWeightsExtraKind
  20884. * @param data defines the data source
  20885. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20886. * @param stride defines the data stride size (can be null)
  20887. * @returns the current mesh
  20888. */
  20889. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20890. /**
  20891. * Flags an associated vertex buffer as updatable
  20892. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20893. * - VertexBuffer.PositionKind
  20894. * - VertexBuffer.UVKind
  20895. * - VertexBuffer.UV2Kind
  20896. * - VertexBuffer.UV3Kind
  20897. * - VertexBuffer.UV4Kind
  20898. * - VertexBuffer.UV5Kind
  20899. * - VertexBuffer.UV6Kind
  20900. * - VertexBuffer.ColorKind
  20901. * - VertexBuffer.MatricesIndicesKind
  20902. * - VertexBuffer.MatricesIndicesExtraKind
  20903. * - VertexBuffer.MatricesWeightsKind
  20904. * - VertexBuffer.MatricesWeightsExtraKind
  20905. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20906. */
  20907. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20908. /**
  20909. * Sets the mesh global Vertex Buffer
  20910. * @param buffer defines the buffer to use
  20911. * @returns the current mesh
  20912. */
  20913. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20914. /**
  20915. * Update a specific associated vertex buffer
  20916. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20917. * - VertexBuffer.PositionKind
  20918. * - VertexBuffer.UVKind
  20919. * - VertexBuffer.UV2Kind
  20920. * - VertexBuffer.UV3Kind
  20921. * - VertexBuffer.UV4Kind
  20922. * - VertexBuffer.UV5Kind
  20923. * - VertexBuffer.UV6Kind
  20924. * - VertexBuffer.ColorKind
  20925. * - VertexBuffer.MatricesIndicesKind
  20926. * - VertexBuffer.MatricesIndicesExtraKind
  20927. * - VertexBuffer.MatricesWeightsKind
  20928. * - VertexBuffer.MatricesWeightsExtraKind
  20929. * @param data defines the data source
  20930. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20931. * @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)
  20932. * @returns the current mesh
  20933. */
  20934. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20935. /**
  20936. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20937. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20938. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20939. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20940. * @returns the current mesh
  20941. */
  20942. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20943. /**
  20944. * Creates a un-shared specific occurence of the geometry for the mesh.
  20945. * @returns the current mesh
  20946. */
  20947. makeGeometryUnique(): Mesh;
  20948. /**
  20949. * Set the index buffer of this mesh
  20950. * @param indices defines the source data
  20951. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20952. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20953. * @returns the current mesh
  20954. */
  20955. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20956. /**
  20957. * Update the current index buffer
  20958. * @param indices defines the source data
  20959. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20960. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20961. * @returns the current mesh
  20962. */
  20963. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20964. /**
  20965. * Invert the geometry to move from a right handed system to a left handed one.
  20966. * @returns the current mesh
  20967. */
  20968. toLeftHanded(): Mesh;
  20969. /** @hidden */
  20970. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20971. /** @hidden */
  20972. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20973. /**
  20974. * Registers for this mesh a javascript function called just before the rendering process
  20975. * @param func defines the function to call before rendering this mesh
  20976. * @returns the current mesh
  20977. */
  20978. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20979. /**
  20980. * Disposes a previously registered javascript function called before the rendering
  20981. * @param func defines the function to remove
  20982. * @returns the current mesh
  20983. */
  20984. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20985. /**
  20986. * Registers for this mesh a javascript function called just after the rendering is complete
  20987. * @param func defines the function to call after rendering this mesh
  20988. * @returns the current mesh
  20989. */
  20990. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20991. /**
  20992. * Disposes a previously registered javascript function called after the rendering.
  20993. * @param func defines the function to remove
  20994. * @returns the current mesh
  20995. */
  20996. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20997. /** @hidden */
  20998. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20999. /** @hidden */
  21000. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21001. /** @hidden */
  21002. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21003. /**
  21004. * 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
  21005. * @param subMesh defines the subMesh to render
  21006. * @param enableAlphaMode defines if alpha mode can be changed
  21007. * @returns the current mesh
  21008. */
  21009. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21010. private _onBeforeDraw;
  21011. /**
  21012. * Renormalize the mesh and patch it up if there are no weights
  21013. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21014. * However in the case of zero weights then we set just a single influence to 1.
  21015. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21016. */
  21017. cleanMatrixWeights(): void;
  21018. private normalizeSkinFourWeights;
  21019. private normalizeSkinWeightsAndExtra;
  21020. /**
  21021. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21022. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21023. * the user know there was an issue with importing the mesh
  21024. * @returns a validation object with skinned, valid and report string
  21025. */
  21026. validateSkinning(): {
  21027. skinned: boolean;
  21028. valid: boolean;
  21029. report: string;
  21030. };
  21031. /** @hidden */
  21032. _checkDelayState(): Mesh;
  21033. private _queueLoad;
  21034. /**
  21035. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21036. * A mesh is in the frustum if its bounding box intersects the frustum
  21037. * @param frustumPlanes defines the frustum to test
  21038. * @returns true if the mesh is in the frustum planes
  21039. */
  21040. isInFrustum(frustumPlanes: Plane[]): boolean;
  21041. /**
  21042. * Sets the mesh material by the material or multiMaterial `id` property
  21043. * @param id is a string identifying the material or the multiMaterial
  21044. * @returns the current mesh
  21045. */
  21046. setMaterialByID(id: string): Mesh;
  21047. /**
  21048. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21049. * @returns an array of IAnimatable
  21050. */
  21051. getAnimatables(): IAnimatable[];
  21052. /**
  21053. * Modifies the mesh geometry according to the passed transformation matrix.
  21054. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21055. * The mesh normals are modified using the same transformation.
  21056. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21057. * @param transform defines the transform matrix to use
  21058. * @see http://doc.babylonjs.com/resources/baking_transformations
  21059. * @returns the current mesh
  21060. */
  21061. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21062. /**
  21063. * Modifies the mesh geometry according to its own current World Matrix.
  21064. * The mesh World Matrix is then reset.
  21065. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21066. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21067. * @see http://doc.babylonjs.com/resources/baking_transformations
  21068. * @returns the current mesh
  21069. */
  21070. bakeCurrentTransformIntoVertices(): Mesh;
  21071. /** @hidden */
  21072. readonly _positions: Nullable<Vector3[]>;
  21073. /** @hidden */
  21074. _resetPointsArrayCache(): Mesh;
  21075. /** @hidden */
  21076. _generatePointsArray(): boolean;
  21077. /**
  21078. * Returns a new Mesh object generated from the current mesh properties.
  21079. * This method must not get confused with createInstance()
  21080. * @param name is a string, the name given to the new mesh
  21081. * @param newParent can be any Node object (default `null`)
  21082. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21083. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21084. * @returns a new mesh
  21085. */
  21086. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21087. /**
  21088. * Releases resources associated with this mesh.
  21089. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21090. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21091. */
  21092. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21093. /**
  21094. * Modifies the mesh geometry according to a displacement map.
  21095. * 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.
  21096. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21097. * @param url is a string, the URL from the image file is to be downloaded.
  21098. * @param minHeight is the lower limit of the displacement.
  21099. * @param maxHeight is the upper limit of the displacement.
  21100. * @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.
  21101. * @param uvOffset is an optional vector2 used to offset UV.
  21102. * @param uvScale is an optional vector2 used to scale UV.
  21103. * @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.
  21104. * @returns the Mesh.
  21105. */
  21106. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21107. /**
  21108. * Modifies the mesh geometry according to a displacementMap buffer.
  21109. * 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.
  21110. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21111. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21112. * @param heightMapWidth is the width of the buffer image.
  21113. * @param heightMapHeight is the height of the buffer image.
  21114. * @param minHeight is the lower limit of the displacement.
  21115. * @param maxHeight is the upper limit of the displacement.
  21116. * @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.
  21117. * @param uvOffset is an optional vector2 used to offset UV.
  21118. * @param uvScale is an optional vector2 used to scale UV.
  21119. * @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.
  21120. * @returns the Mesh.
  21121. */
  21122. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21123. /**
  21124. * Modify the mesh to get a flat shading rendering.
  21125. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21126. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21127. * @returns current mesh
  21128. */
  21129. convertToFlatShadedMesh(): Mesh;
  21130. /**
  21131. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21132. * In other words, more vertices, no more indices and a single bigger VBO.
  21133. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21134. * @returns current mesh
  21135. */
  21136. convertToUnIndexedMesh(): Mesh;
  21137. /**
  21138. * Inverses facet orientations.
  21139. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21140. * @param flipNormals will also inverts the normals
  21141. * @returns current mesh
  21142. */
  21143. flipFaces(flipNormals?: boolean): Mesh;
  21144. /** @hidden */
  21145. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21146. /** @hidden */
  21147. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21148. /**
  21149. * Creates a new InstancedMesh object from the mesh model.
  21150. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21151. * @param name defines the name of the new instance
  21152. * @returns a new InstancedMesh
  21153. */
  21154. createInstance(name: string): InstancedMesh;
  21155. /**
  21156. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21157. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21158. * @returns the current mesh
  21159. */
  21160. synchronizeInstances(): Mesh;
  21161. /**
  21162. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21163. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21164. * This should be used together with the simplification to avoid disappearing triangles.
  21165. * @param successCallback an optional success callback to be called after the optimization finished.
  21166. * @returns the current mesh
  21167. */
  21168. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21169. /**
  21170. * Serialize current mesh
  21171. * @param serializationObject defines the object which will receive the serialization data
  21172. */
  21173. serialize(serializationObject: any): void;
  21174. /** @hidden */
  21175. _syncGeometryWithMorphTargetManager(): void;
  21176. /** @hidden */
  21177. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21178. /**
  21179. * Returns a new Mesh object parsed from the source provided.
  21180. * @param parsedMesh is the source
  21181. * @param scene defines the hosting scene
  21182. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21183. * @returns a new Mesh
  21184. */
  21185. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21186. /**
  21187. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21188. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21189. * @param name defines the name of the mesh to create
  21190. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21191. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21192. * @param closePath creates a seam between the first and the last points of each path of the path array
  21193. * @param offset is taken in account only if the `pathArray` is containing a single path
  21194. * @param scene defines the hosting scene
  21195. * @param updatable defines if the mesh must be flagged as updatable
  21196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21197. * @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)
  21198. * @returns a new Mesh
  21199. */
  21200. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21201. /**
  21202. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21203. * @param name defines the name of the mesh to create
  21204. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21205. * @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
  21206. * @param scene defines the hosting scene
  21207. * @param updatable defines if the mesh must be flagged as updatable
  21208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21209. * @returns a new Mesh
  21210. */
  21211. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21212. /**
  21213. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21214. * @param name defines the name of the mesh to create
  21215. * @param size sets the size (float) of each box side (default 1)
  21216. * @param scene defines the hosting scene
  21217. * @param updatable defines if the mesh must be flagged as updatable
  21218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21219. * @returns a new Mesh
  21220. */
  21221. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21222. /**
  21223. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21224. * @param name defines the name of the mesh to create
  21225. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21226. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21227. * @param scene defines the hosting scene
  21228. * @param updatable defines if the mesh must be flagged as updatable
  21229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21230. * @returns a new Mesh
  21231. */
  21232. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21233. /**
  21234. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21235. * @param name defines the name of the mesh to create
  21236. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21237. * @param diameterTop set the top cap diameter (floats, default 1)
  21238. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21239. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21240. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21241. * @param scene defines the hosting scene
  21242. * @param updatable defines if the mesh must be flagged as updatable
  21243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21244. * @returns a new Mesh
  21245. */
  21246. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21247. /**
  21248. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21249. * @param name defines the name of the mesh to create
  21250. * @param diameter sets the diameter size (float) of the torus (default 1)
  21251. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21252. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21253. * @param scene defines the hosting scene
  21254. * @param updatable defines if the mesh must be flagged as updatable
  21255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21256. * @returns a new Mesh
  21257. */
  21258. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21259. /**
  21260. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21261. * @param name defines the name of the mesh to create
  21262. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21263. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21264. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21265. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21266. * @param p the number of windings on X axis (positive integers, default 2)
  21267. * @param q the number of windings on Y axis (positive integers, default 3)
  21268. * @param scene defines the hosting scene
  21269. * @param updatable defines if the mesh must be flagged as updatable
  21270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21271. * @returns a new Mesh
  21272. */
  21273. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21274. /**
  21275. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21276. * @param name defines the name of the mesh to create
  21277. * @param points is an array successive Vector3
  21278. * @param scene defines the hosting scene
  21279. * @param updatable defines if the mesh must be flagged as updatable
  21280. * @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).
  21281. * @returns a new Mesh
  21282. */
  21283. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21284. /**
  21285. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21286. * @param name defines the name of the mesh to create
  21287. * @param points is an array successive Vector3
  21288. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21289. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21290. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21291. * @param scene defines the hosting scene
  21292. * @param updatable defines if the mesh must be flagged as updatable
  21293. * @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)
  21294. * @returns a new Mesh
  21295. */
  21296. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21297. /**
  21298. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21299. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21300. * 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.
  21301. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21302. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21303. * Remember you can only change the shape positions, not their number when updating a polygon.
  21304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21305. * @param name defines the name of the mesh to create
  21306. * @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
  21307. * @param scene defines the hosting scene
  21308. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21309. * @param updatable defines if the mesh must be flagged as updatable
  21310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21311. * @param earcutInjection can be used to inject your own earcut reference
  21312. * @returns a new Mesh
  21313. */
  21314. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21315. /**
  21316. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21317. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21318. * @param name defines the name of the mesh to create
  21319. * @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
  21320. * @param depth defines the height of extrusion
  21321. * @param scene defines the hosting scene
  21322. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21323. * @param updatable defines if the mesh must be flagged as updatable
  21324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21325. * @param earcutInjection can be used to inject your own earcut reference
  21326. * @returns a new Mesh
  21327. */
  21328. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21329. /**
  21330. * Creates an extruded shape mesh.
  21331. * 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
  21332. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21333. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21334. * @param name defines the name of the mesh to create
  21335. * @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
  21336. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21337. * @param scale is the value to scale the shape
  21338. * @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
  21339. * @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
  21340. * @param scene defines the hosting scene
  21341. * @param updatable defines if the mesh must be flagged as updatable
  21342. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21343. * @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)
  21344. * @returns a new Mesh
  21345. */
  21346. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21347. /**
  21348. * Creates an custom extruded shape mesh.
  21349. * The custom extrusion is a parametric shape.
  21350. * It has no predefined shape. Its final shape will depend on the input parameters.
  21351. * Please consider using the same method from the MeshBuilder class instead
  21352. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21353. * @param name defines the name of the mesh to create
  21354. * @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
  21355. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21356. * @param scaleFunction is a custom Javascript function called on each path point
  21357. * @param rotationFunction is a custom Javascript function called on each path point
  21358. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21359. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21360. * @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
  21361. * @param scene defines the hosting scene
  21362. * @param updatable defines if the mesh must be flagged as updatable
  21363. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21364. * @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)
  21365. * @returns a new Mesh
  21366. */
  21367. 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;
  21368. /**
  21369. * Creates lathe mesh.
  21370. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21371. * Please consider using the same method from the MeshBuilder class instead
  21372. * @param name defines the name of the mesh to create
  21373. * @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
  21374. * @param radius is the radius value of the lathe
  21375. * @param tessellation is the side number of the lathe.
  21376. * @param scene defines the hosting scene
  21377. * @param updatable defines if the mesh must be flagged as updatable
  21378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21379. * @returns a new Mesh
  21380. */
  21381. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21382. /**
  21383. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21384. * @param name defines the name of the mesh to create
  21385. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21386. * @param scene defines the hosting scene
  21387. * @param updatable defines if the mesh must be flagged as updatable
  21388. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21389. * @returns a new Mesh
  21390. */
  21391. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21392. /**
  21393. * Creates a ground mesh.
  21394. * Please consider using the same method from the MeshBuilder class instead
  21395. * @param name defines the name of the mesh to create
  21396. * @param width set the width of the ground
  21397. * @param height set the height of the ground
  21398. * @param subdivisions sets the number of subdivisions per side
  21399. * @param scene defines the hosting scene
  21400. * @param updatable defines if the mesh must be flagged as updatable
  21401. * @returns a new Mesh
  21402. */
  21403. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21404. /**
  21405. * Creates a tiled ground mesh.
  21406. * Please consider using the same method from the MeshBuilder class instead
  21407. * @param name defines the name of the mesh to create
  21408. * @param xmin set the ground minimum X coordinate
  21409. * @param zmin set the ground minimum Y coordinate
  21410. * @param xmax set the ground maximum X coordinate
  21411. * @param zmax set the ground maximum Z coordinate
  21412. * @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
  21413. * @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
  21414. * @param scene defines the hosting scene
  21415. * @param updatable defines if the mesh must be flagged as updatable
  21416. * @returns a new Mesh
  21417. */
  21418. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21419. w: number;
  21420. h: number;
  21421. }, precision: {
  21422. w: number;
  21423. h: number;
  21424. }, scene: Scene, updatable?: boolean): Mesh;
  21425. /**
  21426. * Creates a ground mesh from a height map.
  21427. * Please consider using the same method from the MeshBuilder class instead
  21428. * @see http://doc.babylonjs.com/babylon101/height_map
  21429. * @param name defines the name of the mesh to create
  21430. * @param url sets the URL of the height map image resource
  21431. * @param width set the ground width size
  21432. * @param height set the ground height size
  21433. * @param subdivisions sets the number of subdivision per side
  21434. * @param minHeight is the minimum altitude on the ground
  21435. * @param maxHeight is the maximum altitude on the ground
  21436. * @param scene defines the hosting scene
  21437. * @param updatable defines if the mesh must be flagged as updatable
  21438. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21439. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21440. * @returns a new Mesh
  21441. */
  21442. 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;
  21443. /**
  21444. * Creates a tube mesh.
  21445. * The tube is a parametric shape.
  21446. * It has no predefined shape. Its final shape will depend on the input parameters.
  21447. * Please consider using the same method from the MeshBuilder class instead
  21448. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21449. * @param name defines the name of the mesh to create
  21450. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21451. * @param radius sets the tube radius size
  21452. * @param tessellation is the number of sides on the tubular surface
  21453. * @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
  21454. * @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
  21455. * @param scene defines the hosting scene
  21456. * @param updatable defines if the mesh must be flagged as updatable
  21457. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21458. * @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)
  21459. * @returns a new Mesh
  21460. */
  21461. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21462. (i: number, distance: number): number;
  21463. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21464. /**
  21465. * Creates a polyhedron mesh.
  21466. * Please consider using the same method from the MeshBuilder class instead.
  21467. * * 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
  21468. * * The parameter `size` (positive float, default 1) sets the polygon size
  21469. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21470. * * 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`
  21471. * * 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
  21472. * * 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)`)
  21473. * * 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
  21474. * * 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
  21475. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21476. * * If you create a double-sided mesh, you can choose what parts of 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
  21477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21478. * @param name defines the name of the mesh to create
  21479. * @param options defines the options used to create the mesh
  21480. * @param scene defines the hosting scene
  21481. * @returns a new Mesh
  21482. */
  21483. static CreatePolyhedron(name: string, options: {
  21484. type?: number;
  21485. size?: number;
  21486. sizeX?: number;
  21487. sizeY?: number;
  21488. sizeZ?: number;
  21489. custom?: any;
  21490. faceUV?: Vector4[];
  21491. faceColors?: Color4[];
  21492. updatable?: boolean;
  21493. sideOrientation?: number;
  21494. }, scene: Scene): Mesh;
  21495. /**
  21496. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21497. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21498. * * 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`)
  21499. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21500. * * 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
  21501. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21502. * * If you create a double-sided mesh, you can choose what parts of 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
  21503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21504. * @param name defines the name of the mesh
  21505. * @param options defines the options used to create the mesh
  21506. * @param scene defines the hosting scene
  21507. * @returns a new Mesh
  21508. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21509. */
  21510. static CreateIcoSphere(name: string, options: {
  21511. radius?: number;
  21512. flat?: boolean;
  21513. subdivisions?: number;
  21514. sideOrientation?: number;
  21515. updatable?: boolean;
  21516. }, scene: Scene): Mesh;
  21517. /**
  21518. * Creates a decal mesh.
  21519. * Please consider using the same method from the MeshBuilder class instead.
  21520. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21521. * @param name defines the name of the mesh
  21522. * @param sourceMesh defines the mesh receiving the decal
  21523. * @param position sets the position of the decal in world coordinates
  21524. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21525. * @param size sets the decal scaling
  21526. * @param angle sets the angle to rotate the decal
  21527. * @returns a new Mesh
  21528. */
  21529. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21530. /**
  21531. * Prepare internal position array for software CPU skinning
  21532. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21533. */
  21534. setPositionsForCPUSkinning(): Float32Array;
  21535. /**
  21536. * Prepare internal normal array for software CPU skinning
  21537. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21538. */
  21539. setNormalsForCPUSkinning(): Float32Array;
  21540. /**
  21541. * Updates the vertex buffer by applying transformation from the bones
  21542. * @param skeleton defines the skeleton to apply to current mesh
  21543. * @returns the current mesh
  21544. */
  21545. applySkeleton(skeleton: Skeleton): Mesh;
  21546. /**
  21547. * 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
  21548. * @param meshes defines the list of meshes to scan
  21549. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21550. */
  21551. static MinMax(meshes: AbstractMesh[]): {
  21552. min: Vector3;
  21553. max: Vector3;
  21554. };
  21555. /**
  21556. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21557. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21558. * @returns a vector3
  21559. */
  21560. static Center(meshesOrMinMaxVector: {
  21561. min: Vector3;
  21562. max: Vector3;
  21563. } | AbstractMesh[]): Vector3;
  21564. /**
  21565. * Merge the array of meshes into a single mesh for performance reasons.
  21566. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21567. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21568. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21569. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21570. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21571. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21572. * @returns a new mesh
  21573. */
  21574. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21575. /** @hidden */
  21576. addInstance(instance: InstancedMesh): void;
  21577. /** @hidden */
  21578. removeInstance(instance: InstancedMesh): void;
  21579. }
  21580. }
  21581. declare module "babylonjs/Materials/material" {
  21582. import { IAnimatable } from "babylonjs/Misc/tools";
  21583. import { SmartArray } from "babylonjs/Misc/smartArray";
  21584. import { Observable } from "babylonjs/Misc/observable";
  21585. import { Nullable } from "babylonjs/types";
  21586. import { Scene } from "babylonjs/scene";
  21587. import { Matrix } from "babylonjs/Maths/math";
  21588. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21590. import { Mesh } from "babylonjs/Meshes/mesh";
  21591. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21592. import { Effect } from "babylonjs/Materials/effect";
  21593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21594. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21595. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21596. import { Animation } from "babylonjs/Animations/animation";
  21597. /**
  21598. * Base class for the main features of a material in Babylon.js
  21599. */
  21600. export class Material implements IAnimatable {
  21601. /**
  21602. * Returns the triangle fill mode
  21603. */
  21604. static readonly TriangleFillMode: number;
  21605. /**
  21606. * Returns the wireframe mode
  21607. */
  21608. static readonly WireFrameFillMode: number;
  21609. /**
  21610. * Returns the point fill mode
  21611. */
  21612. static readonly PointFillMode: number;
  21613. /**
  21614. * Returns the point list draw mode
  21615. */
  21616. static readonly PointListDrawMode: number;
  21617. /**
  21618. * Returns the line list draw mode
  21619. */
  21620. static readonly LineListDrawMode: number;
  21621. /**
  21622. * Returns the line loop draw mode
  21623. */
  21624. static readonly LineLoopDrawMode: number;
  21625. /**
  21626. * Returns the line strip draw mode
  21627. */
  21628. static readonly LineStripDrawMode: number;
  21629. /**
  21630. * Returns the triangle strip draw mode
  21631. */
  21632. static readonly TriangleStripDrawMode: number;
  21633. /**
  21634. * Returns the triangle fan draw mode
  21635. */
  21636. static readonly TriangleFanDrawMode: number;
  21637. /**
  21638. * Stores the clock-wise side orientation
  21639. */
  21640. static readonly ClockWiseSideOrientation: number;
  21641. /**
  21642. * Stores the counter clock-wise side orientation
  21643. */
  21644. static readonly CounterClockWiseSideOrientation: number;
  21645. /**
  21646. * The dirty texture flag value
  21647. */
  21648. static readonly TextureDirtyFlag: number;
  21649. /**
  21650. * The dirty light flag value
  21651. */
  21652. static readonly LightDirtyFlag: number;
  21653. /**
  21654. * The dirty fresnel flag value
  21655. */
  21656. static readonly FresnelDirtyFlag: number;
  21657. /**
  21658. * The dirty attribute flag value
  21659. */
  21660. static readonly AttributesDirtyFlag: number;
  21661. /**
  21662. * The dirty misc flag value
  21663. */
  21664. static readonly MiscDirtyFlag: number;
  21665. /**
  21666. * The all dirty flag value
  21667. */
  21668. static readonly AllDirtyFlag: number;
  21669. /**
  21670. * The ID of the material
  21671. */
  21672. id: string;
  21673. /**
  21674. * Gets or sets the unique id of the material
  21675. */
  21676. uniqueId: number;
  21677. /**
  21678. * The name of the material
  21679. */
  21680. name: string;
  21681. /**
  21682. * Gets or sets user defined metadata
  21683. */
  21684. metadata: any;
  21685. /**
  21686. * For internal use only. Please do not use.
  21687. */
  21688. reservedDataStore: any;
  21689. /**
  21690. * Specifies if the ready state should be checked on each call
  21691. */
  21692. checkReadyOnEveryCall: boolean;
  21693. /**
  21694. * Specifies if the ready state should be checked once
  21695. */
  21696. checkReadyOnlyOnce: boolean;
  21697. /**
  21698. * The state of the material
  21699. */
  21700. state: string;
  21701. /**
  21702. * The alpha value of the material
  21703. */
  21704. protected _alpha: number;
  21705. /**
  21706. * Sets the alpha value of the material
  21707. */
  21708. /**
  21709. * Gets the alpha value of the material
  21710. */
  21711. alpha: number;
  21712. /**
  21713. * Specifies if back face culling is enabled
  21714. */
  21715. protected _backFaceCulling: boolean;
  21716. /**
  21717. * Sets the back-face culling state
  21718. */
  21719. /**
  21720. * Gets the back-face culling state
  21721. */
  21722. backFaceCulling: boolean;
  21723. /**
  21724. * Stores the value for side orientation
  21725. */
  21726. sideOrientation: number;
  21727. /**
  21728. * Callback triggered when the material is compiled
  21729. */
  21730. onCompiled: (effect: Effect) => void;
  21731. /**
  21732. * Callback triggered when an error occurs
  21733. */
  21734. onError: (effect: Effect, errors: string) => void;
  21735. /**
  21736. * Callback triggered to get the render target textures
  21737. */
  21738. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21739. /**
  21740. * Gets a boolean indicating that current material needs to register RTT
  21741. */
  21742. readonly hasRenderTargetTextures: boolean;
  21743. /**
  21744. * Specifies if the material should be serialized
  21745. */
  21746. doNotSerialize: boolean;
  21747. /**
  21748. * @hidden
  21749. */
  21750. _storeEffectOnSubMeshes: boolean;
  21751. /**
  21752. * Stores the animations for the material
  21753. */
  21754. animations: Array<Animation>;
  21755. /**
  21756. * An event triggered when the material is disposed
  21757. */
  21758. onDisposeObservable: Observable<Material>;
  21759. /**
  21760. * An observer which watches for dispose events
  21761. */
  21762. private _onDisposeObserver;
  21763. private _onUnBindObservable;
  21764. /**
  21765. * Called during a dispose event
  21766. */
  21767. onDispose: () => void;
  21768. private _onBindObservable;
  21769. /**
  21770. * An event triggered when the material is bound
  21771. */
  21772. readonly onBindObservable: Observable<AbstractMesh>;
  21773. /**
  21774. * An observer which watches for bind events
  21775. */
  21776. private _onBindObserver;
  21777. /**
  21778. * Called during a bind event
  21779. */
  21780. onBind: (Mesh: AbstractMesh) => void;
  21781. /**
  21782. * An event triggered when the material is unbound
  21783. */
  21784. readonly onUnBindObservable: Observable<Material>;
  21785. /**
  21786. * Stores the value of the alpha mode
  21787. */
  21788. private _alphaMode;
  21789. /**
  21790. * Sets the value of the alpha mode.
  21791. *
  21792. * | Value | Type | Description |
  21793. * | --- | --- | --- |
  21794. * | 0 | ALPHA_DISABLE | |
  21795. * | 1 | ALPHA_ADD | |
  21796. * | 2 | ALPHA_COMBINE | |
  21797. * | 3 | ALPHA_SUBTRACT | |
  21798. * | 4 | ALPHA_MULTIPLY | |
  21799. * | 5 | ALPHA_MAXIMIZED | |
  21800. * | 6 | ALPHA_ONEONE | |
  21801. * | 7 | ALPHA_PREMULTIPLIED | |
  21802. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21803. * | 9 | ALPHA_INTERPOLATE | |
  21804. * | 10 | ALPHA_SCREENMODE | |
  21805. *
  21806. */
  21807. /**
  21808. * Gets the value of the alpha mode
  21809. */
  21810. alphaMode: number;
  21811. /**
  21812. * Stores the state of the need depth pre-pass value
  21813. */
  21814. private _needDepthPrePass;
  21815. /**
  21816. * Sets the need depth pre-pass value
  21817. */
  21818. /**
  21819. * Gets the depth pre-pass value
  21820. */
  21821. needDepthPrePass: boolean;
  21822. /**
  21823. * Specifies if depth writing should be disabled
  21824. */
  21825. disableDepthWrite: boolean;
  21826. /**
  21827. * Specifies if depth writing should be forced
  21828. */
  21829. forceDepthWrite: boolean;
  21830. /**
  21831. * Specifies if there should be a separate pass for culling
  21832. */
  21833. separateCullingPass: boolean;
  21834. /**
  21835. * Stores the state specifing if fog should be enabled
  21836. */
  21837. private _fogEnabled;
  21838. /**
  21839. * Sets the state for enabling fog
  21840. */
  21841. /**
  21842. * Gets the value of the fog enabled state
  21843. */
  21844. fogEnabled: boolean;
  21845. /**
  21846. * Stores the size of points
  21847. */
  21848. pointSize: number;
  21849. /**
  21850. * Stores the z offset value
  21851. */
  21852. zOffset: number;
  21853. /**
  21854. * Gets a value specifying if wireframe mode is enabled
  21855. */
  21856. /**
  21857. * Sets the state of wireframe mode
  21858. */
  21859. wireframe: boolean;
  21860. /**
  21861. * Gets the value specifying if point clouds are enabled
  21862. */
  21863. /**
  21864. * Sets the state of point cloud mode
  21865. */
  21866. pointsCloud: boolean;
  21867. /**
  21868. * Gets the material fill mode
  21869. */
  21870. /**
  21871. * Sets the material fill mode
  21872. */
  21873. fillMode: number;
  21874. /**
  21875. * @hidden
  21876. * Stores the effects for the material
  21877. */
  21878. _effect: Nullable<Effect>;
  21879. /**
  21880. * @hidden
  21881. * Specifies if the material was previously ready
  21882. */
  21883. _wasPreviouslyReady: boolean;
  21884. /**
  21885. * Specifies if uniform buffers should be used
  21886. */
  21887. private _useUBO;
  21888. /**
  21889. * Stores a reference to the scene
  21890. */
  21891. private _scene;
  21892. /**
  21893. * Stores the fill mode state
  21894. */
  21895. private _fillMode;
  21896. /**
  21897. * Specifies if the depth write state should be cached
  21898. */
  21899. private _cachedDepthWriteState;
  21900. /**
  21901. * Stores the uniform buffer
  21902. */
  21903. protected _uniformBuffer: UniformBuffer;
  21904. /** @hidden */
  21905. _indexInSceneMaterialArray: number;
  21906. /** @hidden */
  21907. meshMap: Nullable<{
  21908. [id: string]: AbstractMesh | undefined;
  21909. }>;
  21910. /**
  21911. * Creates a material instance
  21912. * @param name defines the name of the material
  21913. * @param scene defines the scene to reference
  21914. * @param doNotAdd specifies if the material should be added to the scene
  21915. */
  21916. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21917. /**
  21918. * Returns a string representation of the current material
  21919. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21920. * @returns a string with material information
  21921. */
  21922. toString(fullDetails?: boolean): string;
  21923. /**
  21924. * Gets the class name of the material
  21925. * @returns a string with the class name of the material
  21926. */
  21927. getClassName(): string;
  21928. /**
  21929. * Specifies if updates for the material been locked
  21930. */
  21931. readonly isFrozen: boolean;
  21932. /**
  21933. * Locks updates for the material
  21934. */
  21935. freeze(): void;
  21936. /**
  21937. * Unlocks updates for the material
  21938. */
  21939. unfreeze(): void;
  21940. /**
  21941. * Specifies if the material is ready to be used
  21942. * @param mesh defines the mesh to check
  21943. * @param useInstances specifies if instances should be used
  21944. * @returns a boolean indicating if the material is ready to be used
  21945. */
  21946. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21947. /**
  21948. * Specifies that the submesh is ready to be used
  21949. * @param mesh defines the mesh to check
  21950. * @param subMesh defines which submesh to check
  21951. * @param useInstances specifies that instances should be used
  21952. * @returns a boolean indicating that the submesh is ready or not
  21953. */
  21954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21955. /**
  21956. * Returns the material effect
  21957. * @returns the effect associated with the material
  21958. */
  21959. getEffect(): Nullable<Effect>;
  21960. /**
  21961. * Returns the current scene
  21962. * @returns a Scene
  21963. */
  21964. getScene(): Scene;
  21965. /**
  21966. * Specifies if the material will require alpha blending
  21967. * @returns a boolean specifying if alpha blending is needed
  21968. */
  21969. needAlphaBlending(): boolean;
  21970. /**
  21971. * Specifies if the mesh will require alpha blending
  21972. * @param mesh defines the mesh to check
  21973. * @returns a boolean specifying if alpha blending is needed for the mesh
  21974. */
  21975. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21976. /**
  21977. * Specifies if this material should be rendered in alpha test mode
  21978. * @returns a boolean specifying if an alpha test is needed.
  21979. */
  21980. needAlphaTesting(): boolean;
  21981. /**
  21982. * Gets the texture used for the alpha test
  21983. * @returns the texture to use for alpha testing
  21984. */
  21985. getAlphaTestTexture(): Nullable<BaseTexture>;
  21986. /**
  21987. * Marks the material to indicate that it needs to be re-calculated
  21988. */
  21989. markDirty(): void;
  21990. /** @hidden */
  21991. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21992. /**
  21993. * Binds the material to the mesh
  21994. * @param world defines the world transformation matrix
  21995. * @param mesh defines the mesh to bind the material to
  21996. */
  21997. bind(world: Matrix, mesh?: Mesh): void;
  21998. /**
  21999. * Binds the submesh to the material
  22000. * @param world defines the world transformation matrix
  22001. * @param mesh defines the mesh containing the submesh
  22002. * @param subMesh defines the submesh to bind the material to
  22003. */
  22004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22005. /**
  22006. * Binds the world matrix to the material
  22007. * @param world defines the world transformation matrix
  22008. */
  22009. bindOnlyWorldMatrix(world: Matrix): void;
  22010. /**
  22011. * Binds the scene's uniform buffer to the effect.
  22012. * @param effect defines the effect to bind to the scene uniform buffer
  22013. * @param sceneUbo defines the uniform buffer storing scene data
  22014. */
  22015. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22016. /**
  22017. * Binds the view matrix to the effect
  22018. * @param effect defines the effect to bind the view matrix to
  22019. */
  22020. bindView(effect: Effect): void;
  22021. /**
  22022. * Binds the view projection matrix to the effect
  22023. * @param effect defines the effect to bind the view projection matrix to
  22024. */
  22025. bindViewProjection(effect: Effect): void;
  22026. /**
  22027. * Specifies if material alpha testing should be turned on for the mesh
  22028. * @param mesh defines the mesh to check
  22029. */
  22030. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22031. /**
  22032. * Processes to execute after binding the material to a mesh
  22033. * @param mesh defines the rendered mesh
  22034. */
  22035. protected _afterBind(mesh?: Mesh): void;
  22036. /**
  22037. * Unbinds the material from the mesh
  22038. */
  22039. unbind(): void;
  22040. /**
  22041. * Gets the active textures from the material
  22042. * @returns an array of textures
  22043. */
  22044. getActiveTextures(): BaseTexture[];
  22045. /**
  22046. * Specifies if the material uses a texture
  22047. * @param texture defines the texture to check against the material
  22048. * @returns a boolean specifying if the material uses the texture
  22049. */
  22050. hasTexture(texture: BaseTexture): boolean;
  22051. /**
  22052. * Makes a duplicate of the material, and gives it a new name
  22053. * @param name defines the new name for the duplicated material
  22054. * @returns the cloned material
  22055. */
  22056. clone(name: string): Nullable<Material>;
  22057. /**
  22058. * Gets the meshes bound to the material
  22059. * @returns an array of meshes bound to the material
  22060. */
  22061. getBindedMeshes(): AbstractMesh[];
  22062. /**
  22063. * Force shader compilation
  22064. * @param mesh defines the mesh associated with this material
  22065. * @param onCompiled defines a function to execute once the material is compiled
  22066. * @param options defines the options to configure the compilation
  22067. */
  22068. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22069. clipPlane: boolean;
  22070. }>): void;
  22071. /**
  22072. * Force shader compilation
  22073. * @param mesh defines the mesh that will use this material
  22074. * @param options defines additional options for compiling the shaders
  22075. * @returns a promise that resolves when the compilation completes
  22076. */
  22077. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22078. clipPlane: boolean;
  22079. }>): Promise<void>;
  22080. private static readonly _ImageProcessingDirtyCallBack;
  22081. private static readonly _TextureDirtyCallBack;
  22082. private static readonly _FresnelDirtyCallBack;
  22083. private static readonly _MiscDirtyCallBack;
  22084. private static readonly _LightsDirtyCallBack;
  22085. private static readonly _AttributeDirtyCallBack;
  22086. private static _FresnelAndMiscDirtyCallBack;
  22087. private static _TextureAndMiscDirtyCallBack;
  22088. private static readonly _DirtyCallbackArray;
  22089. private static readonly _RunDirtyCallBacks;
  22090. /**
  22091. * Marks a define in the material to indicate that it needs to be re-computed
  22092. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22093. */
  22094. markAsDirty(flag: number): void;
  22095. /**
  22096. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22097. * @param func defines a function which checks material defines against the submeshes
  22098. */
  22099. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22100. /**
  22101. * Indicates that image processing needs to be re-calculated for all submeshes
  22102. */
  22103. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22104. /**
  22105. * Indicates that textures need to be re-calculated for all submeshes
  22106. */
  22107. protected _markAllSubMeshesAsTexturesDirty(): void;
  22108. /**
  22109. * Indicates that fresnel needs to be re-calculated for all submeshes
  22110. */
  22111. protected _markAllSubMeshesAsFresnelDirty(): void;
  22112. /**
  22113. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22114. */
  22115. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22116. /**
  22117. * Indicates that lights need to be re-calculated for all submeshes
  22118. */
  22119. protected _markAllSubMeshesAsLightsDirty(): void;
  22120. /**
  22121. * Indicates that attributes need to be re-calculated for all submeshes
  22122. */
  22123. protected _markAllSubMeshesAsAttributesDirty(): void;
  22124. /**
  22125. * Indicates that misc needs to be re-calculated for all submeshes
  22126. */
  22127. protected _markAllSubMeshesAsMiscDirty(): void;
  22128. /**
  22129. * Indicates that textures and misc need to be re-calculated for all submeshes
  22130. */
  22131. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22132. /**
  22133. * Disposes the material
  22134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22136. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22137. */
  22138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22139. /** @hidden */
  22140. private releaseVertexArrayObject;
  22141. /**
  22142. * Serializes this material
  22143. * @returns the serialized material object
  22144. */
  22145. serialize(): any;
  22146. /**
  22147. * Creates a material from parsed material data
  22148. * @param parsedMaterial defines parsed material data
  22149. * @param scene defines the hosting scene
  22150. * @param rootUrl defines the root URL to use to load textures
  22151. * @returns a new material
  22152. */
  22153. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22154. }
  22155. }
  22156. declare module "babylonjs/Meshes/subMesh" {
  22157. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22158. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22159. import { Engine } from "babylonjs/Engines/engine";
  22160. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22161. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22162. import { Effect } from "babylonjs/Materials/effect";
  22163. import { Collider } from "babylonjs/Collisions/collider";
  22164. import { Material } from "babylonjs/Materials/material";
  22165. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22167. import { Mesh } from "babylonjs/Meshes/mesh";
  22168. import { Ray } from "babylonjs/Culling/ray";
  22169. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22170. /**
  22171. * Base class for submeshes
  22172. */
  22173. export class BaseSubMesh {
  22174. /** @hidden */
  22175. _materialDefines: Nullable<MaterialDefines>;
  22176. /** @hidden */
  22177. _materialEffect: Nullable<Effect>;
  22178. /**
  22179. * Gets associated effect
  22180. */
  22181. readonly effect: Nullable<Effect>;
  22182. /**
  22183. * Sets associated effect (effect used to render this submesh)
  22184. * @param effect defines the effect to associate with
  22185. * @param defines defines the set of defines used to compile this effect
  22186. */
  22187. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22188. }
  22189. /**
  22190. * Defines a subdivision inside a mesh
  22191. */
  22192. export class SubMesh extends BaseSubMesh implements ICullable {
  22193. /** the material index to use */
  22194. materialIndex: number;
  22195. /** vertex index start */
  22196. verticesStart: number;
  22197. /** vertices count */
  22198. verticesCount: number;
  22199. /** index start */
  22200. indexStart: number;
  22201. /** indices count */
  22202. indexCount: number;
  22203. /** @hidden */
  22204. _linesIndexCount: number;
  22205. private _mesh;
  22206. private _renderingMesh;
  22207. private _boundingInfo;
  22208. private _linesIndexBuffer;
  22209. /** @hidden */
  22210. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22211. /** @hidden */
  22212. _trianglePlanes: Plane[];
  22213. /** @hidden */
  22214. _lastColliderTransformMatrix: Matrix;
  22215. /** @hidden */
  22216. _renderId: number;
  22217. /** @hidden */
  22218. _alphaIndex: number;
  22219. /** @hidden */
  22220. _distanceToCamera: number;
  22221. /** @hidden */
  22222. _id: number;
  22223. private _currentMaterial;
  22224. /**
  22225. * Add a new submesh to a mesh
  22226. * @param materialIndex defines the material index to use
  22227. * @param verticesStart defines vertex index start
  22228. * @param verticesCount defines vertices count
  22229. * @param indexStart defines index start
  22230. * @param indexCount defines indices count
  22231. * @param mesh defines the parent mesh
  22232. * @param renderingMesh defines an optional rendering mesh
  22233. * @param createBoundingBox defines if bounding box should be created for this submesh
  22234. * @returns the new submesh
  22235. */
  22236. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22237. /**
  22238. * Creates a new submesh
  22239. * @param materialIndex defines the material index to use
  22240. * @param verticesStart defines vertex index start
  22241. * @param verticesCount defines vertices count
  22242. * @param indexStart defines index start
  22243. * @param indexCount defines indices count
  22244. * @param mesh defines the parent mesh
  22245. * @param renderingMesh defines an optional rendering mesh
  22246. * @param createBoundingBox defines if bounding box should be created for this submesh
  22247. */
  22248. constructor(
  22249. /** the material index to use */
  22250. materialIndex: number,
  22251. /** vertex index start */
  22252. verticesStart: number,
  22253. /** vertices count */
  22254. verticesCount: number,
  22255. /** index start */
  22256. indexStart: number,
  22257. /** indices count */
  22258. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22259. /**
  22260. * Returns true if this submesh covers the entire parent mesh
  22261. * @ignorenaming
  22262. */
  22263. readonly IsGlobal: boolean;
  22264. /**
  22265. * Returns the submesh BoudingInfo object
  22266. * @returns current bounding info (or mesh's one if the submesh is global)
  22267. */
  22268. getBoundingInfo(): BoundingInfo;
  22269. /**
  22270. * Sets the submesh BoundingInfo
  22271. * @param boundingInfo defines the new bounding info to use
  22272. * @returns the SubMesh
  22273. */
  22274. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22275. /**
  22276. * Returns the mesh of the current submesh
  22277. * @return the parent mesh
  22278. */
  22279. getMesh(): AbstractMesh;
  22280. /**
  22281. * Returns the rendering mesh of the submesh
  22282. * @returns the rendering mesh (could be different from parent mesh)
  22283. */
  22284. getRenderingMesh(): Mesh;
  22285. /**
  22286. * Returns the submesh material
  22287. * @returns null or the current material
  22288. */
  22289. getMaterial(): Nullable<Material>;
  22290. /**
  22291. * Sets a new updated BoundingInfo object to the submesh
  22292. * @returns the SubMesh
  22293. */
  22294. refreshBoundingInfo(): SubMesh;
  22295. /** @hidden */
  22296. _checkCollision(collider: Collider): boolean;
  22297. /**
  22298. * Updates the submesh BoundingInfo
  22299. * @param world defines the world matrix to use to update the bounding info
  22300. * @returns the submesh
  22301. */
  22302. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22303. /**
  22304. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22305. * @param frustumPlanes defines the frustum planes
  22306. * @returns true if the submesh is intersecting with the frustum
  22307. */
  22308. isInFrustum(frustumPlanes: Plane[]): boolean;
  22309. /**
  22310. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22311. * @param frustumPlanes defines the frustum planes
  22312. * @returns true if the submesh is inside the frustum
  22313. */
  22314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22315. /**
  22316. * Renders the submesh
  22317. * @param enableAlphaMode defines if alpha needs to be used
  22318. * @returns the submesh
  22319. */
  22320. render(enableAlphaMode: boolean): SubMesh;
  22321. /**
  22322. * @hidden
  22323. */
  22324. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22325. /**
  22326. * Checks if the submesh intersects with a ray
  22327. * @param ray defines the ray to test
  22328. * @returns true is the passed ray intersects the submesh bounding box
  22329. */
  22330. canIntersects(ray: Ray): boolean;
  22331. /**
  22332. * Intersects current submesh with a ray
  22333. * @param ray defines the ray to test
  22334. * @param positions defines mesh's positions array
  22335. * @param indices defines mesh's indices array
  22336. * @param fastCheck defines if only bounding info should be used
  22337. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22338. * @returns intersection info or null if no intersection
  22339. */
  22340. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22341. /** @hidden */
  22342. private _intersectLines;
  22343. /** @hidden */
  22344. private _intersectTriangles;
  22345. /** @hidden */
  22346. _rebuild(): void;
  22347. /**
  22348. * Creates a new submesh from the passed mesh
  22349. * @param newMesh defines the new hosting mesh
  22350. * @param newRenderingMesh defines an optional rendering mesh
  22351. * @returns the new submesh
  22352. */
  22353. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22354. /**
  22355. * Release associated resources
  22356. */
  22357. dispose(): void;
  22358. /**
  22359. * Gets the class name
  22360. * @returns the string "SubMesh".
  22361. */
  22362. getClassName(): string;
  22363. /**
  22364. * Creates a new submesh from indices data
  22365. * @param materialIndex the index of the main mesh material
  22366. * @param startIndex the index where to start the copy in the mesh indices array
  22367. * @param indexCount the number of indices to copy then from the startIndex
  22368. * @param mesh the main mesh to create the submesh from
  22369. * @param renderingMesh the optional rendering mesh
  22370. * @returns a new submesh
  22371. */
  22372. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22373. }
  22374. }
  22375. declare module "babylonjs/Meshes/geometry" {
  22376. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22377. import { Scene } from "babylonjs/scene";
  22378. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22379. import { Engine } from "babylonjs/Engines/engine";
  22380. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22381. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22382. import { Effect } from "babylonjs/Materials/effect";
  22383. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22384. import { Mesh } from "babylonjs/Meshes/mesh";
  22385. /**
  22386. * Class used to store geometry data (vertex buffers + index buffer)
  22387. */
  22388. export class Geometry implements IGetSetVerticesData {
  22389. /**
  22390. * Gets or sets the ID of the geometry
  22391. */
  22392. id: string;
  22393. /**
  22394. * Gets or sets the unique ID of the geometry
  22395. */
  22396. uniqueId: number;
  22397. /**
  22398. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22399. */
  22400. delayLoadState: number;
  22401. /**
  22402. * Gets the file containing the data to load when running in delay load state
  22403. */
  22404. delayLoadingFile: Nullable<string>;
  22405. /**
  22406. * Callback called when the geometry is updated
  22407. */
  22408. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22409. private _scene;
  22410. private _engine;
  22411. private _meshes;
  22412. private _totalVertices;
  22413. /** @hidden */
  22414. _indices: IndicesArray;
  22415. /** @hidden */
  22416. _vertexBuffers: {
  22417. [key: string]: VertexBuffer;
  22418. };
  22419. private _isDisposed;
  22420. private _extend;
  22421. private _boundingBias;
  22422. /** @hidden */
  22423. _delayInfo: Array<string>;
  22424. private _indexBuffer;
  22425. private _indexBufferIsUpdatable;
  22426. /** @hidden */
  22427. _boundingInfo: Nullable<BoundingInfo>;
  22428. /** @hidden */
  22429. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22430. /** @hidden */
  22431. _softwareSkinningFrameId: number;
  22432. private _vertexArrayObjects;
  22433. private _updatable;
  22434. /** @hidden */
  22435. _positions: Nullable<Vector3[]>;
  22436. /**
  22437. * 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
  22438. */
  22439. /**
  22440. * 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
  22441. */
  22442. boundingBias: Vector2;
  22443. /**
  22444. * Static function used to attach a new empty geometry to a mesh
  22445. * @param mesh defines the mesh to attach the geometry to
  22446. * @returns the new Geometry
  22447. */
  22448. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22449. /**
  22450. * Creates a new geometry
  22451. * @param id defines the unique ID
  22452. * @param scene defines the hosting scene
  22453. * @param vertexData defines the VertexData used to get geometry data
  22454. * @param updatable defines if geometry must be updatable (false by default)
  22455. * @param mesh defines the mesh that will be associated with the geometry
  22456. */
  22457. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22458. /**
  22459. * Gets the current extend of the geometry
  22460. */
  22461. readonly extend: {
  22462. minimum: Vector3;
  22463. maximum: Vector3;
  22464. };
  22465. /**
  22466. * Gets the hosting scene
  22467. * @returns the hosting Scene
  22468. */
  22469. getScene(): Scene;
  22470. /**
  22471. * Gets the hosting engine
  22472. * @returns the hosting Engine
  22473. */
  22474. getEngine(): Engine;
  22475. /**
  22476. * Defines if the geometry is ready to use
  22477. * @returns true if the geometry is ready to be used
  22478. */
  22479. isReady(): boolean;
  22480. /**
  22481. * Gets a value indicating that the geometry should not be serialized
  22482. */
  22483. readonly doNotSerialize: boolean;
  22484. /** @hidden */
  22485. _rebuild(): void;
  22486. /**
  22487. * Affects all geometry data in one call
  22488. * @param vertexData defines the geometry data
  22489. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22490. */
  22491. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22492. /**
  22493. * Set specific vertex data
  22494. * @param kind defines the data kind (Position, normal, etc...)
  22495. * @param data defines the vertex data to use
  22496. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22497. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22498. */
  22499. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22500. /**
  22501. * Removes a specific vertex data
  22502. * @param kind defines the data kind (Position, normal, etc...)
  22503. */
  22504. removeVerticesData(kind: string): void;
  22505. /**
  22506. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22507. * @param buffer defines the vertex buffer to use
  22508. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22509. */
  22510. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22511. /**
  22512. * Update a specific vertex buffer
  22513. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22514. * It will do nothing if the buffer is not updatable
  22515. * @param kind defines the data kind (Position, normal, etc...)
  22516. * @param data defines the data to use
  22517. * @param offset defines the offset in the target buffer where to store the data
  22518. * @param useBytes set to true if the offset is in bytes
  22519. */
  22520. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22521. /**
  22522. * Update a specific vertex buffer
  22523. * This function will create a new buffer if the current one is not updatable
  22524. * @param kind defines the data kind (Position, normal, etc...)
  22525. * @param data defines the data to use
  22526. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22527. */
  22528. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22529. private _updateBoundingInfo;
  22530. /** @hidden */
  22531. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22532. /**
  22533. * Gets total number of vertices
  22534. * @returns the total number of vertices
  22535. */
  22536. getTotalVertices(): number;
  22537. /**
  22538. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22539. * @param kind defines the data kind (Position, normal, etc...)
  22540. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22541. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22542. * @returns a float array containing vertex data
  22543. */
  22544. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22545. /**
  22546. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22547. * @param kind defines the data kind (Position, normal, etc...)
  22548. * @returns true if the vertex buffer with the specified kind is updatable
  22549. */
  22550. isVertexBufferUpdatable(kind: string): boolean;
  22551. /**
  22552. * Gets a specific vertex buffer
  22553. * @param kind defines the data kind (Position, normal, etc...)
  22554. * @returns a VertexBuffer
  22555. */
  22556. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22557. /**
  22558. * Returns all vertex buffers
  22559. * @return an object holding all vertex buffers indexed by kind
  22560. */
  22561. getVertexBuffers(): Nullable<{
  22562. [key: string]: VertexBuffer;
  22563. }>;
  22564. /**
  22565. * Gets a boolean indicating if specific vertex buffer is present
  22566. * @param kind defines the data kind (Position, normal, etc...)
  22567. * @returns true if data is present
  22568. */
  22569. isVerticesDataPresent(kind: string): boolean;
  22570. /**
  22571. * Gets a list of all attached data kinds (Position, normal, etc...)
  22572. * @returns a list of string containing all kinds
  22573. */
  22574. getVerticesDataKinds(): string[];
  22575. /**
  22576. * Update index buffer
  22577. * @param indices defines the indices to store in the index buffer
  22578. * @param offset defines the offset in the target buffer where to store the data
  22579. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22580. */
  22581. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22582. /**
  22583. * Creates a new index buffer
  22584. * @param indices defines the indices to store in the index buffer
  22585. * @param totalVertices defines the total number of vertices (could be null)
  22586. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22587. */
  22588. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22589. /**
  22590. * Return the total number of indices
  22591. * @returns the total number of indices
  22592. */
  22593. getTotalIndices(): number;
  22594. /**
  22595. * Gets the index buffer array
  22596. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22597. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22598. * @returns the index buffer array
  22599. */
  22600. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22601. /**
  22602. * Gets the index buffer
  22603. * @return the index buffer
  22604. */
  22605. getIndexBuffer(): Nullable<WebGLBuffer>;
  22606. /** @hidden */
  22607. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22608. /**
  22609. * Release the associated resources for a specific mesh
  22610. * @param mesh defines the source mesh
  22611. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22612. */
  22613. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22614. /**
  22615. * Apply current geometry to a given mesh
  22616. * @param mesh defines the mesh to apply geometry to
  22617. */
  22618. applyToMesh(mesh: Mesh): void;
  22619. private _updateExtend;
  22620. private _applyToMesh;
  22621. private notifyUpdate;
  22622. /**
  22623. * Load the geometry if it was flagged as delay loaded
  22624. * @param scene defines the hosting scene
  22625. * @param onLoaded defines a callback called when the geometry is loaded
  22626. */
  22627. load(scene: Scene, onLoaded?: () => void): void;
  22628. private _queueLoad;
  22629. /**
  22630. * Invert the geometry to move from a right handed system to a left handed one.
  22631. */
  22632. toLeftHanded(): void;
  22633. /** @hidden */
  22634. _resetPointsArrayCache(): void;
  22635. /** @hidden */
  22636. _generatePointsArray(): boolean;
  22637. /**
  22638. * Gets a value indicating if the geometry is disposed
  22639. * @returns true if the geometry was disposed
  22640. */
  22641. isDisposed(): boolean;
  22642. private _disposeVertexArrayObjects;
  22643. /**
  22644. * Free all associated resources
  22645. */
  22646. dispose(): void;
  22647. /**
  22648. * Clone the current geometry into a new geometry
  22649. * @param id defines the unique ID of the new geometry
  22650. * @returns a new geometry object
  22651. */
  22652. copy(id: string): Geometry;
  22653. /**
  22654. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22655. * @return a JSON representation of the current geometry data (without the vertices data)
  22656. */
  22657. serialize(): any;
  22658. private toNumberArray;
  22659. /**
  22660. * Serialize all vertices data into a JSON oject
  22661. * @returns a JSON representation of the current geometry data
  22662. */
  22663. serializeVerticeData(): any;
  22664. /**
  22665. * Extracts a clone of a mesh geometry
  22666. * @param mesh defines the source mesh
  22667. * @param id defines the unique ID of the new geometry object
  22668. * @returns the new geometry object
  22669. */
  22670. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22671. /**
  22672. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22673. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22674. * Be aware Math.random() could cause collisions, but:
  22675. * "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"
  22676. * @returns a string containing a new GUID
  22677. */
  22678. static RandomId(): string;
  22679. /** @hidden */
  22680. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22681. private static _CleanMatricesWeights;
  22682. /**
  22683. * Create a new geometry from persisted data (Using .babylon file format)
  22684. * @param parsedVertexData defines the persisted data
  22685. * @param scene defines the hosting scene
  22686. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22687. * @returns the new geometry object
  22688. */
  22689. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22690. }
  22691. }
  22692. declare module "babylonjs/Meshes/mesh.vertexData" {
  22693. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22694. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22695. import { Geometry } from "babylonjs/Meshes/geometry";
  22696. import { Mesh } from "babylonjs/Meshes/mesh";
  22697. /**
  22698. * Define an interface for all classes that will get and set the data on vertices
  22699. */
  22700. export interface IGetSetVerticesData {
  22701. /**
  22702. * Gets a boolean indicating if specific vertex data is present
  22703. * @param kind defines the vertex data kind to use
  22704. * @returns true is data kind is present
  22705. */
  22706. isVerticesDataPresent(kind: string): boolean;
  22707. /**
  22708. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22709. * @param kind defines the data kind (Position, normal, etc...)
  22710. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22711. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22712. * @returns a float array containing vertex data
  22713. */
  22714. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22715. /**
  22716. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22717. * @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.
  22718. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22719. * @returns the indices array or an empty array if the mesh has no geometry
  22720. */
  22721. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22722. /**
  22723. * Set specific vertex data
  22724. * @param kind defines the data kind (Position, normal, etc...)
  22725. * @param data defines the vertex data to use
  22726. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22727. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22728. */
  22729. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22730. /**
  22731. * Update a specific associated vertex buffer
  22732. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22733. * - VertexBuffer.PositionKind
  22734. * - VertexBuffer.UVKind
  22735. * - VertexBuffer.UV2Kind
  22736. * - VertexBuffer.UV3Kind
  22737. * - VertexBuffer.UV4Kind
  22738. * - VertexBuffer.UV5Kind
  22739. * - VertexBuffer.UV6Kind
  22740. * - VertexBuffer.ColorKind
  22741. * - VertexBuffer.MatricesIndicesKind
  22742. * - VertexBuffer.MatricesIndicesExtraKind
  22743. * - VertexBuffer.MatricesWeightsKind
  22744. * - VertexBuffer.MatricesWeightsExtraKind
  22745. * @param data defines the data source
  22746. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22747. * @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)
  22748. */
  22749. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22750. /**
  22751. * Creates a new index buffer
  22752. * @param indices defines the indices to store in the index buffer
  22753. * @param totalVertices defines the total number of vertices (could be null)
  22754. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22755. */
  22756. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22757. }
  22758. /**
  22759. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22760. */
  22761. export class VertexData {
  22762. /**
  22763. * Mesh side orientation : usually the external or front surface
  22764. */
  22765. static readonly FRONTSIDE: number;
  22766. /**
  22767. * Mesh side orientation : usually the internal or back surface
  22768. */
  22769. static readonly BACKSIDE: number;
  22770. /**
  22771. * Mesh side orientation : both internal and external or front and back surfaces
  22772. */
  22773. static readonly DOUBLESIDE: number;
  22774. /**
  22775. * Mesh side orientation : by default, `FRONTSIDE`
  22776. */
  22777. static readonly DEFAULTSIDE: number;
  22778. /**
  22779. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22780. */
  22781. positions: Nullable<FloatArray>;
  22782. /**
  22783. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22784. */
  22785. normals: Nullable<FloatArray>;
  22786. /**
  22787. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22788. */
  22789. tangents: Nullable<FloatArray>;
  22790. /**
  22791. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22792. */
  22793. uvs: Nullable<FloatArray>;
  22794. /**
  22795. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22796. */
  22797. uvs2: Nullable<FloatArray>;
  22798. /**
  22799. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22800. */
  22801. uvs3: Nullable<FloatArray>;
  22802. /**
  22803. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22804. */
  22805. uvs4: Nullable<FloatArray>;
  22806. /**
  22807. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22808. */
  22809. uvs5: Nullable<FloatArray>;
  22810. /**
  22811. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22812. */
  22813. uvs6: Nullable<FloatArray>;
  22814. /**
  22815. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22816. */
  22817. colors: Nullable<FloatArray>;
  22818. /**
  22819. * 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).
  22820. */
  22821. matricesIndices: Nullable<FloatArray>;
  22822. /**
  22823. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22824. */
  22825. matricesWeights: Nullable<FloatArray>;
  22826. /**
  22827. * An array extending the number of possible indices
  22828. */
  22829. matricesIndicesExtra: Nullable<FloatArray>;
  22830. /**
  22831. * An array extending the number of possible weights when the number of indices is extended
  22832. */
  22833. matricesWeightsExtra: Nullable<FloatArray>;
  22834. /**
  22835. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22836. */
  22837. indices: Nullable<IndicesArray>;
  22838. /**
  22839. * Uses the passed data array to set the set the values for the specified kind of data
  22840. * @param data a linear array of floating numbers
  22841. * @param kind the type of data that is being set, eg positions, colors etc
  22842. */
  22843. set(data: FloatArray, kind: string): void;
  22844. /**
  22845. * Associates the vertexData to the passed Mesh.
  22846. * Sets it as updatable or not (default `false`)
  22847. * @param mesh the mesh the vertexData is applied to
  22848. * @param updatable when used and having the value true allows new data to update the vertexData
  22849. * @returns the VertexData
  22850. */
  22851. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22852. /**
  22853. * Associates the vertexData to the passed Geometry.
  22854. * Sets it as updatable or not (default `false`)
  22855. * @param geometry the geometry the vertexData is applied to
  22856. * @param updatable when used and having the value true allows new data to update the vertexData
  22857. * @returns VertexData
  22858. */
  22859. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22860. /**
  22861. * Updates the associated mesh
  22862. * @param mesh the mesh to be updated
  22863. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22864. * @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
  22865. * @returns VertexData
  22866. */
  22867. updateMesh(mesh: Mesh): VertexData;
  22868. /**
  22869. * Updates the associated geometry
  22870. * @param geometry the geometry to be updated
  22871. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22872. * @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
  22873. * @returns VertexData.
  22874. */
  22875. updateGeometry(geometry: Geometry): VertexData;
  22876. private _applyTo;
  22877. private _update;
  22878. /**
  22879. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22880. * @param matrix the transforming matrix
  22881. * @returns the VertexData
  22882. */
  22883. transform(matrix: Matrix): VertexData;
  22884. /**
  22885. * Merges the passed VertexData into the current one
  22886. * @param other the VertexData to be merged into the current one
  22887. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22888. * @returns the modified VertexData
  22889. */
  22890. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22891. private _mergeElement;
  22892. private _validate;
  22893. /**
  22894. * Serializes the VertexData
  22895. * @returns a serialized object
  22896. */
  22897. serialize(): any;
  22898. /**
  22899. * Extracts the vertexData from a mesh
  22900. * @param mesh the mesh from which to extract the VertexData
  22901. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22902. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22903. * @returns the object VertexData associated to the passed mesh
  22904. */
  22905. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22906. /**
  22907. * Extracts the vertexData from the geometry
  22908. * @param geometry the geometry from which to extract the VertexData
  22909. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22910. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22911. * @returns the object VertexData associated to the passed mesh
  22912. */
  22913. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22914. private static _ExtractFrom;
  22915. /**
  22916. * Creates the VertexData for a Ribbon
  22917. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22918. * * pathArray array of paths, each of which an array of successive Vector3
  22919. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22920. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22921. * * 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
  22922. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22923. * * 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)
  22924. * * 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)
  22925. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22926. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22927. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22928. * @returns the VertexData of the ribbon
  22929. */
  22930. static CreateRibbon(options: {
  22931. pathArray: Vector3[][];
  22932. closeArray?: boolean;
  22933. closePath?: boolean;
  22934. offset?: number;
  22935. sideOrientation?: number;
  22936. frontUVs?: Vector4;
  22937. backUVs?: Vector4;
  22938. invertUV?: boolean;
  22939. uvs?: Vector2[];
  22940. colors?: Color4[];
  22941. }): VertexData;
  22942. /**
  22943. * Creates the VertexData for a box
  22944. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22945. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22946. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22947. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22948. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22949. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22950. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22952. * * 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)
  22953. * * 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)
  22954. * @returns the VertexData of the box
  22955. */
  22956. static CreateBox(options: {
  22957. size?: number;
  22958. width?: number;
  22959. height?: number;
  22960. depth?: number;
  22961. faceUV?: Vector4[];
  22962. faceColors?: Color4[];
  22963. sideOrientation?: number;
  22964. frontUVs?: Vector4;
  22965. backUVs?: Vector4;
  22966. }): VertexData;
  22967. /**
  22968. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22969. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22970. * * segments sets the number of horizontal strips optional, default 32
  22971. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22972. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22973. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22974. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22975. * * 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
  22976. * * 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
  22977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22978. * * 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)
  22979. * * 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)
  22980. * @returns the VertexData of the ellipsoid
  22981. */
  22982. static CreateSphere(options: {
  22983. segments?: number;
  22984. diameter?: number;
  22985. diameterX?: number;
  22986. diameterY?: number;
  22987. diameterZ?: number;
  22988. arc?: number;
  22989. slice?: number;
  22990. sideOrientation?: number;
  22991. frontUVs?: Vector4;
  22992. backUVs?: Vector4;
  22993. }): VertexData;
  22994. /**
  22995. * Creates the VertexData for a cylinder, cone or prism
  22996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22997. * * height sets the height (y direction) of the cylinder, optional, default 2
  22998. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22999. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23000. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23001. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23002. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23003. * * 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
  23004. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23005. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23006. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23007. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23009. * * 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)
  23010. * * 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)
  23011. * @returns the VertexData of the cylinder, cone or prism
  23012. */
  23013. static CreateCylinder(options: {
  23014. height?: number;
  23015. diameterTop?: number;
  23016. diameterBottom?: number;
  23017. diameter?: number;
  23018. tessellation?: number;
  23019. subdivisions?: number;
  23020. arc?: number;
  23021. faceColors?: Color4[];
  23022. faceUV?: Vector4[];
  23023. hasRings?: boolean;
  23024. enclose?: boolean;
  23025. sideOrientation?: number;
  23026. frontUVs?: Vector4;
  23027. backUVs?: Vector4;
  23028. }): VertexData;
  23029. /**
  23030. * Creates the VertexData for a torus
  23031. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23032. * * diameter the diameter of the torus, optional default 1
  23033. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23034. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  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 torus
  23039. */
  23040. static CreateTorus(options: {
  23041. diameter?: number;
  23042. thickness?: number;
  23043. tessellation?: number;
  23044. sideOrientation?: number;
  23045. frontUVs?: Vector4;
  23046. backUVs?: Vector4;
  23047. }): VertexData;
  23048. /**
  23049. * Creates the VertexData of the LineSystem
  23050. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23051. * - lines an array of lines, each line being an array of successive Vector3
  23052. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23053. * @returns the VertexData of the LineSystem
  23054. */
  23055. static CreateLineSystem(options: {
  23056. lines: Vector3[][];
  23057. colors?: Nullable<Color4[][]>;
  23058. }): VertexData;
  23059. /**
  23060. * Create the VertexData for a DashedLines
  23061. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23062. * - points an array successive Vector3
  23063. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23064. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23065. * - dashNb the intended total number of dashes, optional, default 200
  23066. * @returns the VertexData for the DashedLines
  23067. */
  23068. static CreateDashedLines(options: {
  23069. points: Vector3[];
  23070. dashSize?: number;
  23071. gapSize?: number;
  23072. dashNb?: number;
  23073. }): VertexData;
  23074. /**
  23075. * Creates the VertexData for a Ground
  23076. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23077. * - width the width (x direction) of the ground, optional, default 1
  23078. * - height the height (z direction) of the ground, optional, default 1
  23079. * - subdivisions the number of subdivisions per side, optional, default 1
  23080. * @returns the VertexData of the Ground
  23081. */
  23082. static CreateGround(options: {
  23083. width?: number;
  23084. height?: number;
  23085. subdivisions?: number;
  23086. subdivisionsX?: number;
  23087. subdivisionsY?: number;
  23088. }): VertexData;
  23089. /**
  23090. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23091. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23092. * * xmin the ground minimum X coordinate, optional, default -1
  23093. * * zmin the ground minimum Z coordinate, optional, default -1
  23094. * * xmax the ground maximum X coordinate, optional, default 1
  23095. * * zmax the ground maximum Z coordinate, optional, default 1
  23096. * * 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}
  23097. * * 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}
  23098. * @returns the VertexData of the TiledGround
  23099. */
  23100. static CreateTiledGround(options: {
  23101. xmin: number;
  23102. zmin: number;
  23103. xmax: number;
  23104. zmax: number;
  23105. subdivisions?: {
  23106. w: number;
  23107. h: number;
  23108. };
  23109. precision?: {
  23110. w: number;
  23111. h: number;
  23112. };
  23113. }): VertexData;
  23114. /**
  23115. * Creates the VertexData of the Ground designed from a heightmap
  23116. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23117. * * width the width (x direction) of the ground
  23118. * * height the height (z direction) of the ground
  23119. * * subdivisions the number of subdivisions per side
  23120. * * minHeight the minimum altitude on the ground, optional, default 0
  23121. * * maxHeight the maximum altitude on the ground, optional default 1
  23122. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23123. * * buffer the array holding the image color data
  23124. * * bufferWidth the width of image
  23125. * * bufferHeight the height of image
  23126. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23127. * @returns the VertexData of the Ground designed from a heightmap
  23128. */
  23129. static CreateGroundFromHeightMap(options: {
  23130. width: number;
  23131. height: number;
  23132. subdivisions: number;
  23133. minHeight: number;
  23134. maxHeight: number;
  23135. colorFilter: Color3;
  23136. buffer: Uint8Array;
  23137. bufferWidth: number;
  23138. bufferHeight: number;
  23139. alphaFilter: number;
  23140. }): VertexData;
  23141. /**
  23142. * Creates the VertexData for a Plane
  23143. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23144. * * size sets the width and height of the plane to the value of size, optional default 1
  23145. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23146. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23148. * * 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)
  23149. * * 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)
  23150. * @returns the VertexData of the box
  23151. */
  23152. static CreatePlane(options: {
  23153. size?: number;
  23154. width?: number;
  23155. height?: number;
  23156. sideOrientation?: number;
  23157. frontUVs?: Vector4;
  23158. backUVs?: Vector4;
  23159. }): VertexData;
  23160. /**
  23161. * Creates the VertexData of the Disc or regular Polygon
  23162. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23163. * * radius the radius of the disc, optional default 0.5
  23164. * * tessellation the number of polygon sides, optional, default 64
  23165. * * 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
  23166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23167. * * 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)
  23168. * * 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)
  23169. * @returns the VertexData of the box
  23170. */
  23171. static CreateDisc(options: {
  23172. radius?: number;
  23173. tessellation?: number;
  23174. arc?: number;
  23175. sideOrientation?: number;
  23176. frontUVs?: Vector4;
  23177. backUVs?: Vector4;
  23178. }): VertexData;
  23179. /**
  23180. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23181. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23182. * @param polygon a mesh built from polygonTriangulation.build()
  23183. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23184. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23185. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23186. * @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)
  23187. * @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)
  23188. * @returns the VertexData of the Polygon
  23189. */
  23190. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23191. /**
  23192. * Creates the VertexData of the IcoSphere
  23193. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23194. * * radius the radius of the IcoSphere, optional default 1
  23195. * * radiusX allows stretching in the x direction, optional, default radius
  23196. * * radiusY allows stretching in the y direction, optional, default radius
  23197. * * radiusZ allows stretching in the z direction, optional, default radius
  23198. * * flat when true creates a flat shaded mesh, optional, default true
  23199. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23201. * * 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)
  23202. * * 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)
  23203. * @returns the VertexData of the IcoSphere
  23204. */
  23205. static CreateIcoSphere(options: {
  23206. radius?: number;
  23207. radiusX?: number;
  23208. radiusY?: number;
  23209. radiusZ?: number;
  23210. flat?: boolean;
  23211. subdivisions?: number;
  23212. sideOrientation?: number;
  23213. frontUVs?: Vector4;
  23214. backUVs?: Vector4;
  23215. }): VertexData;
  23216. /**
  23217. * Creates the VertexData for a Polyhedron
  23218. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23219. * * type provided types are:
  23220. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23221. * * 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)
  23222. * * size the size of the IcoSphere, optional default 1
  23223. * * sizeX allows stretching in the x direction, optional, default size
  23224. * * sizeY allows stretching in the y direction, optional, default size
  23225. * * sizeZ allows stretching in the z direction, optional, default size
  23226. * * 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
  23227. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23228. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23229. * * flat when true creates a flat shaded mesh, optional, default true
  23230. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23232. * * 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)
  23233. * * 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)
  23234. * @returns the VertexData of the Polyhedron
  23235. */
  23236. static CreatePolyhedron(options: {
  23237. type?: number;
  23238. size?: number;
  23239. sizeX?: number;
  23240. sizeY?: number;
  23241. sizeZ?: number;
  23242. custom?: any;
  23243. faceUV?: Vector4[];
  23244. faceColors?: Color4[];
  23245. flat?: boolean;
  23246. sideOrientation?: number;
  23247. frontUVs?: Vector4;
  23248. backUVs?: Vector4;
  23249. }): VertexData;
  23250. /**
  23251. * Creates the VertexData for a TorusKnot
  23252. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23253. * * radius the radius of the torus knot, optional, default 2
  23254. * * tube the thickness of the tube, optional, default 0.5
  23255. * * radialSegments the number of sides on each tube segments, optional, default 32
  23256. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23257. * * p the number of windings around the z axis, optional, default 2
  23258. * * q the number of windings around the x axis, optional, default 3
  23259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23260. * * 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)
  23261. * * 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)
  23262. * @returns the VertexData of the Torus Knot
  23263. */
  23264. static CreateTorusKnot(options: {
  23265. radius?: number;
  23266. tube?: number;
  23267. radialSegments?: number;
  23268. tubularSegments?: number;
  23269. p?: number;
  23270. q?: number;
  23271. sideOrientation?: number;
  23272. frontUVs?: Vector4;
  23273. backUVs?: Vector4;
  23274. }): VertexData;
  23275. /**
  23276. * Compute normals for given positions and indices
  23277. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23278. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23279. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23280. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23281. * * facetNormals : optional array of facet normals (vector3)
  23282. * * facetPositions : optional array of facet positions (vector3)
  23283. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23284. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23285. * * bInfo : optional bounding info, required for facetPartitioning computation
  23286. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23287. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23288. * * useRightHandedSystem: optional boolean to for right handed system computation
  23289. * * depthSort : optional boolean to enable the facet depth sort computation
  23290. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23291. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23292. */
  23293. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23294. facetNormals?: any;
  23295. facetPositions?: any;
  23296. facetPartitioning?: any;
  23297. ratio?: number;
  23298. bInfo?: any;
  23299. bbSize?: Vector3;
  23300. subDiv?: any;
  23301. useRightHandedSystem?: boolean;
  23302. depthSort?: boolean;
  23303. distanceTo?: Vector3;
  23304. depthSortedFacets?: any;
  23305. }): void;
  23306. /** @hidden */
  23307. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23308. /**
  23309. * Applies VertexData created from the imported parameters to the geometry
  23310. * @param parsedVertexData the parsed data from an imported file
  23311. * @param geometry the geometry to apply the VertexData to
  23312. */
  23313. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23314. }
  23315. }
  23316. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23317. import { Nullable } from "babylonjs/types";
  23318. import { Scene } from "babylonjs/scene";
  23319. import { Vector4 } from "babylonjs/Maths/math";
  23320. import { Mesh } from "babylonjs/Meshes/mesh";
  23321. /**
  23322. * Class containing static functions to help procedurally build meshes
  23323. */
  23324. export class DiscBuilder {
  23325. /**
  23326. * Creates a plane polygonal mesh. By default, this is a disc
  23327. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23328. * * 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
  23329. * * 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
  23330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23333. * @param name defines the name of the mesh
  23334. * @param options defines the options used to create the mesh
  23335. * @param scene defines the hosting scene
  23336. * @returns the plane polygonal mesh
  23337. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23338. */
  23339. static CreateDisc(name: string, options: {
  23340. radius?: number;
  23341. tessellation?: number;
  23342. arc?: number;
  23343. updatable?: boolean;
  23344. sideOrientation?: number;
  23345. frontUVs?: Vector4;
  23346. backUVs?: Vector4;
  23347. }, scene?: Nullable<Scene>): Mesh;
  23348. }
  23349. }
  23350. declare module "babylonjs/Particles/solidParticleSystem" {
  23351. import { Vector3 } from "babylonjs/Maths/math";
  23352. import { Mesh } from "babylonjs/Meshes/mesh";
  23353. import { Scene, IDisposable } from "babylonjs/scene";
  23354. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23355. /**
  23356. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23357. *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.
  23358. * The SPS is also a particle system. It provides some methods to manage the particles.
  23359. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23360. *
  23361. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23362. */
  23363. export class SolidParticleSystem implements IDisposable {
  23364. /**
  23365. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23366. * Example : var p = SPS.particles[i];
  23367. */
  23368. particles: SolidParticle[];
  23369. /**
  23370. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23371. */
  23372. nbParticles: number;
  23373. /**
  23374. * If the particles must ever face the camera (default false). Useful for planar particles.
  23375. */
  23376. billboard: boolean;
  23377. /**
  23378. * Recompute normals when adding a shape
  23379. */
  23380. recomputeNormals: boolean;
  23381. /**
  23382. * This a counter ofr your own usage. It's not set by any SPS functions.
  23383. */
  23384. counter: number;
  23385. /**
  23386. * The SPS name. This name is also given to the underlying mesh.
  23387. */
  23388. name: string;
  23389. /**
  23390. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23391. */
  23392. mesh: Mesh;
  23393. /**
  23394. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23395. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23396. */
  23397. vars: any;
  23398. /**
  23399. * This array is populated when the SPS is set as 'pickable'.
  23400. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23401. * Each element of this array is an object `{idx: int, faceId: int}`.
  23402. * `idx` is the picked particle index in the `SPS.particles` array
  23403. * `faceId` is the picked face index counted within this particle.
  23404. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23405. */
  23406. pickedParticles: {
  23407. idx: number;
  23408. faceId: number;
  23409. }[];
  23410. /**
  23411. * This array is populated when `enableDepthSort` is set to true.
  23412. * Each element of this array is an instance of the class DepthSortedParticle.
  23413. */
  23414. depthSortedParticles: DepthSortedParticle[];
  23415. /**
  23416. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23417. * @hidden
  23418. */
  23419. _bSphereOnly: boolean;
  23420. /**
  23421. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23422. * @hidden
  23423. */
  23424. _bSphereRadiusFactor: number;
  23425. private _scene;
  23426. private _positions;
  23427. private _indices;
  23428. private _normals;
  23429. private _colors;
  23430. private _uvs;
  23431. private _indices32;
  23432. private _positions32;
  23433. private _normals32;
  23434. private _fixedNormal32;
  23435. private _colors32;
  23436. private _uvs32;
  23437. private _index;
  23438. private _updatable;
  23439. private _pickable;
  23440. private _isVisibilityBoxLocked;
  23441. private _alwaysVisible;
  23442. private _depthSort;
  23443. private _shapeCounter;
  23444. private _copy;
  23445. private _color;
  23446. private _computeParticleColor;
  23447. private _computeParticleTexture;
  23448. private _computeParticleRotation;
  23449. private _computeParticleVertex;
  23450. private _computeBoundingBox;
  23451. private _depthSortParticles;
  23452. private _camera;
  23453. private _mustUnrotateFixedNormals;
  23454. private _particlesIntersect;
  23455. private _needs32Bits;
  23456. /**
  23457. * Creates a SPS (Solid Particle System) object.
  23458. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23459. * @param scene (Scene) is the scene in which the SPS is added.
  23460. * @param options defines the options of the sps e.g.
  23461. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23462. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23463. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23464. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23465. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23466. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23467. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23468. */
  23469. constructor(name: string, scene: Scene, options?: {
  23470. updatable?: boolean;
  23471. isPickable?: boolean;
  23472. enableDepthSort?: boolean;
  23473. particleIntersection?: boolean;
  23474. boundingSphereOnly?: boolean;
  23475. bSphereRadiusFactor?: number;
  23476. });
  23477. /**
  23478. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23479. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23480. * @returns the created mesh
  23481. */
  23482. buildMesh(): Mesh;
  23483. /**
  23484. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23485. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23486. * Thus the particles generated from `digest()` have their property `position` set yet.
  23487. * @param mesh ( Mesh ) is the mesh to be digested
  23488. * @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
  23489. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23490. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23491. * @returns the current SPS
  23492. */
  23493. digest(mesh: Mesh, options?: {
  23494. facetNb?: number;
  23495. number?: number;
  23496. delta?: number;
  23497. }): SolidParticleSystem;
  23498. private _unrotateFixedNormals;
  23499. private _resetCopy;
  23500. private _meshBuilder;
  23501. private _posToShape;
  23502. private _uvsToShapeUV;
  23503. private _addParticle;
  23504. /**
  23505. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23506. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23507. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23508. * @param nb (positive integer) the number of particles to be created from this model
  23509. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23510. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23511. * @returns the number of shapes in the system
  23512. */
  23513. addShape(mesh: Mesh, nb: number, options?: {
  23514. positionFunction?: any;
  23515. vertexFunction?: any;
  23516. }): number;
  23517. private _rebuildParticle;
  23518. /**
  23519. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23520. * @returns the SPS.
  23521. */
  23522. rebuildMesh(): SolidParticleSystem;
  23523. /**
  23524. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23525. * This method calls `updateParticle()` for each particle of the SPS.
  23526. * For an animated SPS, it is usually called within the render loop.
  23527. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23528. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23529. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23530. * @returns the SPS.
  23531. */
  23532. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23533. /**
  23534. * Disposes the SPS.
  23535. */
  23536. dispose(): void;
  23537. /**
  23538. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23539. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23540. * @returns the SPS.
  23541. */
  23542. refreshVisibleSize(): SolidParticleSystem;
  23543. /**
  23544. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23545. * @param size the size (float) of the visibility box
  23546. * note : this doesn't lock the SPS mesh bounding box.
  23547. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23548. */
  23549. setVisibilityBox(size: number): void;
  23550. /**
  23551. * Gets whether the SPS as always visible or not
  23552. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23553. */
  23554. /**
  23555. * Sets the SPS as always visible or not
  23556. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23557. */
  23558. isAlwaysVisible: boolean;
  23559. /**
  23560. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23561. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23562. */
  23563. /**
  23564. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23565. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23566. */
  23567. isVisibilityBoxLocked: boolean;
  23568. /**
  23569. * Tells to `setParticles()` to compute the particle rotations or not.
  23570. * Default value : true. The SPS is faster when it's set to false.
  23571. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23572. */
  23573. /**
  23574. * Gets if `setParticles()` computes the particle rotations or not.
  23575. * Default value : true. The SPS is faster when it's set to false.
  23576. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23577. */
  23578. computeParticleRotation: boolean;
  23579. /**
  23580. * Tells to `setParticles()` to compute the particle colors or not.
  23581. * Default value : true. The SPS is faster when it's set to false.
  23582. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23583. */
  23584. /**
  23585. * Gets if `setParticles()` computes the particle colors or not.
  23586. * Default value : true. The SPS is faster when it's set to false.
  23587. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23588. */
  23589. computeParticleColor: boolean;
  23590. /**
  23591. * Gets if `setParticles()` computes the particle textures or not.
  23592. * Default value : true. The SPS is faster when it's set to false.
  23593. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23594. */
  23595. computeParticleTexture: boolean;
  23596. /**
  23597. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23598. * Default value : false. The SPS is faster when it's set to false.
  23599. * Note : the particle custom vertex positions aren't stored values.
  23600. */
  23601. /**
  23602. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23603. * Default value : false. The SPS is faster when it's set to false.
  23604. * Note : the particle custom vertex positions aren't stored values.
  23605. */
  23606. computeParticleVertex: boolean;
  23607. /**
  23608. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23609. */
  23610. /**
  23611. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23612. */
  23613. computeBoundingBox: boolean;
  23614. /**
  23615. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23616. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23617. * Default : `true`
  23618. */
  23619. /**
  23620. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23621. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23622. * Default : `true`
  23623. */
  23624. depthSortParticles: boolean;
  23625. /**
  23626. * This function does nothing. It may be overwritten to set all the particle first values.
  23627. * The SPS doesn't call this function, you may have to call it by your own.
  23628. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23629. */
  23630. initParticles(): void;
  23631. /**
  23632. * This function does nothing. It may be overwritten to recycle a particle.
  23633. * The SPS doesn't call this function, you may have to call it by your own.
  23634. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23635. * @param particle The particle to recycle
  23636. * @returns the recycled particle
  23637. */
  23638. recycleParticle(particle: SolidParticle): SolidParticle;
  23639. /**
  23640. * Updates a particle : this function should be overwritten by the user.
  23641. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23642. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23643. * @example : just set a particle position or velocity and recycle conditions
  23644. * @param particle The particle to update
  23645. * @returns the updated particle
  23646. */
  23647. updateParticle(particle: SolidParticle): SolidParticle;
  23648. /**
  23649. * Updates a vertex of a particle : it can be overwritten by the user.
  23650. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23651. * @param particle the current particle
  23652. * @param vertex the current index of the current particle
  23653. * @param pt the index of the current vertex in the particle shape
  23654. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23655. * @example : just set a vertex particle position
  23656. * @returns the updated vertex
  23657. */
  23658. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23659. /**
  23660. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23661. * This does nothing and may be overwritten by the user.
  23662. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23663. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23664. * @param update the boolean update value actually passed to setParticles()
  23665. */
  23666. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23667. /**
  23668. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23669. * This will be passed three parameters.
  23670. * This does nothing and may be overwritten by the user.
  23671. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23672. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23673. * @param update the boolean update value actually passed to setParticles()
  23674. */
  23675. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23676. }
  23677. }
  23678. declare module "babylonjs/Particles/solidParticle" {
  23679. import { Nullable } from "babylonjs/types";
  23680. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23681. import { Mesh } from "babylonjs/Meshes/mesh";
  23682. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23683. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23684. /**
  23685. * Represents one particle of a solid particle system.
  23686. */
  23687. export class SolidParticle {
  23688. /**
  23689. * particle global index
  23690. */
  23691. idx: number;
  23692. /**
  23693. * The color of the particle
  23694. */
  23695. color: Nullable<Color4>;
  23696. /**
  23697. * The world space position of the particle.
  23698. */
  23699. position: Vector3;
  23700. /**
  23701. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23702. */
  23703. rotation: Vector3;
  23704. /**
  23705. * The world space rotation quaternion of the particle.
  23706. */
  23707. rotationQuaternion: Nullable<Quaternion>;
  23708. /**
  23709. * The scaling of the particle.
  23710. */
  23711. scaling: Vector3;
  23712. /**
  23713. * The uvs of the particle.
  23714. */
  23715. uvs: Vector4;
  23716. /**
  23717. * The current speed of the particle.
  23718. */
  23719. velocity: Vector3;
  23720. /**
  23721. * The pivot point in the particle local space.
  23722. */
  23723. pivot: Vector3;
  23724. /**
  23725. * Must the particle be translated from its pivot point in its local space ?
  23726. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23727. * Default : false
  23728. */
  23729. translateFromPivot: boolean;
  23730. /**
  23731. * Is the particle active or not ?
  23732. */
  23733. alive: boolean;
  23734. /**
  23735. * Is the particle visible or not ?
  23736. */
  23737. isVisible: boolean;
  23738. /**
  23739. * Index of this particle in the global "positions" array (Internal use)
  23740. * @hidden
  23741. */
  23742. _pos: number;
  23743. /**
  23744. * @hidden Index of this particle in the global "indices" array (Internal use)
  23745. */
  23746. _ind: number;
  23747. /**
  23748. * @hidden ModelShape of this particle (Internal use)
  23749. */
  23750. _model: ModelShape;
  23751. /**
  23752. * ModelShape id of this particle
  23753. */
  23754. shapeId: number;
  23755. /**
  23756. * Index of the particle in its shape id (Internal use)
  23757. */
  23758. idxInShape: number;
  23759. /**
  23760. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23761. */
  23762. _modelBoundingInfo: BoundingInfo;
  23763. /**
  23764. * @hidden Particle BoundingInfo object (Internal use)
  23765. */
  23766. _boundingInfo: BoundingInfo;
  23767. /**
  23768. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23769. */
  23770. _sps: SolidParticleSystem;
  23771. /**
  23772. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23773. */
  23774. _stillInvisible: boolean;
  23775. /**
  23776. * @hidden Last computed particle rotation matrix
  23777. */
  23778. _rotationMatrix: number[];
  23779. /**
  23780. * Parent particle Id, if any.
  23781. * Default null.
  23782. */
  23783. parentId: Nullable<number>;
  23784. /**
  23785. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23786. * The possible values are :
  23787. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23788. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23789. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23790. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23791. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23792. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23793. * */
  23794. cullingStrategy: number;
  23795. /**
  23796. * @hidden Internal global position in the SPS.
  23797. */
  23798. _globalPosition: Vector3;
  23799. /**
  23800. * Creates a Solid Particle object.
  23801. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23802. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23803. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23804. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23805. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23806. * @param shapeId (integer) is the model shape identifier in the SPS.
  23807. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23808. * @param sps defines the sps it is associated to
  23809. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23810. */
  23811. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23812. /**
  23813. * Legacy support, changed scale to scaling
  23814. */
  23815. /**
  23816. * Legacy support, changed scale to scaling
  23817. */
  23818. scale: Vector3;
  23819. /**
  23820. * Legacy support, changed quaternion to rotationQuaternion
  23821. */
  23822. /**
  23823. * Legacy support, changed quaternion to rotationQuaternion
  23824. */
  23825. quaternion: Nullable<Quaternion>;
  23826. /**
  23827. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23828. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23829. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23830. * @returns true if it intersects
  23831. */
  23832. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23833. /**
  23834. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23835. * A particle is in the frustum if its bounding box intersects the frustum
  23836. * @param frustumPlanes defines the frustum to test
  23837. * @returns true if the particle is in the frustum planes
  23838. */
  23839. isInFrustum(frustumPlanes: Plane[]): boolean;
  23840. /**
  23841. * get the rotation matrix of the particle
  23842. * @hidden
  23843. */
  23844. getRotationMatrix(m: Matrix): void;
  23845. }
  23846. /**
  23847. * Represents the shape of the model used by one particle of a solid particle system.
  23848. * SPS internal tool, don't use it manually.
  23849. */
  23850. export class ModelShape {
  23851. /**
  23852. * The shape id
  23853. * @hidden
  23854. */
  23855. shapeID: number;
  23856. /**
  23857. * flat array of model positions (internal use)
  23858. * @hidden
  23859. */
  23860. _shape: Vector3[];
  23861. /**
  23862. * flat array of model UVs (internal use)
  23863. * @hidden
  23864. */
  23865. _shapeUV: number[];
  23866. /**
  23867. * length of the shape in the model indices array (internal use)
  23868. * @hidden
  23869. */
  23870. _indicesLength: number;
  23871. /**
  23872. * Custom position function (internal use)
  23873. * @hidden
  23874. */
  23875. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23876. /**
  23877. * Custom vertex function (internal use)
  23878. * @hidden
  23879. */
  23880. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23881. /**
  23882. * 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.
  23883. * SPS internal tool, don't use it manually.
  23884. * @hidden
  23885. */
  23886. 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>);
  23887. }
  23888. /**
  23889. * Represents a Depth Sorted Particle in the solid particle system.
  23890. */
  23891. export class DepthSortedParticle {
  23892. /**
  23893. * Index of the particle in the "indices" array
  23894. */
  23895. ind: number;
  23896. /**
  23897. * Length of the particle shape in the "indices" array
  23898. */
  23899. indicesLength: number;
  23900. /**
  23901. * Squared distance from the particle to the camera
  23902. */
  23903. sqDistance: number;
  23904. }
  23905. }
  23906. declare module "babylonjs/Meshes/abstractMesh" {
  23907. import { Observable } from "babylonjs/Misc/observable";
  23908. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23909. import { Camera } from "babylonjs/Cameras/camera";
  23910. import { Scene, IDisposable } from "babylonjs/scene";
  23911. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23912. import { Node } from "babylonjs/node";
  23913. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23914. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23916. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23917. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23918. import { Material } from "babylonjs/Materials/material";
  23919. import { Light } from "babylonjs/Lights/light";
  23920. import { Skeleton } from "babylonjs/Bones/skeleton";
  23921. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23922. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23923. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23924. import { Ray } from "babylonjs/Culling/ray";
  23925. import { Collider } from "babylonjs/Collisions/collider";
  23926. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23927. /**
  23928. * Class used to store all common mesh properties
  23929. */
  23930. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23931. /** No occlusion */
  23932. static OCCLUSION_TYPE_NONE: number;
  23933. /** Occlusion set to optimisitic */
  23934. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23935. /** Occlusion set to strict */
  23936. static OCCLUSION_TYPE_STRICT: number;
  23937. /** Use an accurante occlusion algorithm */
  23938. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23939. /** Use a conservative occlusion algorithm */
  23940. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23941. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23942. * Test order :
  23943. * Is the bounding sphere outside the frustum ?
  23944. * If not, are the bounding box vertices outside the frustum ?
  23945. * It not, then the cullable object is in the frustum.
  23946. */
  23947. static readonly CULLINGSTRATEGY_STANDARD: number;
  23948. /** Culling strategy : Bounding Sphere Only.
  23949. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23950. * It's also less accurate than the standard because some not visible objects can still be selected.
  23951. * Test : is the bounding sphere outside the frustum ?
  23952. * If not, then the cullable object is in the frustum.
  23953. */
  23954. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23955. /** Culling strategy : Optimistic Inclusion.
  23956. * This in an inclusion test first, then the standard exclusion test.
  23957. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23958. * 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.
  23959. * Anyway, it's as accurate as the standard strategy.
  23960. * Test :
  23961. * Is the cullable object bounding sphere center in the frustum ?
  23962. * If not, apply the default culling strategy.
  23963. */
  23964. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23965. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23966. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23967. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23968. * 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.
  23969. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23970. * Test :
  23971. * Is the cullable object bounding sphere center in the frustum ?
  23972. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23973. */
  23974. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23975. /**
  23976. * No billboard
  23977. */
  23978. static readonly BILLBOARDMODE_NONE: number;
  23979. /** Billboard on X axis */
  23980. static readonly BILLBOARDMODE_X: number;
  23981. /** Billboard on Y axis */
  23982. static readonly BILLBOARDMODE_Y: number;
  23983. /** Billboard on Z axis */
  23984. static readonly BILLBOARDMODE_Z: number;
  23985. /** Billboard on all axes */
  23986. static readonly BILLBOARDMODE_ALL: number;
  23987. private _facetData;
  23988. /**
  23989. * The culling strategy to use to check whether the mesh must be rendered or not.
  23990. * This value can be changed at any time and will be used on the next render mesh selection.
  23991. * The possible values are :
  23992. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23993. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23994. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23995. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23996. * Please read each static variable documentation to get details about the culling process.
  23997. * */
  23998. cullingStrategy: number;
  23999. /**
  24000. * Gets the number of facets in the mesh
  24001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24002. */
  24003. readonly facetNb: number;
  24004. /**
  24005. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24007. */
  24008. partitioningSubdivisions: number;
  24009. /**
  24010. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24011. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24012. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24013. */
  24014. partitioningBBoxRatio: number;
  24015. /**
  24016. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24017. * Works only for updatable meshes.
  24018. * Doesn't work with multi-materials
  24019. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24020. */
  24021. mustDepthSortFacets: boolean;
  24022. /**
  24023. * The location (Vector3) where the facet depth sort must be computed from.
  24024. * By default, the active camera position.
  24025. * Used only when facet depth sort is enabled
  24026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24027. */
  24028. facetDepthSortFrom: Vector3;
  24029. /**
  24030. * gets a boolean indicating if facetData is enabled
  24031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24032. */
  24033. readonly isFacetDataEnabled: boolean;
  24034. /** @hidden */
  24035. _updateNonUniformScalingState(value: boolean): boolean;
  24036. /**
  24037. * An event triggered when this mesh collides with another one
  24038. */
  24039. onCollideObservable: Observable<AbstractMesh>;
  24040. private _onCollideObserver;
  24041. /** Set a function to call when this mesh collides with another one */
  24042. onCollide: () => void;
  24043. /**
  24044. * An event triggered when the collision's position changes
  24045. */
  24046. onCollisionPositionChangeObservable: Observable<Vector3>;
  24047. private _onCollisionPositionChangeObserver;
  24048. /** Set a function to call when the collision's position changes */
  24049. onCollisionPositionChange: () => void;
  24050. /**
  24051. * An event triggered when material is changed
  24052. */
  24053. onMaterialChangedObservable: Observable<AbstractMesh>;
  24054. /**
  24055. * Gets or sets the orientation for POV movement & rotation
  24056. */
  24057. definedFacingForward: boolean;
  24058. /** @hidden */
  24059. _occlusionQuery: Nullable<WebGLQuery>;
  24060. private _visibility;
  24061. /**
  24062. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24063. */
  24064. /**
  24065. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24066. */
  24067. visibility: number;
  24068. /** Gets or sets the alpha index used to sort transparent meshes
  24069. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24070. */
  24071. alphaIndex: number;
  24072. /**
  24073. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24074. */
  24075. isVisible: boolean;
  24076. /**
  24077. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24078. */
  24079. isPickable: boolean;
  24080. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24081. showSubMeshesBoundingBox: boolean;
  24082. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24083. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24084. */
  24085. isBlocker: boolean;
  24086. /**
  24087. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24088. */
  24089. enablePointerMoveEvents: boolean;
  24090. /**
  24091. * Specifies the rendering group id for this mesh (0 by default)
  24092. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24093. */
  24094. renderingGroupId: number;
  24095. private _material;
  24096. /** Gets or sets current material */
  24097. material: Nullable<Material>;
  24098. private _receiveShadows;
  24099. /**
  24100. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24101. * @see http://doc.babylonjs.com/babylon101/shadows
  24102. */
  24103. receiveShadows: boolean;
  24104. /** Defines color to use when rendering outline */
  24105. outlineColor: Color3;
  24106. /** Define width to use when rendering outline */
  24107. outlineWidth: number;
  24108. /** Defines color to use when rendering overlay */
  24109. overlayColor: Color3;
  24110. /** Defines alpha to use when rendering overlay */
  24111. overlayAlpha: number;
  24112. private _hasVertexAlpha;
  24113. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24114. hasVertexAlpha: boolean;
  24115. private _useVertexColors;
  24116. /** 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) */
  24117. useVertexColors: boolean;
  24118. private _computeBonesUsingShaders;
  24119. /**
  24120. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24121. */
  24122. computeBonesUsingShaders: boolean;
  24123. private _numBoneInfluencers;
  24124. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24125. numBoneInfluencers: number;
  24126. private _applyFog;
  24127. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24128. applyFog: boolean;
  24129. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24130. useOctreeForRenderingSelection: boolean;
  24131. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24132. useOctreeForPicking: boolean;
  24133. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24134. useOctreeForCollisions: boolean;
  24135. private _layerMask;
  24136. /**
  24137. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24138. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24139. */
  24140. layerMask: number;
  24141. /**
  24142. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24143. */
  24144. alwaysSelectAsActiveMesh: boolean;
  24145. /**
  24146. * Gets or sets the current action manager
  24147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24148. */
  24149. actionManager: Nullable<AbstractActionManager>;
  24150. private _checkCollisions;
  24151. private _collisionMask;
  24152. private _collisionGroup;
  24153. /**
  24154. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24156. */
  24157. ellipsoid: Vector3;
  24158. /**
  24159. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24161. */
  24162. ellipsoidOffset: Vector3;
  24163. private _collider;
  24164. private _oldPositionForCollisions;
  24165. private _diffPositionForCollisions;
  24166. /**
  24167. * Gets or sets a collision mask used to mask collisions (default is -1).
  24168. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24169. */
  24170. collisionMask: number;
  24171. /**
  24172. * Gets or sets the current collision group mask (-1 by default).
  24173. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24174. */
  24175. collisionGroup: number;
  24176. /**
  24177. * Defines edge width used when edgesRenderer is enabled
  24178. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24179. */
  24180. edgesWidth: number;
  24181. /**
  24182. * Defines edge color used when edgesRenderer is enabled
  24183. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24184. */
  24185. edgesColor: Color4;
  24186. /** @hidden */
  24187. _edgesRenderer: Nullable<IEdgesRenderer>;
  24188. /** @hidden */
  24189. _masterMesh: Nullable<AbstractMesh>;
  24190. /** @hidden */
  24191. _boundingInfo: Nullable<BoundingInfo>;
  24192. /** @hidden */
  24193. _renderId: number;
  24194. /**
  24195. * Gets or sets the list of subMeshes
  24196. * @see http://doc.babylonjs.com/how_to/multi_materials
  24197. */
  24198. subMeshes: SubMesh[];
  24199. /** @hidden */
  24200. _intersectionsInProgress: AbstractMesh[];
  24201. /** @hidden */
  24202. _unIndexed: boolean;
  24203. /** @hidden */
  24204. _lightSources: Light[];
  24205. /** @hidden */
  24206. readonly _positions: Nullable<Vector3[]>;
  24207. /** @hidden */
  24208. _waitingActions: any;
  24209. /** @hidden */
  24210. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24211. private _skeleton;
  24212. /** @hidden */
  24213. _bonesTransformMatrices: Nullable<Float32Array>;
  24214. /**
  24215. * Gets or sets a skeleton to apply skining transformations
  24216. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24217. */
  24218. skeleton: Nullable<Skeleton>;
  24219. /**
  24220. * An event triggered when the mesh is rebuilt.
  24221. */
  24222. onRebuildObservable: Observable<AbstractMesh>;
  24223. /**
  24224. * Creates a new AbstractMesh
  24225. * @param name defines the name of the mesh
  24226. * @param scene defines the hosting scene
  24227. */
  24228. constructor(name: string, scene?: Nullable<Scene>);
  24229. /**
  24230. * Returns the string "AbstractMesh"
  24231. * @returns "AbstractMesh"
  24232. */
  24233. getClassName(): string;
  24234. /**
  24235. * Gets a string representation of the current mesh
  24236. * @param fullDetails defines a boolean indicating if full details must be included
  24237. * @returns a string representation of the current mesh
  24238. */
  24239. toString(fullDetails?: boolean): string;
  24240. /** @hidden */
  24241. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24242. /** @hidden */
  24243. _rebuild(): void;
  24244. /** @hidden */
  24245. _resyncLightSources(): void;
  24246. /** @hidden */
  24247. _resyncLighSource(light: Light): void;
  24248. /** @hidden */
  24249. _unBindEffect(): void;
  24250. /** @hidden */
  24251. _removeLightSource(light: Light): void;
  24252. private _markSubMeshesAsDirty;
  24253. /** @hidden */
  24254. _markSubMeshesAsLightDirty(): void;
  24255. /** @hidden */
  24256. _markSubMeshesAsAttributesDirty(): void;
  24257. /** @hidden */
  24258. _markSubMeshesAsMiscDirty(): void;
  24259. /**
  24260. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24261. */
  24262. scaling: Vector3;
  24263. /**
  24264. * Returns true if the mesh is blocked. Implemented by child classes
  24265. */
  24266. readonly isBlocked: boolean;
  24267. /**
  24268. * Returns the mesh itself by default. Implemented by child classes
  24269. * @param camera defines the camera to use to pick the right LOD level
  24270. * @returns the currentAbstractMesh
  24271. */
  24272. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24273. /**
  24274. * Returns 0 by default. Implemented by child classes
  24275. * @returns an integer
  24276. */
  24277. getTotalVertices(): number;
  24278. /**
  24279. * Returns a positive integer : the total number of indices in this mesh geometry.
  24280. * @returns the numner of indices or zero if the mesh has no geometry.
  24281. */
  24282. getTotalIndices(): number;
  24283. /**
  24284. * Returns null by default. Implemented by child classes
  24285. * @returns null
  24286. */
  24287. getIndices(): Nullable<IndicesArray>;
  24288. /**
  24289. * Returns the array of the requested vertex data kind. Implemented by child classes
  24290. * @param kind defines the vertex data kind to use
  24291. * @returns null
  24292. */
  24293. getVerticesData(kind: string): Nullable<FloatArray>;
  24294. /**
  24295. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24296. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24297. * Note that a new underlying VertexBuffer object is created each call.
  24298. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24299. * @param kind defines vertex data kind:
  24300. * * VertexBuffer.PositionKind
  24301. * * VertexBuffer.UVKind
  24302. * * VertexBuffer.UV2Kind
  24303. * * VertexBuffer.UV3Kind
  24304. * * VertexBuffer.UV4Kind
  24305. * * VertexBuffer.UV5Kind
  24306. * * VertexBuffer.UV6Kind
  24307. * * VertexBuffer.ColorKind
  24308. * * VertexBuffer.MatricesIndicesKind
  24309. * * VertexBuffer.MatricesIndicesExtraKind
  24310. * * VertexBuffer.MatricesWeightsKind
  24311. * * VertexBuffer.MatricesWeightsExtraKind
  24312. * @param data defines the data source
  24313. * @param updatable defines if the data must be flagged as updatable (or static)
  24314. * @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
  24315. * @returns the current mesh
  24316. */
  24317. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24318. /**
  24319. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24320. * If the mesh has no geometry, it is simply returned as it is.
  24321. * @param kind defines vertex data kind:
  24322. * * VertexBuffer.PositionKind
  24323. * * VertexBuffer.UVKind
  24324. * * VertexBuffer.UV2Kind
  24325. * * VertexBuffer.UV3Kind
  24326. * * VertexBuffer.UV4Kind
  24327. * * VertexBuffer.UV5Kind
  24328. * * VertexBuffer.UV6Kind
  24329. * * VertexBuffer.ColorKind
  24330. * * VertexBuffer.MatricesIndicesKind
  24331. * * VertexBuffer.MatricesIndicesExtraKind
  24332. * * VertexBuffer.MatricesWeightsKind
  24333. * * VertexBuffer.MatricesWeightsExtraKind
  24334. * @param data defines the data source
  24335. * @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
  24336. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24337. * @returns the current mesh
  24338. */
  24339. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24340. /**
  24341. * Sets the mesh indices,
  24342. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24343. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24344. * @param totalVertices Defines the total number of vertices
  24345. * @returns the current mesh
  24346. */
  24347. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24348. /**
  24349. * Gets a boolean indicating if specific vertex data is present
  24350. * @param kind defines the vertex data kind to use
  24351. * @returns true is data kind is present
  24352. */
  24353. isVerticesDataPresent(kind: string): boolean;
  24354. /**
  24355. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24356. * @returns a BoundingInfo
  24357. */
  24358. getBoundingInfo(): BoundingInfo;
  24359. /**
  24360. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24361. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24362. * @returns the current mesh
  24363. */
  24364. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24365. /**
  24366. * Overwrite the current bounding info
  24367. * @param boundingInfo defines the new bounding info
  24368. * @returns the current mesh
  24369. */
  24370. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24371. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24372. readonly useBones: boolean;
  24373. /** @hidden */
  24374. _preActivate(): void;
  24375. /** @hidden */
  24376. _preActivateForIntermediateRendering(renderId: number): void;
  24377. /** @hidden */
  24378. _activate(renderId: number): void;
  24379. /**
  24380. * Gets the current world matrix
  24381. * @returns a Matrix
  24382. */
  24383. getWorldMatrix(): Matrix;
  24384. /** @hidden */
  24385. _getWorldMatrixDeterminant(): number;
  24386. /**
  24387. * Perform relative position change from the point of view of behind the front of the mesh.
  24388. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24389. * Supports definition of mesh facing forward or backward
  24390. * @param amountRight defines the distance on the right axis
  24391. * @param amountUp defines the distance on the up axis
  24392. * @param amountForward defines the distance on the forward axis
  24393. * @returns the current mesh
  24394. */
  24395. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24396. /**
  24397. * Calculate relative position change from the point of view of behind the front of the mesh.
  24398. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24399. * Supports definition of mesh facing forward or backward
  24400. * @param amountRight defines the distance on the right axis
  24401. * @param amountUp defines the distance on the up axis
  24402. * @param amountForward defines the distance on the forward axis
  24403. * @returns the new displacement vector
  24404. */
  24405. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24406. /**
  24407. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24408. * Supports definition of mesh facing forward or backward
  24409. * @param flipBack defines the flip
  24410. * @param twirlClockwise defines the twirl
  24411. * @param tiltRight defines the tilt
  24412. * @returns the current mesh
  24413. */
  24414. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24415. /**
  24416. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24417. * Supports definition of mesh facing forward or backward.
  24418. * @param flipBack defines the flip
  24419. * @param twirlClockwise defines the twirl
  24420. * @param tiltRight defines the tilt
  24421. * @returns the new rotation vector
  24422. */
  24423. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24424. /**
  24425. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24426. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24427. * @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
  24428. * @returns the new bounding vectors
  24429. */
  24430. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24431. min: Vector3;
  24432. max: Vector3;
  24433. };
  24434. /**
  24435. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24436. * This means the mesh underlying bounding box and sphere are recomputed.
  24437. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24438. * @returns the current mesh
  24439. */
  24440. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24441. /** @hidden */
  24442. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24443. /** @hidden */
  24444. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24445. /** @hidden */
  24446. _updateBoundingInfo(): AbstractMesh;
  24447. /** @hidden */
  24448. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24449. /** @hidden */
  24450. protected _afterComputeWorldMatrix(): void;
  24451. /**
  24452. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24453. * A mesh is in the frustum if its bounding box intersects the frustum
  24454. * @param frustumPlanes defines the frustum to test
  24455. * @returns true if the mesh is in the frustum planes
  24456. */
  24457. isInFrustum(frustumPlanes: Plane[]): boolean;
  24458. /**
  24459. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24460. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24461. * @param frustumPlanes defines the frustum to test
  24462. * @returns true if the mesh is completely in the frustum planes
  24463. */
  24464. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24465. /**
  24466. * True if the mesh intersects another mesh or a SolidParticle object
  24467. * @param mesh defines a target mesh or SolidParticle to test
  24468. * @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)
  24469. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24470. * @returns true if there is an intersection
  24471. */
  24472. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24473. /**
  24474. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24475. * @param point defines the point to test
  24476. * @returns true if there is an intersection
  24477. */
  24478. intersectsPoint(point: Vector3): boolean;
  24479. /**
  24480. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24481. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24482. */
  24483. checkCollisions: boolean;
  24484. /**
  24485. * Gets Collider object used to compute collisions (not physics)
  24486. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24487. */
  24488. readonly collider: Collider;
  24489. /**
  24490. * Move the mesh using collision engine
  24491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24492. * @param displacement defines the requested displacement vector
  24493. * @returns the current mesh
  24494. */
  24495. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24496. private _onCollisionPositionChange;
  24497. /** @hidden */
  24498. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24499. /** @hidden */
  24500. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24501. /** @hidden */
  24502. _checkCollision(collider: Collider): AbstractMesh;
  24503. /** @hidden */
  24504. _generatePointsArray(): boolean;
  24505. /**
  24506. * Checks if the passed Ray intersects with the mesh
  24507. * @param ray defines the ray to use
  24508. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24509. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24510. * @returns the picking info
  24511. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24512. */
  24513. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24514. /**
  24515. * Clones the current mesh
  24516. * @param name defines the mesh name
  24517. * @param newParent defines the new mesh parent
  24518. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24519. * @returns the new mesh
  24520. */
  24521. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24522. /**
  24523. * Disposes all the submeshes of the current meshnp
  24524. * @returns the current mesh
  24525. */
  24526. releaseSubMeshes(): AbstractMesh;
  24527. /**
  24528. * Releases resources associated with this abstract mesh.
  24529. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24530. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24531. */
  24532. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24533. /**
  24534. * Adds the passed mesh as a child to the current mesh
  24535. * @param mesh defines the child mesh
  24536. * @returns the current mesh
  24537. */
  24538. addChild(mesh: AbstractMesh): AbstractMesh;
  24539. /**
  24540. * Removes the passed mesh from the current mesh children list
  24541. * @param mesh defines the child mesh
  24542. * @returns the current mesh
  24543. */
  24544. removeChild(mesh: AbstractMesh): AbstractMesh;
  24545. /** @hidden */
  24546. private _initFacetData;
  24547. /**
  24548. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24549. * This method can be called within the render loop.
  24550. * 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
  24551. * @returns the current mesh
  24552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24553. */
  24554. updateFacetData(): AbstractMesh;
  24555. /**
  24556. * Returns the facetLocalNormals array.
  24557. * The normals are expressed in the mesh local spac
  24558. * @returns an array of Vector3
  24559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24560. */
  24561. getFacetLocalNormals(): Vector3[];
  24562. /**
  24563. * Returns the facetLocalPositions array.
  24564. * The facet positions are expressed in the mesh local space
  24565. * @returns an array of Vector3
  24566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24567. */
  24568. getFacetLocalPositions(): Vector3[];
  24569. /**
  24570. * Returns the facetLocalPartioning array
  24571. * @returns an array of array of numbers
  24572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24573. */
  24574. getFacetLocalPartitioning(): number[][];
  24575. /**
  24576. * Returns the i-th facet position in the world system.
  24577. * This method allocates a new Vector3 per call
  24578. * @param i defines the facet index
  24579. * @returns a new Vector3
  24580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24581. */
  24582. getFacetPosition(i: number): Vector3;
  24583. /**
  24584. * Sets the reference Vector3 with the i-th facet position in the world system
  24585. * @param i defines the facet index
  24586. * @param ref defines the target vector
  24587. * @returns the current mesh
  24588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24589. */
  24590. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24591. /**
  24592. * Returns the i-th facet normal in the world system.
  24593. * This method allocates a new Vector3 per call
  24594. * @param i defines the facet index
  24595. * @returns a new Vector3
  24596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24597. */
  24598. getFacetNormal(i: number): Vector3;
  24599. /**
  24600. * Sets the reference Vector3 with the i-th facet normal in the world system
  24601. * @param i defines the facet index
  24602. * @param ref defines the target vector
  24603. * @returns the current mesh
  24604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24605. */
  24606. getFacetNormalToRef(i: number, ref: Vector3): this;
  24607. /**
  24608. * 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)
  24609. * @param x defines x coordinate
  24610. * @param y defines y coordinate
  24611. * @param z defines z coordinate
  24612. * @returns the array of facet indexes
  24613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24614. */
  24615. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24616. /**
  24617. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24618. * @param projected sets as the (x,y,z) world projection on the facet
  24619. * @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
  24620. * @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
  24621. * @param x defines x coordinate
  24622. * @param y defines y coordinate
  24623. * @param z defines z coordinate
  24624. * @returns the face index if found (or null instead)
  24625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24626. */
  24627. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24628. /**
  24629. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24630. * @param projected sets as the (x,y,z) local projection on the facet
  24631. * @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
  24632. * @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
  24633. * @param x defines x coordinate
  24634. * @param y defines y coordinate
  24635. * @param z defines z coordinate
  24636. * @returns the face index if found (or null instead)
  24637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24638. */
  24639. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24640. /**
  24641. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24642. * @returns the parameters
  24643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24644. */
  24645. getFacetDataParameters(): any;
  24646. /**
  24647. * Disables the feature FacetData and frees the related memory
  24648. * @returns the current mesh
  24649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24650. */
  24651. disableFacetData(): AbstractMesh;
  24652. /**
  24653. * Updates the AbstractMesh indices array
  24654. * @param indices defines the data source
  24655. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24656. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24657. * @returns the current mesh
  24658. */
  24659. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24660. /**
  24661. * Creates new normals data for the mesh
  24662. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24663. * @returns the current mesh
  24664. */
  24665. createNormals(updatable: boolean): AbstractMesh;
  24666. /**
  24667. * Align the mesh with a normal
  24668. * @param normal defines the normal to use
  24669. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24670. * @returns the current mesh
  24671. */
  24672. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24673. /** @hidden */
  24674. _checkOcclusionQuery(): boolean;
  24675. }
  24676. }
  24677. declare module "babylonjs/Actions/actionEvent" {
  24678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24679. import { Nullable } from "babylonjs/types";
  24680. import { Sprite } from "babylonjs/Sprites/sprite";
  24681. import { Scene } from "babylonjs/scene";
  24682. import { Vector2 } from "babylonjs/Maths/math";
  24683. /**
  24684. * Interface used to define ActionEvent
  24685. */
  24686. export interface IActionEvent {
  24687. /** The mesh or sprite that triggered the action */
  24688. source: any;
  24689. /** The X mouse cursor position at the time of the event */
  24690. pointerX: number;
  24691. /** The Y mouse cursor position at the time of the event */
  24692. pointerY: number;
  24693. /** The mesh that is currently pointed at (can be null) */
  24694. meshUnderPointer: Nullable<AbstractMesh>;
  24695. /** the original (browser) event that triggered the ActionEvent */
  24696. sourceEvent?: any;
  24697. /** additional data for the event */
  24698. additionalData?: any;
  24699. }
  24700. /**
  24701. * ActionEvent is the event being sent when an action is triggered.
  24702. */
  24703. export class ActionEvent implements IActionEvent {
  24704. /** The mesh or sprite that triggered the action */
  24705. source: any;
  24706. /** The X mouse cursor position at the time of the event */
  24707. pointerX: number;
  24708. /** The Y mouse cursor position at the time of the event */
  24709. pointerY: number;
  24710. /** The mesh that is currently pointed at (can be null) */
  24711. meshUnderPointer: Nullable<AbstractMesh>;
  24712. /** the original (browser) event that triggered the ActionEvent */
  24713. sourceEvent?: any;
  24714. /** additional data for the event */
  24715. additionalData?: any;
  24716. /**
  24717. * Creates a new ActionEvent
  24718. * @param source The mesh or sprite that triggered the action
  24719. * @param pointerX The X mouse cursor position at the time of the event
  24720. * @param pointerY The Y mouse cursor position at the time of the event
  24721. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24722. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24723. * @param additionalData additional data for the event
  24724. */
  24725. constructor(
  24726. /** The mesh or sprite that triggered the action */
  24727. source: any,
  24728. /** The X mouse cursor position at the time of the event */
  24729. pointerX: number,
  24730. /** The Y mouse cursor position at the time of the event */
  24731. pointerY: number,
  24732. /** The mesh that is currently pointed at (can be null) */
  24733. meshUnderPointer: Nullable<AbstractMesh>,
  24734. /** the original (browser) event that triggered the ActionEvent */
  24735. sourceEvent?: any,
  24736. /** additional data for the event */
  24737. additionalData?: any);
  24738. /**
  24739. * Helper function to auto-create an ActionEvent from a source mesh.
  24740. * @param source The source mesh that triggered the event
  24741. * @param evt The original (browser) event
  24742. * @param additionalData additional data for the event
  24743. * @returns the new ActionEvent
  24744. */
  24745. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24746. /**
  24747. * Helper function to auto-create an ActionEvent from a source sprite
  24748. * @param source The source sprite that triggered the event
  24749. * @param scene Scene associated with the sprite
  24750. * @param evt The original (browser) event
  24751. * @param additionalData additional data for the event
  24752. * @returns the new ActionEvent
  24753. */
  24754. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24755. /**
  24756. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24757. * @param scene the scene where the event occurred
  24758. * @param evt The original (browser) event
  24759. * @returns the new ActionEvent
  24760. */
  24761. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24762. /**
  24763. * Helper function to auto-create an ActionEvent from a primitive
  24764. * @param prim defines the target primitive
  24765. * @param pointerPos defines the pointer position
  24766. * @param evt The original (browser) event
  24767. * @param additionalData additional data for the event
  24768. * @returns the new ActionEvent
  24769. */
  24770. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24771. }
  24772. }
  24773. declare module "babylonjs/Actions/abstractActionManager" {
  24774. import { IDisposable } from "babylonjs/scene";
  24775. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24776. import { IAction } from "babylonjs/Actions/action";
  24777. import { Nullable } from "babylonjs/types";
  24778. /**
  24779. * Abstract class used to decouple action Manager from scene and meshes.
  24780. * Do not instantiate.
  24781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24782. */
  24783. export abstract class AbstractActionManager implements IDisposable {
  24784. /** Gets the list of active triggers */
  24785. static Triggers: {
  24786. [key: string]: number;
  24787. };
  24788. /** Gets the cursor to use when hovering items */
  24789. hoverCursor: string;
  24790. /** Gets the list of actions */
  24791. actions: IAction[];
  24792. /**
  24793. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24794. */
  24795. isRecursive: boolean;
  24796. /**
  24797. * Releases all associated resources
  24798. */
  24799. abstract dispose(): void;
  24800. /**
  24801. * Does this action manager has pointer triggers
  24802. */
  24803. abstract readonly hasPointerTriggers: boolean;
  24804. /**
  24805. * Does this action manager has pick triggers
  24806. */
  24807. abstract readonly hasPickTriggers: boolean;
  24808. /**
  24809. * Process a specific trigger
  24810. * @param trigger defines the trigger to process
  24811. * @param evt defines the event details to be processed
  24812. */
  24813. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24814. /**
  24815. * Does this action manager handles actions of any of the given triggers
  24816. * @param triggers defines the triggers to be tested
  24817. * @return a boolean indicating whether one (or more) of the triggers is handled
  24818. */
  24819. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24820. /**
  24821. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24822. * speed.
  24823. * @param triggerA defines the trigger to be tested
  24824. * @param triggerB defines the trigger to be tested
  24825. * @return a boolean indicating whether one (or more) of the triggers is handled
  24826. */
  24827. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24828. /**
  24829. * Does this action manager handles actions of a given trigger
  24830. * @param trigger defines the trigger to be tested
  24831. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24832. * @return whether the trigger is handled
  24833. */
  24834. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24835. /**
  24836. * Serialize this manager to a JSON object
  24837. * @param name defines the property name to store this manager
  24838. * @returns a JSON representation of this manager
  24839. */
  24840. abstract serialize(name: string): any;
  24841. /**
  24842. * Registers an action to this action manager
  24843. * @param action defines the action to be registered
  24844. * @return the action amended (prepared) after registration
  24845. */
  24846. abstract registerAction(action: IAction): Nullable<IAction>;
  24847. /**
  24848. * Unregisters an action to this action manager
  24849. * @param action defines the action to be unregistered
  24850. * @return a boolean indicating whether the action has been unregistered
  24851. */
  24852. abstract unregisterAction(action: IAction): Boolean;
  24853. /**
  24854. * Does exist one action manager with at least one trigger
  24855. **/
  24856. static readonly HasTriggers: boolean;
  24857. /**
  24858. * Does exist one action manager with at least one pick trigger
  24859. **/
  24860. static readonly HasPickTriggers: boolean;
  24861. /**
  24862. * Does exist one action manager that handles actions of a given trigger
  24863. * @param trigger defines the trigger to be tested
  24864. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24865. **/
  24866. static HasSpecificTrigger(trigger: number): boolean;
  24867. }
  24868. }
  24869. declare module "babylonjs/node" {
  24870. import { Scene } from "babylonjs/scene";
  24871. import { Nullable } from "babylonjs/types";
  24872. import { Matrix } from "babylonjs/Maths/math";
  24873. import { Engine } from "babylonjs/Engines/engine";
  24874. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24875. import { Observable } from "babylonjs/Misc/observable";
  24876. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24877. import { Animatable } from "babylonjs/Animations/animatable";
  24878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24879. import { Animation } from "babylonjs/Animations/animation";
  24880. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24882. /**
  24883. * Defines how a node can be built from a string name.
  24884. */
  24885. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24886. /**
  24887. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24888. */
  24889. export class Node implements IBehaviorAware<Node> {
  24890. /** @hidden */
  24891. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24892. private static _NodeConstructors;
  24893. /**
  24894. * Add a new node constructor
  24895. * @param type defines the type name of the node to construct
  24896. * @param constructorFunc defines the constructor function
  24897. */
  24898. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24899. /**
  24900. * Returns a node constructor based on type name
  24901. * @param type defines the type name
  24902. * @param name defines the new node name
  24903. * @param scene defines the hosting scene
  24904. * @param options defines optional options to transmit to constructors
  24905. * @returns the new constructor or null
  24906. */
  24907. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24908. /**
  24909. * Gets or sets the name of the node
  24910. */
  24911. name: string;
  24912. /**
  24913. * Gets or sets the id of the node
  24914. */
  24915. id: string;
  24916. /**
  24917. * Gets or sets the unique id of the node
  24918. */
  24919. uniqueId: number;
  24920. /**
  24921. * Gets or sets a string used to store user defined state for the node
  24922. */
  24923. state: string;
  24924. /**
  24925. * Gets or sets an object used to store user defined information for the node
  24926. */
  24927. metadata: any;
  24928. /**
  24929. * For internal use only. Please do not use.
  24930. */
  24931. reservedDataStore: any;
  24932. /**
  24933. * Gets or sets a boolean used to define if the node must be serialized
  24934. */
  24935. doNotSerialize: boolean;
  24936. /** @hidden */
  24937. _isDisposed: boolean;
  24938. /**
  24939. * Gets a list of Animations associated with the node
  24940. */
  24941. animations: import("babylonjs/Animations/animation").Animation[];
  24942. protected _ranges: {
  24943. [name: string]: Nullable<AnimationRange>;
  24944. };
  24945. /**
  24946. * Callback raised when the node is ready to be used
  24947. */
  24948. onReady: (node: Node) => void;
  24949. private _isEnabled;
  24950. private _isParentEnabled;
  24951. private _isReady;
  24952. /** @hidden */
  24953. _currentRenderId: number;
  24954. private _parentRenderId;
  24955. protected _childRenderId: number;
  24956. /** @hidden */
  24957. _waitingParentId: Nullable<string>;
  24958. /** @hidden */
  24959. _scene: Scene;
  24960. /** @hidden */
  24961. _cache: any;
  24962. private _parentNode;
  24963. private _children;
  24964. /** @hidden */
  24965. _worldMatrix: Matrix;
  24966. /** @hidden */
  24967. _worldMatrixDeterminant: number;
  24968. /** @hidden */
  24969. private _sceneRootNodesIndex;
  24970. /**
  24971. * Gets a boolean indicating if the node has been disposed
  24972. * @returns true if the node was disposed
  24973. */
  24974. isDisposed(): boolean;
  24975. /**
  24976. * Gets or sets the parent of the node
  24977. */
  24978. parent: Nullable<Node>;
  24979. private addToSceneRootNodes;
  24980. private removeFromSceneRootNodes;
  24981. private _animationPropertiesOverride;
  24982. /**
  24983. * Gets or sets the animation properties override
  24984. */
  24985. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24986. /**
  24987. * Gets a string idenfifying the name of the class
  24988. * @returns "Node" string
  24989. */
  24990. getClassName(): string;
  24991. /** @hidden */
  24992. readonly _isNode: boolean;
  24993. /**
  24994. * An event triggered when the mesh is disposed
  24995. */
  24996. onDisposeObservable: Observable<Node>;
  24997. private _onDisposeObserver;
  24998. /**
  24999. * Sets a callback that will be raised when the node will be disposed
  25000. */
  25001. onDispose: () => void;
  25002. /**
  25003. * Creates a new Node
  25004. * @param name the name and id to be given to this node
  25005. * @param scene the scene this node will be added to
  25006. * @param addToRootNodes the node will be added to scene.rootNodes
  25007. */
  25008. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25009. /**
  25010. * Gets the scene of the node
  25011. * @returns a scene
  25012. */
  25013. getScene(): Scene;
  25014. /**
  25015. * Gets the engine of the node
  25016. * @returns a Engine
  25017. */
  25018. getEngine(): Engine;
  25019. private _behaviors;
  25020. /**
  25021. * Attach a behavior to the node
  25022. * @see http://doc.babylonjs.com/features/behaviour
  25023. * @param behavior defines the behavior to attach
  25024. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25025. * @returns the current Node
  25026. */
  25027. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25028. /**
  25029. * Remove an attached behavior
  25030. * @see http://doc.babylonjs.com/features/behaviour
  25031. * @param behavior defines the behavior to attach
  25032. * @returns the current Node
  25033. */
  25034. removeBehavior(behavior: Behavior<Node>): Node;
  25035. /**
  25036. * Gets the list of attached behaviors
  25037. * @see http://doc.babylonjs.com/features/behaviour
  25038. */
  25039. readonly behaviors: Behavior<Node>[];
  25040. /**
  25041. * Gets an attached behavior by name
  25042. * @param name defines the name of the behavior to look for
  25043. * @see http://doc.babylonjs.com/features/behaviour
  25044. * @returns null if behavior was not found else the requested behavior
  25045. */
  25046. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25047. /**
  25048. * Returns the latest update of the World matrix
  25049. * @returns a Matrix
  25050. */
  25051. getWorldMatrix(): Matrix;
  25052. /** @hidden */
  25053. _getWorldMatrixDeterminant(): number;
  25054. /**
  25055. * Returns directly the latest state of the mesh World matrix.
  25056. * A Matrix is returned.
  25057. */
  25058. readonly worldMatrixFromCache: Matrix;
  25059. /** @hidden */
  25060. _initCache(): void;
  25061. /** @hidden */
  25062. updateCache(force?: boolean): void;
  25063. /** @hidden */
  25064. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25065. /** @hidden */
  25066. _updateCache(ignoreParentClass?: boolean): void;
  25067. /** @hidden */
  25068. _isSynchronized(): boolean;
  25069. /** @hidden */
  25070. _markSyncedWithParent(): void;
  25071. /** @hidden */
  25072. isSynchronizedWithParent(): boolean;
  25073. /** @hidden */
  25074. isSynchronized(): boolean;
  25075. /**
  25076. * Is this node ready to be used/rendered
  25077. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25078. * @return true if the node is ready
  25079. */
  25080. isReady(completeCheck?: boolean): boolean;
  25081. /**
  25082. * Is this node enabled?
  25083. * 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
  25084. * @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
  25085. * @return whether this node (and its parent) is enabled
  25086. */
  25087. isEnabled(checkAncestors?: boolean): boolean;
  25088. /** @hidden */
  25089. protected _syncParentEnabledState(): void;
  25090. /**
  25091. * Set the enabled state of this node
  25092. * @param value defines the new enabled state
  25093. */
  25094. setEnabled(value: boolean): void;
  25095. /**
  25096. * Is this node a descendant of the given node?
  25097. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25098. * @param ancestor defines the parent node to inspect
  25099. * @returns a boolean indicating if this node is a descendant of the given node
  25100. */
  25101. isDescendantOf(ancestor: Node): boolean;
  25102. /** @hidden */
  25103. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25104. /**
  25105. * Will return all nodes that have this node as ascendant
  25106. * @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
  25107. * @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
  25108. * @return all children nodes of all types
  25109. */
  25110. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25111. /**
  25112. * Get all child-meshes of this node
  25113. * @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)
  25114. * @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
  25115. * @returns an array of AbstractMesh
  25116. */
  25117. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25118. /**
  25119. * Get all direct children of this node
  25120. * @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
  25121. * @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)
  25122. * @returns an array of Node
  25123. */
  25124. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25125. /** @hidden */
  25126. _setReady(state: boolean): void;
  25127. /**
  25128. * Get an animation by name
  25129. * @param name defines the name of the animation to look for
  25130. * @returns null if not found else the requested animation
  25131. */
  25132. getAnimationByName(name: string): Nullable<Animation>;
  25133. /**
  25134. * Creates an animation range for this node
  25135. * @param name defines the name of the range
  25136. * @param from defines the starting key
  25137. * @param to defines the end key
  25138. */
  25139. createAnimationRange(name: string, from: number, to: number): void;
  25140. /**
  25141. * Delete a specific animation range
  25142. * @param name defines the name of the range to delete
  25143. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25144. */
  25145. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25146. /**
  25147. * Get an animation range by name
  25148. * @param name defines the name of the animation range to look for
  25149. * @returns null if not found else the requested animation range
  25150. */
  25151. getAnimationRange(name: string): Nullable<AnimationRange>;
  25152. /**
  25153. * Gets the list of all animation ranges defined on this node
  25154. * @returns an array
  25155. */
  25156. getAnimationRanges(): Nullable<AnimationRange>[];
  25157. /**
  25158. * Will start the animation sequence
  25159. * @param name defines the range frames for animation sequence
  25160. * @param loop defines if the animation should loop (false by default)
  25161. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25162. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25163. * @returns the object created for this animation. If range does not exist, it will return null
  25164. */
  25165. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25166. /**
  25167. * Serialize animation ranges into a JSON compatible object
  25168. * @returns serialization object
  25169. */
  25170. serializeAnimationRanges(): any;
  25171. /**
  25172. * Computes the world matrix of the node
  25173. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25174. * @returns the world matrix
  25175. */
  25176. computeWorldMatrix(force?: boolean): Matrix;
  25177. /**
  25178. * Releases resources associated with this node.
  25179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25181. */
  25182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25183. /**
  25184. * Parse animation range data from a serialization object and store them into a given node
  25185. * @param node defines where to store the animation ranges
  25186. * @param parsedNode defines the serialization object to read data from
  25187. * @param scene defines the hosting scene
  25188. */
  25189. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25190. }
  25191. }
  25192. declare module "babylonjs/Animations/animation" {
  25193. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25194. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25195. import { Nullable } from "babylonjs/types";
  25196. import { Scene } from "babylonjs/scene";
  25197. import { IAnimatable } from "babylonjs/Misc/tools";
  25198. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25199. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25200. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25201. import { Node } from "babylonjs/node";
  25202. import { Animatable } from "babylonjs/Animations/animatable";
  25203. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25204. /**
  25205. * Class used to store any kind of animation
  25206. */
  25207. export class Animation {
  25208. /**Name of the animation */
  25209. name: string;
  25210. /**Property to animate */
  25211. targetProperty: string;
  25212. /**The frames per second of the animation */
  25213. framePerSecond: number;
  25214. /**The data type of the animation */
  25215. dataType: number;
  25216. /**The loop mode of the animation */
  25217. loopMode?: number | undefined;
  25218. /**Specifies if blending should be enabled */
  25219. enableBlending?: boolean | undefined;
  25220. /**
  25221. * Use matrix interpolation instead of using direct key value when animating matrices
  25222. */
  25223. static AllowMatricesInterpolation: boolean;
  25224. /**
  25225. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25226. */
  25227. static AllowMatrixDecomposeForInterpolation: boolean;
  25228. /**
  25229. * Stores the key frames of the animation
  25230. */
  25231. private _keys;
  25232. /**
  25233. * Stores the easing function of the animation
  25234. */
  25235. private _easingFunction;
  25236. /**
  25237. * @hidden Internal use only
  25238. */
  25239. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25240. /**
  25241. * The set of event that will be linked to this animation
  25242. */
  25243. private _events;
  25244. /**
  25245. * Stores an array of target property paths
  25246. */
  25247. targetPropertyPath: string[];
  25248. /**
  25249. * Stores the blending speed of the animation
  25250. */
  25251. blendingSpeed: number;
  25252. /**
  25253. * Stores the animation ranges for the animation
  25254. */
  25255. private _ranges;
  25256. /**
  25257. * @hidden Internal use
  25258. */
  25259. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25260. /**
  25261. * Sets up an animation
  25262. * @param property The property to animate
  25263. * @param animationType The animation type to apply
  25264. * @param framePerSecond The frames per second of the animation
  25265. * @param easingFunction The easing function used in the animation
  25266. * @returns The created animation
  25267. */
  25268. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25269. /**
  25270. * Create and start an animation on a node
  25271. * @param name defines the name of the global animation that will be run on all nodes
  25272. * @param node defines the root node where the animation will take place
  25273. * @param targetProperty defines property to animate
  25274. * @param framePerSecond defines the number of frame per second yo use
  25275. * @param totalFrame defines the number of frames in total
  25276. * @param from defines the initial value
  25277. * @param to defines the final value
  25278. * @param loopMode defines which loop mode you want to use (off by default)
  25279. * @param easingFunction defines the easing function to use (linear by default)
  25280. * @param onAnimationEnd defines the callback to call when animation end
  25281. * @returns the animatable created for this animation
  25282. */
  25283. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25284. /**
  25285. * Create and start an animation on a node and its descendants
  25286. * @param name defines the name of the global animation that will be run on all nodes
  25287. * @param node defines the root node where the animation will take place
  25288. * @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
  25289. * @param targetProperty defines property to animate
  25290. * @param framePerSecond defines the number of frame per second to use
  25291. * @param totalFrame defines the number of frames in total
  25292. * @param from defines the initial value
  25293. * @param to defines the final value
  25294. * @param loopMode defines which loop mode you want to use (off by default)
  25295. * @param easingFunction defines the easing function to use (linear by default)
  25296. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25297. * @returns the list of animatables created for all nodes
  25298. * @example https://www.babylonjs-playground.com/#MH0VLI
  25299. */
  25300. 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[]>;
  25301. /**
  25302. * Creates a new animation, merges it with the existing animations and starts it
  25303. * @param name Name of the animation
  25304. * @param node Node which contains the scene that begins the animations
  25305. * @param targetProperty Specifies which property to animate
  25306. * @param framePerSecond The frames per second of the animation
  25307. * @param totalFrame The total number of frames
  25308. * @param from The frame at the beginning of the animation
  25309. * @param to The frame at the end of the animation
  25310. * @param loopMode Specifies the loop mode of the animation
  25311. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25312. * @param onAnimationEnd Callback to run once the animation is complete
  25313. * @returns Nullable animation
  25314. */
  25315. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25316. /**
  25317. * Transition property of an host to the target Value
  25318. * @param property The property to transition
  25319. * @param targetValue The target Value of the property
  25320. * @param host The object where the property to animate belongs
  25321. * @param scene Scene used to run the animation
  25322. * @param frameRate Framerate (in frame/s) to use
  25323. * @param transition The transition type we want to use
  25324. * @param duration The duration of the animation, in milliseconds
  25325. * @param onAnimationEnd Callback trigger at the end of the animation
  25326. * @returns Nullable animation
  25327. */
  25328. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25329. /**
  25330. * Return the array of runtime animations currently using this animation
  25331. */
  25332. readonly runtimeAnimations: RuntimeAnimation[];
  25333. /**
  25334. * Specifies if any of the runtime animations are currently running
  25335. */
  25336. readonly hasRunningRuntimeAnimations: boolean;
  25337. /**
  25338. * Initializes the animation
  25339. * @param name Name of the animation
  25340. * @param targetProperty Property to animate
  25341. * @param framePerSecond The frames per second of the animation
  25342. * @param dataType The data type of the animation
  25343. * @param loopMode The loop mode of the animation
  25344. * @param enableBlending Specifies if blending should be enabled
  25345. */
  25346. constructor(
  25347. /**Name of the animation */
  25348. name: string,
  25349. /**Property to animate */
  25350. targetProperty: string,
  25351. /**The frames per second of the animation */
  25352. framePerSecond: number,
  25353. /**The data type of the animation */
  25354. dataType: number,
  25355. /**The loop mode of the animation */
  25356. loopMode?: number | undefined,
  25357. /**Specifies if blending should be enabled */
  25358. enableBlending?: boolean | undefined);
  25359. /**
  25360. * Converts the animation to a string
  25361. * @param fullDetails support for multiple levels of logging within scene loading
  25362. * @returns String form of the animation
  25363. */
  25364. toString(fullDetails?: boolean): string;
  25365. /**
  25366. * Add an event to this animation
  25367. * @param event Event to add
  25368. */
  25369. addEvent(event: AnimationEvent): void;
  25370. /**
  25371. * Remove all events found at the given frame
  25372. * @param frame The frame to remove events from
  25373. */
  25374. removeEvents(frame: number): void;
  25375. /**
  25376. * Retrieves all the events from the animation
  25377. * @returns Events from the animation
  25378. */
  25379. getEvents(): AnimationEvent[];
  25380. /**
  25381. * Creates an animation range
  25382. * @param name Name of the animation range
  25383. * @param from Starting frame of the animation range
  25384. * @param to Ending frame of the animation
  25385. */
  25386. createRange(name: string, from: number, to: number): void;
  25387. /**
  25388. * Deletes an animation range by name
  25389. * @param name Name of the animation range to delete
  25390. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25391. */
  25392. deleteRange(name: string, deleteFrames?: boolean): void;
  25393. /**
  25394. * Gets the animation range by name, or null if not defined
  25395. * @param name Name of the animation range
  25396. * @returns Nullable animation range
  25397. */
  25398. getRange(name: string): Nullable<AnimationRange>;
  25399. /**
  25400. * Gets the key frames from the animation
  25401. * @returns The key frames of the animation
  25402. */
  25403. getKeys(): Array<IAnimationKey>;
  25404. /**
  25405. * Gets the highest frame rate of the animation
  25406. * @returns Highest frame rate of the animation
  25407. */
  25408. getHighestFrame(): number;
  25409. /**
  25410. * Gets the easing function of the animation
  25411. * @returns Easing function of the animation
  25412. */
  25413. getEasingFunction(): IEasingFunction;
  25414. /**
  25415. * Sets the easing function of the animation
  25416. * @param easingFunction A custom mathematical formula for animation
  25417. */
  25418. setEasingFunction(easingFunction: EasingFunction): void;
  25419. /**
  25420. * Interpolates a scalar linearly
  25421. * @param startValue Start value of the animation curve
  25422. * @param endValue End value of the animation curve
  25423. * @param gradient Scalar amount to interpolate
  25424. * @returns Interpolated scalar value
  25425. */
  25426. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25427. /**
  25428. * Interpolates a scalar cubically
  25429. * @param startValue Start value of the animation curve
  25430. * @param outTangent End tangent of the animation
  25431. * @param endValue End value of the animation curve
  25432. * @param inTangent Start tangent of the animation curve
  25433. * @param gradient Scalar amount to interpolate
  25434. * @returns Interpolated scalar value
  25435. */
  25436. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25437. /**
  25438. * Interpolates a quaternion using a spherical linear interpolation
  25439. * @param startValue Start value of the animation curve
  25440. * @param endValue End value of the animation curve
  25441. * @param gradient Scalar amount to interpolate
  25442. * @returns Interpolated quaternion value
  25443. */
  25444. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25445. /**
  25446. * Interpolates a quaternion cubically
  25447. * @param startValue Start value of the animation curve
  25448. * @param outTangent End tangent of the animation curve
  25449. * @param endValue End value of the animation curve
  25450. * @param inTangent Start tangent of the animation curve
  25451. * @param gradient Scalar amount to interpolate
  25452. * @returns Interpolated quaternion value
  25453. */
  25454. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25455. /**
  25456. * Interpolates a Vector3 linearl
  25457. * @param startValue Start value of the animation curve
  25458. * @param endValue End value of the animation curve
  25459. * @param gradient Scalar amount to interpolate
  25460. * @returns Interpolated scalar value
  25461. */
  25462. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25463. /**
  25464. * Interpolates a Vector3 cubically
  25465. * @param startValue Start value of the animation curve
  25466. * @param outTangent End tangent of the animation
  25467. * @param endValue End value of the animation curve
  25468. * @param inTangent Start tangent of the animation curve
  25469. * @param gradient Scalar amount to interpolate
  25470. * @returns InterpolatedVector3 value
  25471. */
  25472. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25473. /**
  25474. * Interpolates a Vector2 linearly
  25475. * @param startValue Start value of the animation curve
  25476. * @param endValue End value of the animation curve
  25477. * @param gradient Scalar amount to interpolate
  25478. * @returns Interpolated Vector2 value
  25479. */
  25480. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25481. /**
  25482. * Interpolates a Vector2 cubically
  25483. * @param startValue Start value of the animation curve
  25484. * @param outTangent End tangent of the animation
  25485. * @param endValue End value of the animation curve
  25486. * @param inTangent Start tangent of the animation curve
  25487. * @param gradient Scalar amount to interpolate
  25488. * @returns Interpolated Vector2 value
  25489. */
  25490. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25491. /**
  25492. * Interpolates a size linearly
  25493. * @param startValue Start value of the animation curve
  25494. * @param endValue End value of the animation curve
  25495. * @param gradient Scalar amount to interpolate
  25496. * @returns Interpolated Size value
  25497. */
  25498. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25499. /**
  25500. * Interpolates a Color3 linearly
  25501. * @param startValue Start value of the animation curve
  25502. * @param endValue End value of the animation curve
  25503. * @param gradient Scalar amount to interpolate
  25504. * @returns Interpolated Color3 value
  25505. */
  25506. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25507. /**
  25508. * @hidden Internal use only
  25509. */
  25510. _getKeyValue(value: any): any;
  25511. /**
  25512. * @hidden Internal use only
  25513. */
  25514. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25515. /**
  25516. * Defines the function to use to interpolate matrices
  25517. * @param startValue defines the start matrix
  25518. * @param endValue defines the end matrix
  25519. * @param gradient defines the gradient between both matrices
  25520. * @param result defines an optional target matrix where to store the interpolation
  25521. * @returns the interpolated matrix
  25522. */
  25523. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25524. /**
  25525. * Makes a copy of the animation
  25526. * @returns Cloned animation
  25527. */
  25528. clone(): Animation;
  25529. /**
  25530. * Sets the key frames of the animation
  25531. * @param values The animation key frames to set
  25532. */
  25533. setKeys(values: Array<IAnimationKey>): void;
  25534. /**
  25535. * Serializes the animation to an object
  25536. * @returns Serialized object
  25537. */
  25538. serialize(): any;
  25539. /**
  25540. * Float animation type
  25541. */
  25542. private static _ANIMATIONTYPE_FLOAT;
  25543. /**
  25544. * Vector3 animation type
  25545. */
  25546. private static _ANIMATIONTYPE_VECTOR3;
  25547. /**
  25548. * Quaternion animation type
  25549. */
  25550. private static _ANIMATIONTYPE_QUATERNION;
  25551. /**
  25552. * Matrix animation type
  25553. */
  25554. private static _ANIMATIONTYPE_MATRIX;
  25555. /**
  25556. * Color3 animation type
  25557. */
  25558. private static _ANIMATIONTYPE_COLOR3;
  25559. /**
  25560. * Vector2 animation type
  25561. */
  25562. private static _ANIMATIONTYPE_VECTOR2;
  25563. /**
  25564. * Size animation type
  25565. */
  25566. private static _ANIMATIONTYPE_SIZE;
  25567. /**
  25568. * Relative Loop Mode
  25569. */
  25570. private static _ANIMATIONLOOPMODE_RELATIVE;
  25571. /**
  25572. * Cycle Loop Mode
  25573. */
  25574. private static _ANIMATIONLOOPMODE_CYCLE;
  25575. /**
  25576. * Constant Loop Mode
  25577. */
  25578. private static _ANIMATIONLOOPMODE_CONSTANT;
  25579. /**
  25580. * Get the float animation type
  25581. */
  25582. static readonly ANIMATIONTYPE_FLOAT: number;
  25583. /**
  25584. * Get the Vector3 animation type
  25585. */
  25586. static readonly ANIMATIONTYPE_VECTOR3: number;
  25587. /**
  25588. * Get the Vector2 animation type
  25589. */
  25590. static readonly ANIMATIONTYPE_VECTOR2: number;
  25591. /**
  25592. * Get the Size animation type
  25593. */
  25594. static readonly ANIMATIONTYPE_SIZE: number;
  25595. /**
  25596. * Get the Quaternion animation type
  25597. */
  25598. static readonly ANIMATIONTYPE_QUATERNION: number;
  25599. /**
  25600. * Get the Matrix animation type
  25601. */
  25602. static readonly ANIMATIONTYPE_MATRIX: number;
  25603. /**
  25604. * Get the Color3 animation type
  25605. */
  25606. static readonly ANIMATIONTYPE_COLOR3: number;
  25607. /**
  25608. * Get the Relative Loop Mode
  25609. */
  25610. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25611. /**
  25612. * Get the Cycle Loop Mode
  25613. */
  25614. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25615. /**
  25616. * Get the Constant Loop Mode
  25617. */
  25618. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25619. /** @hidden */
  25620. static _UniversalLerp(left: any, right: any, amount: number): any;
  25621. /**
  25622. * Parses an animation object and creates an animation
  25623. * @param parsedAnimation Parsed animation object
  25624. * @returns Animation object
  25625. */
  25626. static Parse(parsedAnimation: any): Animation;
  25627. /**
  25628. * Appends the serialized animations from the source animations
  25629. * @param source Source containing the animations
  25630. * @param destination Target to store the animations
  25631. */
  25632. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25633. }
  25634. }
  25635. declare module "babylonjs/Materials/Textures/baseTexture" {
  25636. import { Observable } from "babylonjs/Misc/observable";
  25637. import { IAnimatable } from "babylonjs/Misc/tools";
  25638. import { Nullable } from "babylonjs/types";
  25639. import { Scene } from "babylonjs/scene";
  25640. import { Matrix, ISize } from "babylonjs/Maths/math";
  25641. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25642. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25643. /**
  25644. * Base class of all the textures in babylon.
  25645. * It groups all the common properties the materials, post process, lights... might need
  25646. * in order to make a correct use of the texture.
  25647. */
  25648. export class BaseTexture implements IAnimatable {
  25649. /**
  25650. * Default anisotropic filtering level for the application.
  25651. * It is set to 4 as a good tradeoff between perf and quality.
  25652. */
  25653. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25654. /**
  25655. * Gets or sets the unique id of the texture
  25656. */
  25657. uniqueId: number;
  25658. /**
  25659. * Define the name of the texture.
  25660. */
  25661. name: string;
  25662. /**
  25663. * Gets or sets an object used to store user defined information.
  25664. */
  25665. metadata: any;
  25666. /**
  25667. * For internal use only. Please do not use.
  25668. */
  25669. reservedDataStore: any;
  25670. private _hasAlpha;
  25671. /**
  25672. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25673. */
  25674. hasAlpha: boolean;
  25675. /**
  25676. * Defines if the alpha value should be determined via the rgb values.
  25677. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25678. */
  25679. getAlphaFromRGB: boolean;
  25680. /**
  25681. * Intensity or strength of the texture.
  25682. * It is commonly used by materials to fine tune the intensity of the texture
  25683. */
  25684. level: number;
  25685. /**
  25686. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25687. * This is part of the texture as textures usually maps to one uv set.
  25688. */
  25689. coordinatesIndex: number;
  25690. private _coordinatesMode;
  25691. /**
  25692. * How a texture is mapped.
  25693. *
  25694. * | Value | Type | Description |
  25695. * | ----- | ----------------------------------- | ----------- |
  25696. * | 0 | EXPLICIT_MODE | |
  25697. * | 1 | SPHERICAL_MODE | |
  25698. * | 2 | PLANAR_MODE | |
  25699. * | 3 | CUBIC_MODE | |
  25700. * | 4 | PROJECTION_MODE | |
  25701. * | 5 | SKYBOX_MODE | |
  25702. * | 6 | INVCUBIC_MODE | |
  25703. * | 7 | EQUIRECTANGULAR_MODE | |
  25704. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25705. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25706. */
  25707. coordinatesMode: number;
  25708. /**
  25709. * | Value | Type | Description |
  25710. * | ----- | ------------------ | ----------- |
  25711. * | 0 | CLAMP_ADDRESSMODE | |
  25712. * | 1 | WRAP_ADDRESSMODE | |
  25713. * | 2 | MIRROR_ADDRESSMODE | |
  25714. */
  25715. wrapU: number;
  25716. /**
  25717. * | Value | Type | Description |
  25718. * | ----- | ------------------ | ----------- |
  25719. * | 0 | CLAMP_ADDRESSMODE | |
  25720. * | 1 | WRAP_ADDRESSMODE | |
  25721. * | 2 | MIRROR_ADDRESSMODE | |
  25722. */
  25723. wrapV: number;
  25724. /**
  25725. * | Value | Type | Description |
  25726. * | ----- | ------------------ | ----------- |
  25727. * | 0 | CLAMP_ADDRESSMODE | |
  25728. * | 1 | WRAP_ADDRESSMODE | |
  25729. * | 2 | MIRROR_ADDRESSMODE | |
  25730. */
  25731. wrapR: number;
  25732. /**
  25733. * With compliant hardware and browser (supporting anisotropic filtering)
  25734. * this defines the level of anisotropic filtering in the texture.
  25735. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25736. */
  25737. anisotropicFilteringLevel: number;
  25738. /**
  25739. * Define if the texture is a cube texture or if false a 2d texture.
  25740. */
  25741. isCube: boolean;
  25742. /**
  25743. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25744. */
  25745. is3D: boolean;
  25746. /**
  25747. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25748. * HDR texture are usually stored in linear space.
  25749. * This only impacts the PBR and Background materials
  25750. */
  25751. gammaSpace: boolean;
  25752. /**
  25753. * Gets whether or not the texture contains RGBD data.
  25754. */
  25755. readonly isRGBD: boolean;
  25756. /**
  25757. * Is Z inverted in the texture (useful in a cube texture).
  25758. */
  25759. invertZ: boolean;
  25760. /**
  25761. * Are mip maps generated for this texture or not.
  25762. */
  25763. readonly noMipmap: boolean;
  25764. /**
  25765. * @hidden
  25766. */
  25767. lodLevelInAlpha: boolean;
  25768. /**
  25769. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25770. */
  25771. lodGenerationOffset: number;
  25772. /**
  25773. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25774. */
  25775. lodGenerationScale: number;
  25776. /**
  25777. * Define if the texture is a render target.
  25778. */
  25779. isRenderTarget: boolean;
  25780. /**
  25781. * Define the unique id of the texture in the scene.
  25782. */
  25783. readonly uid: string;
  25784. /**
  25785. * Return a string representation of the texture.
  25786. * @returns the texture as a string
  25787. */
  25788. toString(): string;
  25789. /**
  25790. * Get the class name of the texture.
  25791. * @returns "BaseTexture"
  25792. */
  25793. getClassName(): string;
  25794. /**
  25795. * Define the list of animation attached to the texture.
  25796. */
  25797. animations: import("babylonjs/Animations/animation").Animation[];
  25798. /**
  25799. * An event triggered when the texture is disposed.
  25800. */
  25801. onDisposeObservable: Observable<BaseTexture>;
  25802. private _onDisposeObserver;
  25803. /**
  25804. * Callback triggered when the texture has been disposed.
  25805. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25806. */
  25807. onDispose: () => void;
  25808. /**
  25809. * Define the current state of the loading sequence when in delayed load mode.
  25810. */
  25811. delayLoadState: number;
  25812. private _scene;
  25813. /** @hidden */
  25814. _texture: Nullable<InternalTexture>;
  25815. private _uid;
  25816. /**
  25817. * Define if the texture is preventinga material to render or not.
  25818. * If not and the texture is not ready, the engine will use a default black texture instead.
  25819. */
  25820. readonly isBlocking: boolean;
  25821. /**
  25822. * Instantiates a new BaseTexture.
  25823. * Base class of all the textures in babylon.
  25824. * It groups all the common properties the materials, post process, lights... might need
  25825. * in order to make a correct use of the texture.
  25826. * @param scene Define the scene the texture blongs to
  25827. */
  25828. constructor(scene: Nullable<Scene>);
  25829. /**
  25830. * Get the scene the texture belongs to.
  25831. * @returns the scene or null if undefined
  25832. */
  25833. getScene(): Nullable<Scene>;
  25834. /**
  25835. * Get the texture transform matrix used to offset tile the texture for istance.
  25836. * @returns the transformation matrix
  25837. */
  25838. getTextureMatrix(): Matrix;
  25839. /**
  25840. * Get the texture reflection matrix used to rotate/transform the reflection.
  25841. * @returns the reflection matrix
  25842. */
  25843. getReflectionTextureMatrix(): Matrix;
  25844. /**
  25845. * Get the underlying lower level texture from Babylon.
  25846. * @returns the insternal texture
  25847. */
  25848. getInternalTexture(): Nullable<InternalTexture>;
  25849. /**
  25850. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25851. * @returns true if ready or not blocking
  25852. */
  25853. isReadyOrNotBlocking(): boolean;
  25854. /**
  25855. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25856. * @returns true if fully ready
  25857. */
  25858. isReady(): boolean;
  25859. private _cachedSize;
  25860. /**
  25861. * Get the size of the texture.
  25862. * @returns the texture size.
  25863. */
  25864. getSize(): ISize;
  25865. /**
  25866. * Get the base size of the texture.
  25867. * It can be different from the size if the texture has been resized for POT for instance
  25868. * @returns the base size
  25869. */
  25870. getBaseSize(): ISize;
  25871. /**
  25872. * Update the sampling mode of the texture.
  25873. * Default is Trilinear mode.
  25874. *
  25875. * | Value | Type | Description |
  25876. * | ----- | ------------------ | ----------- |
  25877. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25878. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25879. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25880. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25881. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25882. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25883. * | 7 | NEAREST_LINEAR | |
  25884. * | 8 | NEAREST_NEAREST | |
  25885. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25886. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25887. * | 11 | LINEAR_LINEAR | |
  25888. * | 12 | LINEAR_NEAREST | |
  25889. *
  25890. * > _mag_: magnification filter (close to the viewer)
  25891. * > _min_: minification filter (far from the viewer)
  25892. * > _mip_: filter used between mip map levels
  25893. *@param samplingMode Define the new sampling mode of the texture
  25894. */
  25895. updateSamplingMode(samplingMode: number): void;
  25896. /**
  25897. * Scales the texture if is `canRescale()`
  25898. * @param ratio the resize factor we want to use to rescale
  25899. */
  25900. scale(ratio: number): void;
  25901. /**
  25902. * Get if the texture can rescale.
  25903. */
  25904. readonly canRescale: boolean;
  25905. /** @hidden */
  25906. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25907. /** @hidden */
  25908. _rebuild(): void;
  25909. /**
  25910. * Triggers the load sequence in delayed load mode.
  25911. */
  25912. delayLoad(): void;
  25913. /**
  25914. * Clones the texture.
  25915. * @returns the cloned texture
  25916. */
  25917. clone(): Nullable<BaseTexture>;
  25918. /**
  25919. * Get the texture underlying type (INT, FLOAT...)
  25920. */
  25921. readonly textureType: number;
  25922. /**
  25923. * Get the texture underlying format (RGB, RGBA...)
  25924. */
  25925. readonly textureFormat: number;
  25926. /**
  25927. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25928. * This will returns an RGBA array buffer containing either in values (0-255) or
  25929. * float values (0-1) depending of the underlying buffer type.
  25930. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25931. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25932. * @param buffer defines a user defined buffer to fill with data (can be null)
  25933. * @returns The Array buffer containing the pixels data.
  25934. */
  25935. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25936. /**
  25937. * Release and destroy the underlying lower level texture aka internalTexture.
  25938. */
  25939. releaseInternalTexture(): void;
  25940. /**
  25941. * Get the polynomial representation of the texture data.
  25942. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25943. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25944. */
  25945. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25946. /** @hidden */
  25947. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25948. /** @hidden */
  25949. readonly _lodTextureMid: Nullable<BaseTexture>;
  25950. /** @hidden */
  25951. readonly _lodTextureLow: Nullable<BaseTexture>;
  25952. /**
  25953. * Dispose the texture and release its associated resources.
  25954. */
  25955. dispose(): void;
  25956. /**
  25957. * Serialize the texture into a JSON representation that can be parsed later on.
  25958. * @returns the JSON representation of the texture
  25959. */
  25960. serialize(): any;
  25961. /**
  25962. * Helper function to be called back once a list of texture contains only ready textures.
  25963. * @param textures Define the list of textures to wait for
  25964. * @param callback Define the callback triggered once the entire list will be ready
  25965. */
  25966. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25967. }
  25968. }
  25969. declare module "babylonjs/Materials/uniformBuffer" {
  25970. import { Nullable, FloatArray } from "babylonjs/types";
  25971. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25972. import { Engine } from "babylonjs/Engines/engine";
  25973. import { Effect } from "babylonjs/Materials/effect";
  25974. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25975. /**
  25976. * Uniform buffer objects.
  25977. *
  25978. * Handles blocks of uniform on the GPU.
  25979. *
  25980. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25981. *
  25982. * For more information, please refer to :
  25983. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25984. */
  25985. export class UniformBuffer {
  25986. private _engine;
  25987. private _buffer;
  25988. private _data;
  25989. private _bufferData;
  25990. private _dynamic?;
  25991. private _uniformLocations;
  25992. private _uniformSizes;
  25993. private _uniformLocationPointer;
  25994. private _needSync;
  25995. private _noUBO;
  25996. private _currentEffect;
  25997. private static _MAX_UNIFORM_SIZE;
  25998. private static _tempBuffer;
  25999. /**
  26000. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26001. * This is dynamic to allow compat with webgl 1 and 2.
  26002. * You will need to pass the name of the uniform as well as the value.
  26003. */
  26004. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26005. /**
  26006. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26007. * This is dynamic to allow compat with webgl 1 and 2.
  26008. * You will need to pass the name of the uniform as well as the value.
  26009. */
  26010. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26011. /**
  26012. * Lambda to Update a single float in a uniform buffer.
  26013. * This is dynamic to allow compat with webgl 1 and 2.
  26014. * You will need to pass the name of the uniform as well as the value.
  26015. */
  26016. updateFloat: (name: string, x: number) => void;
  26017. /**
  26018. * Lambda to Update a vec2 of float in a uniform buffer.
  26019. * This is dynamic to allow compat with webgl 1 and 2.
  26020. * You will need to pass the name of the uniform as well as the value.
  26021. */
  26022. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26023. /**
  26024. * Lambda to Update a vec3 of float in a uniform buffer.
  26025. * This is dynamic to allow compat with webgl 1 and 2.
  26026. * You will need to pass the name of the uniform as well as the value.
  26027. */
  26028. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26029. /**
  26030. * Lambda to Update a vec4 of float in a uniform buffer.
  26031. * This is dynamic to allow compat with webgl 1 and 2.
  26032. * You will need to pass the name of the uniform as well as the value.
  26033. */
  26034. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26035. /**
  26036. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26037. * This is dynamic to allow compat with webgl 1 and 2.
  26038. * You will need to pass the name of the uniform as well as the value.
  26039. */
  26040. updateMatrix: (name: string, mat: Matrix) => void;
  26041. /**
  26042. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26043. * This is dynamic to allow compat with webgl 1 and 2.
  26044. * You will need to pass the name of the uniform as well as the value.
  26045. */
  26046. updateVector3: (name: string, vector: Vector3) => void;
  26047. /**
  26048. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26049. * This is dynamic to allow compat with webgl 1 and 2.
  26050. * You will need to pass the name of the uniform as well as the value.
  26051. */
  26052. updateVector4: (name: string, vector: Vector4) => void;
  26053. /**
  26054. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26055. * This is dynamic to allow compat with webgl 1 and 2.
  26056. * You will need to pass the name of the uniform as well as the value.
  26057. */
  26058. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26059. /**
  26060. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26061. * This is dynamic to allow compat with webgl 1 and 2.
  26062. * You will need to pass the name of the uniform as well as the value.
  26063. */
  26064. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26065. /**
  26066. * Instantiates a new Uniform buffer objects.
  26067. *
  26068. * Handles blocks of uniform on the GPU.
  26069. *
  26070. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26071. *
  26072. * For more information, please refer to :
  26073. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26074. * @param engine Define the engine the buffer is associated with
  26075. * @param data Define the data contained in the buffer
  26076. * @param dynamic Define if the buffer is updatable
  26077. */
  26078. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26079. /**
  26080. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26081. * or just falling back on setUniformXXX calls.
  26082. */
  26083. readonly useUbo: boolean;
  26084. /**
  26085. * Indicates if the WebGL underlying uniform buffer is in sync
  26086. * with the javascript cache data.
  26087. */
  26088. readonly isSync: boolean;
  26089. /**
  26090. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26091. * Also, a dynamic UniformBuffer will disable cache verification and always
  26092. * update the underlying WebGL uniform buffer to the GPU.
  26093. * @returns if Dynamic, otherwise false
  26094. */
  26095. isDynamic(): boolean;
  26096. /**
  26097. * The data cache on JS side.
  26098. * @returns the underlying data as a float array
  26099. */
  26100. getData(): Float32Array;
  26101. /**
  26102. * The underlying WebGL Uniform buffer.
  26103. * @returns the webgl buffer
  26104. */
  26105. getBuffer(): Nullable<WebGLBuffer>;
  26106. /**
  26107. * std140 layout specifies how to align data within an UBO structure.
  26108. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26109. * for specs.
  26110. */
  26111. private _fillAlignment;
  26112. /**
  26113. * Adds an uniform in the buffer.
  26114. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26115. * for the layout to be correct !
  26116. * @param name Name of the uniform, as used in the uniform block in the shader.
  26117. * @param size Data size, or data directly.
  26118. */
  26119. addUniform(name: string, size: number | number[]): void;
  26120. /**
  26121. * Adds a Matrix 4x4 to the uniform buffer.
  26122. * @param name Name of the uniform, as used in the uniform block in the shader.
  26123. * @param mat A 4x4 matrix.
  26124. */
  26125. addMatrix(name: string, mat: Matrix): void;
  26126. /**
  26127. * Adds a vec2 to the uniform buffer.
  26128. * @param name Name of the uniform, as used in the uniform block in the shader.
  26129. * @param x Define the x component value of the vec2
  26130. * @param y Define the y component value of the vec2
  26131. */
  26132. addFloat2(name: string, x: number, y: number): void;
  26133. /**
  26134. * Adds a vec3 to the uniform buffer.
  26135. * @param name Name of the uniform, as used in the uniform block in the shader.
  26136. * @param x Define the x component value of the vec3
  26137. * @param y Define the y component value of the vec3
  26138. * @param z Define the z component value of the vec3
  26139. */
  26140. addFloat3(name: string, x: number, y: number, z: number): void;
  26141. /**
  26142. * Adds a vec3 to the uniform buffer.
  26143. * @param name Name of the uniform, as used in the uniform block in the shader.
  26144. * @param color Define the vec3 from a Color
  26145. */
  26146. addColor3(name: string, color: Color3): void;
  26147. /**
  26148. * Adds a vec4 to the uniform buffer.
  26149. * @param name Name of the uniform, as used in the uniform block in the shader.
  26150. * @param color Define the rgb components from a Color
  26151. * @param alpha Define the a component of the vec4
  26152. */
  26153. addColor4(name: string, color: Color3, alpha: number): void;
  26154. /**
  26155. * Adds a vec3 to the uniform buffer.
  26156. * @param name Name of the uniform, as used in the uniform block in the shader.
  26157. * @param vector Define the vec3 components from a Vector
  26158. */
  26159. addVector3(name: string, vector: Vector3): void;
  26160. /**
  26161. * Adds a Matrix 3x3 to the uniform buffer.
  26162. * @param name Name of the uniform, as used in the uniform block in the shader.
  26163. */
  26164. addMatrix3x3(name: string): void;
  26165. /**
  26166. * Adds a Matrix 2x2 to the uniform buffer.
  26167. * @param name Name of the uniform, as used in the uniform block in the shader.
  26168. */
  26169. addMatrix2x2(name: string): void;
  26170. /**
  26171. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26172. */
  26173. create(): void;
  26174. /** @hidden */
  26175. _rebuild(): void;
  26176. /**
  26177. * Updates the WebGL Uniform Buffer on the GPU.
  26178. * If the `dynamic` flag is set to true, no cache comparison is done.
  26179. * Otherwise, the buffer will be updated only if the cache differs.
  26180. */
  26181. update(): void;
  26182. /**
  26183. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26184. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26185. * @param data Define the flattened data
  26186. * @param size Define the size of the data.
  26187. */
  26188. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26189. private _updateMatrix3x3ForUniform;
  26190. private _updateMatrix3x3ForEffect;
  26191. private _updateMatrix2x2ForEffect;
  26192. private _updateMatrix2x2ForUniform;
  26193. private _updateFloatForEffect;
  26194. private _updateFloatForUniform;
  26195. private _updateFloat2ForEffect;
  26196. private _updateFloat2ForUniform;
  26197. private _updateFloat3ForEffect;
  26198. private _updateFloat3ForUniform;
  26199. private _updateFloat4ForEffect;
  26200. private _updateFloat4ForUniform;
  26201. private _updateMatrixForEffect;
  26202. private _updateMatrixForUniform;
  26203. private _updateVector3ForEffect;
  26204. private _updateVector3ForUniform;
  26205. private _updateVector4ForEffect;
  26206. private _updateVector4ForUniform;
  26207. private _updateColor3ForEffect;
  26208. private _updateColor3ForUniform;
  26209. private _updateColor4ForEffect;
  26210. private _updateColor4ForUniform;
  26211. /**
  26212. * Sets a sampler uniform on the effect.
  26213. * @param name Define the name of the sampler.
  26214. * @param texture Define the texture to set in the sampler
  26215. */
  26216. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26217. /**
  26218. * Directly updates the value of the uniform in the cache AND on the GPU.
  26219. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26220. * @param data Define the flattened data
  26221. */
  26222. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26223. /**
  26224. * Binds this uniform buffer to an effect.
  26225. * @param effect Define the effect to bind the buffer to
  26226. * @param name Name of the uniform block in the shader.
  26227. */
  26228. bindToEffect(effect: Effect, name: string): void;
  26229. /**
  26230. * Disposes the uniform buffer.
  26231. */
  26232. dispose(): void;
  26233. }
  26234. }
  26235. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26236. import { Nullable } from "babylonjs/types";
  26237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26238. /**
  26239. * This represents the required contract to create a new type of texture loader.
  26240. */
  26241. export interface IInternalTextureLoader {
  26242. /**
  26243. * Defines wether the loader supports cascade loading the different faces.
  26244. */
  26245. supportCascades: boolean;
  26246. /**
  26247. * This returns if the loader support the current file information.
  26248. * @param extension defines the file extension of the file being loaded
  26249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26250. * @param fallback defines the fallback internal texture if any
  26251. * @param isBase64 defines whether the texture is encoded as a base64
  26252. * @param isBuffer defines whether the texture data are stored as a buffer
  26253. * @returns true if the loader can load the specified file
  26254. */
  26255. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26256. /**
  26257. * Transform the url before loading if required.
  26258. * @param rootUrl the url of the texture
  26259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26260. * @returns the transformed texture
  26261. */
  26262. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26263. /**
  26264. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26265. * @param rootUrl the url of the texture
  26266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26267. * @returns the fallback texture
  26268. */
  26269. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26270. /**
  26271. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26272. * @param data contains the texture data
  26273. * @param texture defines the BabylonJS internal texture
  26274. * @param createPolynomials will be true if polynomials have been requested
  26275. * @param onLoad defines the callback to trigger once the texture is ready
  26276. * @param onError defines the callback to trigger in case of error
  26277. */
  26278. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26279. /**
  26280. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26281. * @param data contains the texture data
  26282. * @param texture defines the BabylonJS internal texture
  26283. * @param callback defines the method to call once ready to upload
  26284. */
  26285. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26286. }
  26287. }
  26288. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26289. import { Scene } from "babylonjs/scene";
  26290. import { Engine } from "babylonjs/Engines/engine";
  26291. import { Texture } from "babylonjs/Materials/Textures/texture";
  26292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26293. /**
  26294. * Creation options of the multi render target texture.
  26295. */
  26296. export interface IMultiRenderTargetOptions {
  26297. /**
  26298. * Define if the texture needs to create mip maps after render.
  26299. */
  26300. generateMipMaps?: boolean;
  26301. /**
  26302. * Define the types of all the draw buffers we want to create
  26303. */
  26304. types?: number[];
  26305. /**
  26306. * Define the sampling modes of all the draw buffers we want to create
  26307. */
  26308. samplingModes?: number[];
  26309. /**
  26310. * Define if a depth buffer is required
  26311. */
  26312. generateDepthBuffer?: boolean;
  26313. /**
  26314. * Define if a stencil buffer is required
  26315. */
  26316. generateStencilBuffer?: boolean;
  26317. /**
  26318. * Define if a depth texture is required instead of a depth buffer
  26319. */
  26320. generateDepthTexture?: boolean;
  26321. /**
  26322. * Define the number of desired draw buffers
  26323. */
  26324. textureCount?: number;
  26325. /**
  26326. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26327. */
  26328. doNotChangeAspectRatio?: boolean;
  26329. /**
  26330. * Define the default type of the buffers we are creating
  26331. */
  26332. defaultType?: number;
  26333. }
  26334. /**
  26335. * A multi render target, like a render target provides the ability to render to a texture.
  26336. * Unlike the render target, it can render to several draw buffers in one draw.
  26337. * This is specially interesting in deferred rendering or for any effects requiring more than
  26338. * just one color from a single pass.
  26339. */
  26340. export class MultiRenderTarget extends RenderTargetTexture {
  26341. private _internalTextures;
  26342. private _textures;
  26343. private _multiRenderTargetOptions;
  26344. /**
  26345. * Get if draw buffers are currently supported by the used hardware and browser.
  26346. */
  26347. readonly isSupported: boolean;
  26348. /**
  26349. * Get the list of textures generated by the multi render target.
  26350. */
  26351. readonly textures: Texture[];
  26352. /**
  26353. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26354. */
  26355. readonly depthTexture: Texture;
  26356. /**
  26357. * Set the wrapping mode on U of all the textures we are rendering to.
  26358. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26359. */
  26360. wrapU: number;
  26361. /**
  26362. * Set the wrapping mode on V of all the textures we are rendering to.
  26363. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26364. */
  26365. wrapV: number;
  26366. /**
  26367. * Instantiate a new multi render target texture.
  26368. * A multi render target, like a render target provides the ability to render to a texture.
  26369. * Unlike the render target, it can render to several draw buffers in one draw.
  26370. * This is specially interesting in deferred rendering or for any effects requiring more than
  26371. * just one color from a single pass.
  26372. * @param name Define the name of the texture
  26373. * @param size Define the size of the buffers to render to
  26374. * @param count Define the number of target we are rendering into
  26375. * @param scene Define the scene the texture belongs to
  26376. * @param options Define the options used to create the multi render target
  26377. */
  26378. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26379. /** @hidden */
  26380. _rebuild(): void;
  26381. private _createInternalTextures;
  26382. private _createTextures;
  26383. /**
  26384. * Define the number of samples used if MSAA is enabled.
  26385. */
  26386. samples: number;
  26387. /**
  26388. * Resize all the textures in the multi render target.
  26389. * Be carrefull as it will recreate all the data in the new texture.
  26390. * @param size Define the new size
  26391. */
  26392. resize(size: any): void;
  26393. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26394. /**
  26395. * Dispose the render targets and their associated resources
  26396. */
  26397. dispose(): void;
  26398. /**
  26399. * Release all the underlying texture used as draw buffers.
  26400. */
  26401. releaseInternalTextures(): void;
  26402. }
  26403. }
  26404. declare module "babylonjs/Audio/analyser" {
  26405. import { Scene } from "babylonjs/scene";
  26406. /**
  26407. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26409. */
  26410. export class Analyser {
  26411. /**
  26412. * Gets or sets the smoothing
  26413. * @ignorenaming
  26414. */
  26415. SMOOTHING: number;
  26416. /**
  26417. * Gets or sets the FFT table size
  26418. * @ignorenaming
  26419. */
  26420. FFT_SIZE: number;
  26421. /**
  26422. * Gets or sets the bar graph amplitude
  26423. * @ignorenaming
  26424. */
  26425. BARGRAPHAMPLITUDE: number;
  26426. /**
  26427. * Gets or sets the position of the debug canvas
  26428. * @ignorenaming
  26429. */
  26430. DEBUGCANVASPOS: {
  26431. x: number;
  26432. y: number;
  26433. };
  26434. /**
  26435. * Gets or sets the debug canvas size
  26436. * @ignorenaming
  26437. */
  26438. DEBUGCANVASSIZE: {
  26439. width: number;
  26440. height: number;
  26441. };
  26442. private _byteFreqs;
  26443. private _byteTime;
  26444. private _floatFreqs;
  26445. private _webAudioAnalyser;
  26446. private _debugCanvas;
  26447. private _debugCanvasContext;
  26448. private _scene;
  26449. private _registerFunc;
  26450. private _audioEngine;
  26451. /**
  26452. * Creates a new analyser
  26453. * @param scene defines hosting scene
  26454. */
  26455. constructor(scene: Scene);
  26456. /**
  26457. * Get the number of data values you will have to play with for the visualization
  26458. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26459. * @returns a number
  26460. */
  26461. getFrequencyBinCount(): number;
  26462. /**
  26463. * Gets the current frequency data as a byte array
  26464. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26465. * @returns a Uint8Array
  26466. */
  26467. getByteFrequencyData(): Uint8Array;
  26468. /**
  26469. * Gets the current waveform as a byte array
  26470. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26471. * @returns a Uint8Array
  26472. */
  26473. getByteTimeDomainData(): Uint8Array;
  26474. /**
  26475. * Gets the current frequency data as a float array
  26476. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26477. * @returns a Float32Array
  26478. */
  26479. getFloatFrequencyData(): Float32Array;
  26480. /**
  26481. * Renders the debug canvas
  26482. */
  26483. drawDebugCanvas(): void;
  26484. /**
  26485. * Stops rendering the debug canvas and removes it
  26486. */
  26487. stopDebugCanvas(): void;
  26488. /**
  26489. * Connects two audio nodes
  26490. * @param inputAudioNode defines first node to connect
  26491. * @param outputAudioNode defines second node to connect
  26492. */
  26493. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26494. /**
  26495. * Releases all associated resources
  26496. */
  26497. dispose(): void;
  26498. }
  26499. }
  26500. declare module "babylonjs/Audio/audioEngine" {
  26501. import { IDisposable } from "babylonjs/scene";
  26502. import { Analyser } from "babylonjs/Audio/analyser";
  26503. import { Nullable } from "babylonjs/types";
  26504. import { Observable } from "babylonjs/Misc/observable";
  26505. /**
  26506. * This represents an audio engine and it is responsible
  26507. * to play, synchronize and analyse sounds throughout the application.
  26508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26509. */
  26510. export interface IAudioEngine extends IDisposable {
  26511. /**
  26512. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26513. */
  26514. readonly canUseWebAudio: boolean;
  26515. /**
  26516. * Gets the current AudioContext if available.
  26517. */
  26518. readonly audioContext: Nullable<AudioContext>;
  26519. /**
  26520. * The master gain node defines the global audio volume of your audio engine.
  26521. */
  26522. readonly masterGain: GainNode;
  26523. /**
  26524. * Gets whether or not mp3 are supported by your browser.
  26525. */
  26526. readonly isMP3supported: boolean;
  26527. /**
  26528. * Gets whether or not ogg are supported by your browser.
  26529. */
  26530. readonly isOGGsupported: boolean;
  26531. /**
  26532. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26533. * @ignoreNaming
  26534. */
  26535. WarnedWebAudioUnsupported: boolean;
  26536. /**
  26537. * Defines if the audio engine relies on a custom unlocked button.
  26538. * In this case, the embedded button will not be displayed.
  26539. */
  26540. useCustomUnlockedButton: boolean;
  26541. /**
  26542. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26543. */
  26544. readonly unlocked: boolean;
  26545. /**
  26546. * Event raised when audio has been unlocked on the browser.
  26547. */
  26548. onAudioUnlockedObservable: Observable<AudioEngine>;
  26549. /**
  26550. * Event raised when audio has been locked on the browser.
  26551. */
  26552. onAudioLockedObservable: Observable<AudioEngine>;
  26553. /**
  26554. * Flags the audio engine in Locked state.
  26555. * This happens due to new browser policies preventing audio to autoplay.
  26556. */
  26557. lock(): void;
  26558. /**
  26559. * Unlocks the audio engine once a user action has been done on the dom.
  26560. * This is helpful to resume play once browser policies have been satisfied.
  26561. */
  26562. unlock(): void;
  26563. }
  26564. /**
  26565. * This represents the default audio engine used in babylon.
  26566. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26568. */
  26569. export class AudioEngine implements IAudioEngine {
  26570. private _audioContext;
  26571. private _audioContextInitialized;
  26572. private _muteButton;
  26573. private _hostElement;
  26574. /**
  26575. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26576. */
  26577. canUseWebAudio: boolean;
  26578. /**
  26579. * The master gain node defines the global audio volume of your audio engine.
  26580. */
  26581. masterGain: GainNode;
  26582. /**
  26583. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26584. * @ignoreNaming
  26585. */
  26586. WarnedWebAudioUnsupported: boolean;
  26587. /**
  26588. * Gets whether or not mp3 are supported by your browser.
  26589. */
  26590. isMP3supported: boolean;
  26591. /**
  26592. * Gets whether or not ogg are supported by your browser.
  26593. */
  26594. isOGGsupported: boolean;
  26595. /**
  26596. * Gets whether audio has been unlocked on the device.
  26597. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26598. * a user interaction has happened.
  26599. */
  26600. unlocked: boolean;
  26601. /**
  26602. * Defines if the audio engine relies on a custom unlocked button.
  26603. * In this case, the embedded button will not be displayed.
  26604. */
  26605. useCustomUnlockedButton: boolean;
  26606. /**
  26607. * Event raised when audio has been unlocked on the browser.
  26608. */
  26609. onAudioUnlockedObservable: Observable<AudioEngine>;
  26610. /**
  26611. * Event raised when audio has been locked on the browser.
  26612. */
  26613. onAudioLockedObservable: Observable<AudioEngine>;
  26614. /**
  26615. * Gets the current AudioContext if available.
  26616. */
  26617. readonly audioContext: Nullable<AudioContext>;
  26618. private _connectedAnalyser;
  26619. /**
  26620. * Instantiates a new audio engine.
  26621. *
  26622. * There should be only one per page as some browsers restrict the number
  26623. * of audio contexts you can create.
  26624. * @param hostElement defines the host element where to display the mute icon if necessary
  26625. */
  26626. constructor(hostElement?: Nullable<HTMLElement>);
  26627. /**
  26628. * Flags the audio engine in Locked state.
  26629. * This happens due to new browser policies preventing audio to autoplay.
  26630. */
  26631. lock(): void;
  26632. /**
  26633. * Unlocks the audio engine once a user action has been done on the dom.
  26634. * This is helpful to resume play once browser policies have been satisfied.
  26635. */
  26636. unlock(): void;
  26637. private _resumeAudioContext;
  26638. private _initializeAudioContext;
  26639. private _tryToRun;
  26640. private _triggerRunningState;
  26641. private _triggerSuspendedState;
  26642. private _displayMuteButton;
  26643. private _moveButtonToTopLeft;
  26644. private _onResize;
  26645. private _hideMuteButton;
  26646. /**
  26647. * Destroy and release the resources associated with the audio ccontext.
  26648. */
  26649. dispose(): void;
  26650. /**
  26651. * Gets the global volume sets on the master gain.
  26652. * @returns the global volume if set or -1 otherwise
  26653. */
  26654. getGlobalVolume(): number;
  26655. /**
  26656. * Sets the global volume of your experience (sets on the master gain).
  26657. * @param newVolume Defines the new global volume of the application
  26658. */
  26659. setGlobalVolume(newVolume: number): void;
  26660. /**
  26661. * Connect the audio engine to an audio analyser allowing some amazing
  26662. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26664. * @param analyser The analyser to connect to the engine
  26665. */
  26666. connectToAnalyser(analyser: Analyser): void;
  26667. }
  26668. }
  26669. declare module "babylonjs/Loading/loadingScreen" {
  26670. /**
  26671. * Interface used to present a loading screen while loading a scene
  26672. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26673. */
  26674. export interface ILoadingScreen {
  26675. /**
  26676. * Function called to display the loading screen
  26677. */
  26678. displayLoadingUI: () => void;
  26679. /**
  26680. * Function called to hide the loading screen
  26681. */
  26682. hideLoadingUI: () => void;
  26683. /**
  26684. * Gets or sets the color to use for the background
  26685. */
  26686. loadingUIBackgroundColor: string;
  26687. /**
  26688. * Gets or sets the text to display while loading
  26689. */
  26690. loadingUIText: string;
  26691. }
  26692. /**
  26693. * Class used for the default loading screen
  26694. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26695. */
  26696. export class DefaultLoadingScreen implements ILoadingScreen {
  26697. private _renderingCanvas;
  26698. private _loadingText;
  26699. private _loadingDivBackgroundColor;
  26700. private _loadingDiv;
  26701. private _loadingTextDiv;
  26702. /**
  26703. * Creates a new default loading screen
  26704. * @param _renderingCanvas defines the canvas used to render the scene
  26705. * @param _loadingText defines the default text to display
  26706. * @param _loadingDivBackgroundColor defines the default background color
  26707. */
  26708. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26709. /**
  26710. * Function called to display the loading screen
  26711. */
  26712. displayLoadingUI(): void;
  26713. /**
  26714. * Function called to hide the loading screen
  26715. */
  26716. hideLoadingUI(): void;
  26717. /**
  26718. * Gets or sets the text to display while loading
  26719. */
  26720. loadingUIText: string;
  26721. /**
  26722. * Gets or sets the color to use for the background
  26723. */
  26724. loadingUIBackgroundColor: string;
  26725. private _resizeLoadingUI;
  26726. }
  26727. }
  26728. declare module "babylonjs/Materials/Textures/videoTexture" {
  26729. import { Observable } from "babylonjs/Misc/observable";
  26730. import { Nullable } from "babylonjs/types";
  26731. import { Scene } from "babylonjs/scene";
  26732. import { Texture } from "babylonjs/Materials/Textures/texture";
  26733. /**
  26734. * Settings for finer control over video usage
  26735. */
  26736. export interface VideoTextureSettings {
  26737. /**
  26738. * Applies `autoplay` to video, if specified
  26739. */
  26740. autoPlay?: boolean;
  26741. /**
  26742. * Applies `loop` to video, if specified
  26743. */
  26744. loop?: boolean;
  26745. /**
  26746. * Automatically updates internal texture from video at every frame in the render loop
  26747. */
  26748. autoUpdateTexture: boolean;
  26749. /**
  26750. * Image src displayed during the video loading or until the user interacts with the video.
  26751. */
  26752. poster?: string;
  26753. }
  26754. /**
  26755. * If you want to display a video in your scene, this is the special texture for that.
  26756. * This special texture works similar to other textures, with the exception of a few parameters.
  26757. * @see https://doc.babylonjs.com/how_to/video_texture
  26758. */
  26759. export class VideoTexture extends Texture {
  26760. /**
  26761. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26762. */
  26763. readonly autoUpdateTexture: boolean;
  26764. /**
  26765. * The video instance used by the texture internally
  26766. */
  26767. readonly video: HTMLVideoElement;
  26768. private _onUserActionRequestedObservable;
  26769. /**
  26770. * Event triggerd when a dom action is required by the user to play the video.
  26771. * This happens due to recent changes in browser policies preventing video to auto start.
  26772. */
  26773. readonly onUserActionRequestedObservable: Observable<Texture>;
  26774. private _generateMipMaps;
  26775. private _engine;
  26776. private _stillImageCaptured;
  26777. private _displayingPosterTexture;
  26778. private _settings;
  26779. private _createInternalTextureOnEvent;
  26780. /**
  26781. * Creates a video texture.
  26782. * If you want to display a video in your scene, this is the special texture for that.
  26783. * This special texture works similar to other textures, with the exception of a few parameters.
  26784. * @see https://doc.babylonjs.com/how_to/video_texture
  26785. * @param name optional name, will detect from video source, if not defined
  26786. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26787. * @param scene is obviously the current scene.
  26788. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26789. * @param invertY is false by default but can be used to invert video on Y axis
  26790. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26791. * @param settings allows finer control over video usage
  26792. */
  26793. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26794. private _getName;
  26795. private _getVideo;
  26796. private _createInternalTexture;
  26797. private reset;
  26798. /**
  26799. * @hidden Internal method to initiate `update`.
  26800. */
  26801. _rebuild(): void;
  26802. /**
  26803. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26804. */
  26805. update(): void;
  26806. /**
  26807. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26808. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26809. */
  26810. updateTexture(isVisible: boolean): void;
  26811. protected _updateInternalTexture: () => void;
  26812. /**
  26813. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26814. * @param url New url.
  26815. */
  26816. updateURL(url: string): void;
  26817. /**
  26818. * Dispose the texture and release its associated resources.
  26819. */
  26820. dispose(): void;
  26821. /**
  26822. * Creates a video texture straight from a stream.
  26823. * @param scene Define the scene the texture should be created in
  26824. * @param stream Define the stream the texture should be created from
  26825. * @returns The created video texture as a promise
  26826. */
  26827. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26828. /**
  26829. * Creates a video texture straight from your WebCam video feed.
  26830. * @param scene Define the scene the texture should be created in
  26831. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26832. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26833. * @returns The created video texture as a promise
  26834. */
  26835. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26836. minWidth: number;
  26837. maxWidth: number;
  26838. minHeight: number;
  26839. maxHeight: number;
  26840. deviceId: string;
  26841. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26842. /**
  26843. * Creates a video texture straight from your WebCam video feed.
  26844. * @param scene Define the scene the texture should be created in
  26845. * @param onReady Define a callback to triggered once the texture will be ready
  26846. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26847. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26848. */
  26849. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26850. minWidth: number;
  26851. maxWidth: number;
  26852. minHeight: number;
  26853. maxHeight: number;
  26854. deviceId: string;
  26855. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26856. }
  26857. }
  26858. declare module "babylonjs/Engines/engine" {
  26859. import { Observable } from "babylonjs/Misc/observable";
  26860. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26861. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26862. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26863. import { Camera } from "babylonjs/Cameras/camera";
  26864. import { Scene } from "babylonjs/scene";
  26865. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26866. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26867. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26868. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26869. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26870. import { Material } from "babylonjs/Materials/material";
  26871. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26872. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26874. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26875. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26876. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26877. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26878. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26879. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26880. import { WebRequest } from "babylonjs/Misc/webRequest";
  26881. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26882. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26883. /**
  26884. * Interface for attribute information associated with buffer instanciation
  26885. */
  26886. export class InstancingAttributeInfo {
  26887. /**
  26888. * Index/offset of the attribute in the vertex shader
  26889. */
  26890. index: number;
  26891. /**
  26892. * size of the attribute, 1, 2, 3 or 4
  26893. */
  26894. attributeSize: number;
  26895. /**
  26896. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26897. * default is FLOAT
  26898. */
  26899. attribyteType: number;
  26900. /**
  26901. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26902. */
  26903. normalized: boolean;
  26904. /**
  26905. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26906. */
  26907. offset: number;
  26908. /**
  26909. * Name of the GLSL attribute, for debugging purpose only
  26910. */
  26911. attributeName: string;
  26912. }
  26913. /**
  26914. * Define options used to create a depth texture
  26915. */
  26916. export class DepthTextureCreationOptions {
  26917. /** Specifies whether or not a stencil should be allocated in the texture */
  26918. generateStencil?: boolean;
  26919. /** Specifies whether or not bilinear filtering is enable on the texture */
  26920. bilinearFiltering?: boolean;
  26921. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26922. comparisonFunction?: number;
  26923. /** Specifies if the created texture is a cube texture */
  26924. isCube?: boolean;
  26925. }
  26926. /**
  26927. * Class used to describe the capabilities of the engine relatively to the current browser
  26928. */
  26929. export class EngineCapabilities {
  26930. /** Maximum textures units per fragment shader */
  26931. maxTexturesImageUnits: number;
  26932. /** Maximum texture units per vertex shader */
  26933. maxVertexTextureImageUnits: number;
  26934. /** Maximum textures units in the entire pipeline */
  26935. maxCombinedTexturesImageUnits: number;
  26936. /** Maximum texture size */
  26937. maxTextureSize: number;
  26938. /** Maximum cube texture size */
  26939. maxCubemapTextureSize: number;
  26940. /** Maximum render texture size */
  26941. maxRenderTextureSize: number;
  26942. /** Maximum number of vertex attributes */
  26943. maxVertexAttribs: number;
  26944. /** Maximum number of varyings */
  26945. maxVaryingVectors: number;
  26946. /** Maximum number of uniforms per vertex shader */
  26947. maxVertexUniformVectors: number;
  26948. /** Maximum number of uniforms per fragment shader */
  26949. maxFragmentUniformVectors: number;
  26950. /** Defines if standard derivates (dx/dy) are supported */
  26951. standardDerivatives: boolean;
  26952. /** Defines if s3tc texture compression is supported */
  26953. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26954. /** Defines if pvrtc texture compression is supported */
  26955. pvrtc: any;
  26956. /** Defines if etc1 texture compression is supported */
  26957. etc1: any;
  26958. /** Defines if etc2 texture compression is supported */
  26959. etc2: any;
  26960. /** Defines if astc texture compression is supported */
  26961. astc: any;
  26962. /** Defines if float textures are supported */
  26963. textureFloat: boolean;
  26964. /** Defines if vertex array objects are supported */
  26965. vertexArrayObject: boolean;
  26966. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26967. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26968. /** Gets the maximum level of anisotropy supported */
  26969. maxAnisotropy: number;
  26970. /** Defines if instancing is supported */
  26971. instancedArrays: boolean;
  26972. /** Defines if 32 bits indices are supported */
  26973. uintIndices: boolean;
  26974. /** Defines if high precision shaders are supported */
  26975. highPrecisionShaderSupported: boolean;
  26976. /** Defines if depth reading in the fragment shader is supported */
  26977. fragmentDepthSupported: boolean;
  26978. /** Defines if float texture linear filtering is supported*/
  26979. textureFloatLinearFiltering: boolean;
  26980. /** Defines if rendering to float textures is supported */
  26981. textureFloatRender: boolean;
  26982. /** Defines if half float textures are supported*/
  26983. textureHalfFloat: boolean;
  26984. /** Defines if half float texture linear filtering is supported*/
  26985. textureHalfFloatLinearFiltering: boolean;
  26986. /** Defines if rendering to half float textures is supported */
  26987. textureHalfFloatRender: boolean;
  26988. /** Defines if textureLOD shader command is supported */
  26989. textureLOD: boolean;
  26990. /** Defines if draw buffers extension is supported */
  26991. drawBuffersExtension: boolean;
  26992. /** Defines if depth textures are supported */
  26993. depthTextureExtension: boolean;
  26994. /** Defines if float color buffer are supported */
  26995. colorBufferFloat: boolean;
  26996. /** Gets disjoint timer query extension (null if not supported) */
  26997. timerQuery: EXT_disjoint_timer_query;
  26998. /** Defines if timestamp can be used with timer query */
  26999. canUseTimestampForTimerQuery: boolean;
  27000. /** Function used to let the system compiles shaders in background */
  27001. parallelShaderCompile: {
  27002. MAX_SHADER_COMPILER_THREADS_KHR: number;
  27003. maxShaderCompilerThreadsKHR: (thread: number) => void;
  27004. COMPLETION_STATUS_KHR: number;
  27005. };
  27006. }
  27007. /** Interface defining initialization parameters for Engine class */
  27008. export interface EngineOptions extends WebGLContextAttributes {
  27009. /**
  27010. * Defines if the engine should no exceed a specified device ratio
  27011. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27012. */
  27013. limitDeviceRatio?: number;
  27014. /**
  27015. * Defines if webvr should be enabled automatically
  27016. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27017. */
  27018. autoEnableWebVR?: boolean;
  27019. /**
  27020. * Defines if webgl2 should be turned off even if supported
  27021. * @see http://doc.babylonjs.com/features/webgl2
  27022. */
  27023. disableWebGL2Support?: boolean;
  27024. /**
  27025. * Defines if webaudio should be initialized as well
  27026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27027. */
  27028. audioEngine?: boolean;
  27029. /**
  27030. * Defines if animations should run using a deterministic lock step
  27031. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27032. */
  27033. deterministicLockstep?: boolean;
  27034. /** Defines the maximum steps to use with deterministic lock step mode */
  27035. lockstepMaxSteps?: number;
  27036. /**
  27037. * Defines that engine should ignore context lost events
  27038. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27039. */
  27040. doNotHandleContextLost?: boolean;
  27041. /**
  27042. * Defines that engine should ignore modifying touch action attribute and style
  27043. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27044. */
  27045. doNotHandleTouchAction?: boolean;
  27046. /**
  27047. * Defines that engine should compile shaders with high precision floats (if supported). False by default
  27048. */
  27049. useHighPrecisionFloats?: boolean;
  27050. }
  27051. /**
  27052. * Defines the interface used by display changed events
  27053. */
  27054. export interface IDisplayChangedEventArgs {
  27055. /** Gets the vrDisplay object (if any) */
  27056. vrDisplay: Nullable<any>;
  27057. /** Gets a boolean indicating if webVR is supported */
  27058. vrSupported: boolean;
  27059. }
  27060. /**
  27061. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27062. */
  27063. export class Engine {
  27064. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27065. static ExceptionList: ({
  27066. key: string;
  27067. capture: string;
  27068. captureConstraint: number;
  27069. targets: string[];
  27070. } | {
  27071. key: string;
  27072. capture: null;
  27073. captureConstraint: null;
  27074. targets: string[];
  27075. })[];
  27076. /** Gets the list of created engines */
  27077. static readonly Instances: Engine[];
  27078. /**
  27079. * Gets the latest created engine
  27080. */
  27081. static readonly LastCreatedEngine: Nullable<Engine>;
  27082. /**
  27083. * Gets the latest created scene
  27084. */
  27085. static readonly LastCreatedScene: Nullable<Scene>;
  27086. /**
  27087. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27088. * @param flag defines which part of the materials must be marked as dirty
  27089. * @param predicate defines a predicate used to filter which materials should be affected
  27090. */
  27091. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27092. /**
  27093. * Hidden
  27094. */
  27095. static _TextureLoaders: IInternalTextureLoader[];
  27096. /** Defines that alpha blending is disabled */
  27097. static readonly ALPHA_DISABLE: number;
  27098. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27099. static readonly ALPHA_ADD: number;
  27100. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27101. static readonly ALPHA_COMBINE: number;
  27102. /** Defines that alpha blending to DEST - SRC * DEST */
  27103. static readonly ALPHA_SUBTRACT: number;
  27104. /** Defines that alpha blending to SRC * DEST */
  27105. static readonly ALPHA_MULTIPLY: number;
  27106. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27107. static readonly ALPHA_MAXIMIZED: number;
  27108. /** Defines that alpha blending to SRC + DEST */
  27109. static readonly ALPHA_ONEONE: number;
  27110. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27111. static readonly ALPHA_PREMULTIPLIED: number;
  27112. /**
  27113. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27114. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27115. */
  27116. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27117. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27118. static readonly ALPHA_INTERPOLATE: number;
  27119. /**
  27120. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27121. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27122. */
  27123. static readonly ALPHA_SCREENMODE: number;
  27124. /** Defines that the ressource is not delayed*/
  27125. static readonly DELAYLOADSTATE_NONE: number;
  27126. /** Defines that the ressource was successfully delay loaded */
  27127. static readonly DELAYLOADSTATE_LOADED: number;
  27128. /** Defines that the ressource is currently delay loading */
  27129. static readonly DELAYLOADSTATE_LOADING: number;
  27130. /** Defines that the ressource is delayed and has not started loading */
  27131. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27133. static readonly NEVER: number;
  27134. /** 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 */
  27135. static readonly ALWAYS: number;
  27136. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27137. static readonly LESS: number;
  27138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27139. static readonly EQUAL: number;
  27140. /** 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 */
  27141. static readonly LEQUAL: number;
  27142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27143. static readonly GREATER: number;
  27144. /** 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 */
  27145. static readonly GEQUAL: number;
  27146. /** 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 */
  27147. static readonly NOTEQUAL: number;
  27148. /** Passed to stencilOperation to specify that stencil value must be kept */
  27149. static readonly KEEP: number;
  27150. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27151. static readonly REPLACE: number;
  27152. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27153. static readonly INCR: number;
  27154. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27155. static readonly DECR: number;
  27156. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27157. static readonly INVERT: number;
  27158. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27159. static readonly INCR_WRAP: number;
  27160. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27161. static readonly DECR_WRAP: number;
  27162. /** Texture is not repeating outside of 0..1 UVs */
  27163. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27164. /** Texture is repeating outside of 0..1 UVs */
  27165. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27166. /** Texture is repeating and mirrored */
  27167. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27168. /** ALPHA */
  27169. static readonly TEXTUREFORMAT_ALPHA: number;
  27170. /** LUMINANCE */
  27171. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27172. /** LUMINANCE_ALPHA */
  27173. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27174. /** RGB */
  27175. static readonly TEXTUREFORMAT_RGB: number;
  27176. /** RGBA */
  27177. static readonly TEXTUREFORMAT_RGBA: number;
  27178. /** RED */
  27179. static readonly TEXTUREFORMAT_RED: number;
  27180. /** RED (2nd reference) */
  27181. static readonly TEXTUREFORMAT_R: number;
  27182. /** RG */
  27183. static readonly TEXTUREFORMAT_RG: number;
  27184. /** RED_INTEGER */
  27185. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27186. /** RED_INTEGER (2nd reference) */
  27187. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27188. /** RG_INTEGER */
  27189. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27190. /** RGB_INTEGER */
  27191. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27192. /** RGBA_INTEGER */
  27193. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27194. /** UNSIGNED_BYTE */
  27195. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27196. /** UNSIGNED_BYTE (2nd reference) */
  27197. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27198. /** FLOAT */
  27199. static readonly TEXTURETYPE_FLOAT: number;
  27200. /** HALF_FLOAT */
  27201. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27202. /** BYTE */
  27203. static readonly TEXTURETYPE_BYTE: number;
  27204. /** SHORT */
  27205. static readonly TEXTURETYPE_SHORT: number;
  27206. /** UNSIGNED_SHORT */
  27207. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27208. /** INT */
  27209. static readonly TEXTURETYPE_INT: number;
  27210. /** UNSIGNED_INT */
  27211. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27212. /** UNSIGNED_SHORT_4_4_4_4 */
  27213. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27214. /** UNSIGNED_SHORT_5_5_5_1 */
  27215. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27216. /** UNSIGNED_SHORT_5_6_5 */
  27217. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27218. /** UNSIGNED_INT_2_10_10_10_REV */
  27219. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27220. /** UNSIGNED_INT_24_8 */
  27221. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27222. /** UNSIGNED_INT_10F_11F_11F_REV */
  27223. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27224. /** UNSIGNED_INT_5_9_9_9_REV */
  27225. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27226. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27227. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27228. /** nearest is mag = nearest and min = nearest and mip = linear */
  27229. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27230. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27231. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27232. /** Trilinear is mag = linear and min = linear and mip = linear */
  27233. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27234. /** nearest is mag = nearest and min = nearest and mip = linear */
  27235. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27237. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27238. /** Trilinear is mag = linear and min = linear and mip = linear */
  27239. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27240. /** mag = nearest and min = nearest and mip = nearest */
  27241. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27242. /** mag = nearest and min = linear and mip = nearest */
  27243. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27244. /** mag = nearest and min = linear and mip = linear */
  27245. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27246. /** mag = nearest and min = linear and mip = none */
  27247. static readonly TEXTURE_NEAREST_LINEAR: number;
  27248. /** mag = nearest and min = nearest and mip = none */
  27249. static readonly TEXTURE_NEAREST_NEAREST: number;
  27250. /** mag = linear and min = nearest and mip = nearest */
  27251. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27252. /** mag = linear and min = nearest and mip = linear */
  27253. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27254. /** mag = linear and min = linear and mip = none */
  27255. static readonly TEXTURE_LINEAR_LINEAR: number;
  27256. /** mag = linear and min = nearest and mip = none */
  27257. static readonly TEXTURE_LINEAR_NEAREST: number;
  27258. /** Explicit coordinates mode */
  27259. static readonly TEXTURE_EXPLICIT_MODE: number;
  27260. /** Spherical coordinates mode */
  27261. static readonly TEXTURE_SPHERICAL_MODE: number;
  27262. /** Planar coordinates mode */
  27263. static readonly TEXTURE_PLANAR_MODE: number;
  27264. /** Cubic coordinates mode */
  27265. static readonly TEXTURE_CUBIC_MODE: number;
  27266. /** Projection coordinates mode */
  27267. static readonly TEXTURE_PROJECTION_MODE: number;
  27268. /** Skybox coordinates mode */
  27269. static readonly TEXTURE_SKYBOX_MODE: number;
  27270. /** Inverse Cubic coordinates mode */
  27271. static readonly TEXTURE_INVCUBIC_MODE: number;
  27272. /** Equirectangular coordinates mode */
  27273. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27274. /** Equirectangular Fixed coordinates mode */
  27275. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27276. /** Equirectangular Fixed Mirrored coordinates mode */
  27277. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27278. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27279. static readonly SCALEMODE_FLOOR: number;
  27280. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27281. static readonly SCALEMODE_NEAREST: number;
  27282. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27283. static readonly SCALEMODE_CEILING: number;
  27284. /**
  27285. * Returns the current version of the framework
  27286. */
  27287. static readonly Version: string;
  27288. /**
  27289. * Returns a string describing the current engine
  27290. */
  27291. readonly description: string;
  27292. /**
  27293. * Gets or sets the epsilon value used by collision engine
  27294. */
  27295. static CollisionsEpsilon: number;
  27296. /**
  27297. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27298. */
  27299. static ShadersRepository: string;
  27300. /**
  27301. * Method called to create the default loading screen.
  27302. * This can be overriden in your own app.
  27303. * @param canvas The rendering canvas element
  27304. * @returns The loading screen
  27305. */
  27306. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27307. /**
  27308. * Method called to create the default rescale post process on each engine.
  27309. */
  27310. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27311. /**
  27312. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27313. */
  27314. forcePOTTextures: boolean;
  27315. /**
  27316. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27317. */
  27318. isFullscreen: boolean;
  27319. /**
  27320. * Gets a boolean indicating if the pointer is currently locked
  27321. */
  27322. isPointerLock: boolean;
  27323. /**
  27324. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27325. */
  27326. cullBackFaces: boolean;
  27327. /**
  27328. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27329. */
  27330. renderEvenInBackground: boolean;
  27331. /**
  27332. * Gets or sets a boolean indicating that cache can be kept between frames
  27333. */
  27334. preventCacheWipeBetweenFrames: boolean;
  27335. /**
  27336. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27337. **/
  27338. enableOfflineSupport: boolean;
  27339. /**
  27340. * 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)
  27341. **/
  27342. disableManifestCheck: boolean;
  27343. /**
  27344. * Gets the list of created scenes
  27345. */
  27346. scenes: Scene[];
  27347. /**
  27348. * Event raised when a new scene is created
  27349. */
  27350. onNewSceneAddedObservable: Observable<Scene>;
  27351. /**
  27352. * Gets the list of created postprocesses
  27353. */
  27354. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27355. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27356. validateShaderPrograms: boolean;
  27357. /**
  27358. * Observable event triggered each time the rendering canvas is resized
  27359. */
  27360. onResizeObservable: Observable<Engine>;
  27361. /**
  27362. * Observable event triggered each time the canvas loses focus
  27363. */
  27364. onCanvasBlurObservable: Observable<Engine>;
  27365. /**
  27366. * Observable event triggered each time the canvas gains focus
  27367. */
  27368. onCanvasFocusObservable: Observable<Engine>;
  27369. /**
  27370. * Observable event triggered each time the canvas receives pointerout event
  27371. */
  27372. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27373. /**
  27374. * Observable event triggered before each texture is initialized
  27375. */
  27376. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27377. private _vrDisplay;
  27378. private _vrSupported;
  27379. private _oldSize;
  27380. private _oldHardwareScaleFactor;
  27381. private _vrExclusivePointerMode;
  27382. private _webVRInitPromise;
  27383. /**
  27384. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27385. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27386. */
  27387. readonly isInVRExclusivePointerMode: boolean;
  27388. /**
  27389. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27390. */
  27391. disableUniformBuffers: boolean;
  27392. /** @hidden */
  27393. _uniformBuffers: UniformBuffer[];
  27394. /**
  27395. * Gets a boolean indicating that the engine supports uniform buffers
  27396. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27397. */
  27398. readonly supportsUniformBuffers: boolean;
  27399. /**
  27400. * Observable raised when the engine begins a new frame
  27401. */
  27402. onBeginFrameObservable: Observable<Engine>;
  27403. /**
  27404. * If set, will be used to request the next animation frame for the render loop
  27405. */
  27406. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27407. /**
  27408. * Observable raised when the engine ends the current frame
  27409. */
  27410. onEndFrameObservable: Observable<Engine>;
  27411. /**
  27412. * Observable raised when the engine is about to compile a shader
  27413. */
  27414. onBeforeShaderCompilationObservable: Observable<Engine>;
  27415. /**
  27416. * Observable raised when the engine has jsut compiled a shader
  27417. */
  27418. onAfterShaderCompilationObservable: Observable<Engine>;
  27419. /** @hidden */
  27420. _gl: WebGLRenderingContext;
  27421. private _renderingCanvas;
  27422. private _windowIsBackground;
  27423. private _webGLVersion;
  27424. private _highPrecisionShadersAllowed;
  27425. /** @hidden */
  27426. readonly _shouldUseHighPrecisionShader: boolean;
  27427. /**
  27428. * Gets a boolean indicating that only power of 2 textures are supported
  27429. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27430. */
  27431. readonly needPOTTextures: boolean;
  27432. /** @hidden */
  27433. _badOS: boolean;
  27434. /** @hidden */
  27435. _badDesktopOS: boolean;
  27436. /**
  27437. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27438. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27439. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27440. */
  27441. disableTextureBindingOptimization: boolean;
  27442. /**
  27443. * Gets the audio engine
  27444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27445. * @ignorenaming
  27446. */
  27447. static audioEngine: IAudioEngine;
  27448. /**
  27449. * Default AudioEngine factory responsible of creating the Audio Engine.
  27450. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27451. */
  27452. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27453. /**
  27454. * Default offline support factory responsible of creating a tool used to store data locally.
  27455. * By default, this will create a Database object if the workload has been embedded.
  27456. */
  27457. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27458. private _onFocus;
  27459. private _onBlur;
  27460. private _onCanvasPointerOut;
  27461. private _onCanvasBlur;
  27462. private _onCanvasFocus;
  27463. private _onFullscreenChange;
  27464. private _onPointerLockChange;
  27465. private _onVRDisplayPointerRestricted;
  27466. private _onVRDisplayPointerUnrestricted;
  27467. private _onVrDisplayConnect;
  27468. private _onVrDisplayDisconnect;
  27469. private _onVrDisplayPresentChange;
  27470. /**
  27471. * Observable signaled when VR display mode changes
  27472. */
  27473. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27474. /**
  27475. * Observable signaled when VR request present is complete
  27476. */
  27477. onVRRequestPresentComplete: Observable<boolean>;
  27478. /**
  27479. * Observable signaled when VR request present starts
  27480. */
  27481. onVRRequestPresentStart: Observable<Engine>;
  27482. private _hardwareScalingLevel;
  27483. /** @hidden */
  27484. protected _caps: EngineCapabilities;
  27485. private _pointerLockRequested;
  27486. private _isStencilEnable;
  27487. private _colorWrite;
  27488. private _loadingScreen;
  27489. /** @hidden */
  27490. _drawCalls: PerfCounter;
  27491. /** @hidden */
  27492. _textureCollisions: PerfCounter;
  27493. private _glVersion;
  27494. private _glRenderer;
  27495. private _glVendor;
  27496. private _videoTextureSupported;
  27497. private _renderingQueueLaunched;
  27498. private _activeRenderLoops;
  27499. private _deterministicLockstep;
  27500. private _lockstepMaxSteps;
  27501. /**
  27502. * Observable signaled when a context lost event is raised
  27503. */
  27504. onContextLostObservable: Observable<Engine>;
  27505. /**
  27506. * Observable signaled when a context restored event is raised
  27507. */
  27508. onContextRestoredObservable: Observable<Engine>;
  27509. private _onContextLost;
  27510. private _onContextRestored;
  27511. private _contextWasLost;
  27512. private _doNotHandleContextLost;
  27513. /**
  27514. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27516. */
  27517. doNotHandleContextLost: boolean;
  27518. private _performanceMonitor;
  27519. private _fps;
  27520. private _deltaTime;
  27521. /**
  27522. * Turn this value on if you want to pause FPS computation when in background
  27523. */
  27524. disablePerformanceMonitorInBackground: boolean;
  27525. /**
  27526. * Gets the performance monitor attached to this engine
  27527. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27528. */
  27529. readonly performanceMonitor: PerformanceMonitor;
  27530. /** @hidden */
  27531. protected _depthCullingState: _DepthCullingState;
  27532. /** @hidden */
  27533. protected _stencilState: _StencilState;
  27534. /** @hidden */
  27535. protected _alphaState: _AlphaState;
  27536. /** @hidden */
  27537. protected _alphaMode: number;
  27538. protected _internalTexturesCache: InternalTexture[];
  27539. /** @hidden */
  27540. protected _activeChannel: number;
  27541. private _currentTextureChannel;
  27542. /** @hidden */
  27543. protected _boundTexturesCache: {
  27544. [key: string]: Nullable<InternalTexture>;
  27545. };
  27546. /** @hidden */
  27547. protected _currentEffect: Nullable<Effect>;
  27548. /** @hidden */
  27549. protected _currentProgram: Nullable<WebGLProgram>;
  27550. private _compiledEffects;
  27551. private _vertexAttribArraysEnabled;
  27552. /** @hidden */
  27553. protected _cachedViewport: Nullable<Viewport>;
  27554. private _cachedVertexArrayObject;
  27555. /** @hidden */
  27556. protected _cachedVertexBuffers: any;
  27557. /** @hidden */
  27558. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27559. /** @hidden */
  27560. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27561. /** @hidden */
  27562. protected _currentRenderTarget: Nullable<InternalTexture>;
  27563. private _uintIndicesCurrentlySet;
  27564. private _currentBoundBuffer;
  27565. /** @hidden */
  27566. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27567. private _currentBufferPointers;
  27568. private _currentInstanceLocations;
  27569. private _currentInstanceBuffers;
  27570. private _textureUnits;
  27571. private _firstBoundInternalTextureTracker;
  27572. private _lastBoundInternalTextureTracker;
  27573. private _workingCanvas;
  27574. private _workingContext;
  27575. private _rescalePostProcess;
  27576. private _dummyFramebuffer;
  27577. private _externalData;
  27578. private _bindedRenderFunction;
  27579. private _vaoRecordInProgress;
  27580. private _mustWipeVertexAttributes;
  27581. private _emptyTexture;
  27582. private _emptyCubeTexture;
  27583. private _emptyTexture3D;
  27584. /** @hidden */
  27585. _frameHandler: number;
  27586. private _nextFreeTextureSlots;
  27587. private _maxSimultaneousTextures;
  27588. private _activeRequests;
  27589. private _texturesSupported;
  27590. private _textureFormatInUse;
  27591. /**
  27592. * Gets the list of texture formats supported
  27593. */
  27594. readonly texturesSupported: Array<string>;
  27595. /**
  27596. * Gets the list of texture formats in use
  27597. */
  27598. readonly textureFormatInUse: Nullable<string>;
  27599. /**
  27600. * Gets the current viewport
  27601. */
  27602. readonly currentViewport: Nullable<Viewport>;
  27603. /**
  27604. * Gets the default empty texture
  27605. */
  27606. readonly emptyTexture: InternalTexture;
  27607. /**
  27608. * Gets the default empty 3D texture
  27609. */
  27610. readonly emptyTexture3D: InternalTexture;
  27611. /**
  27612. * Gets the default empty cube texture
  27613. */
  27614. readonly emptyCubeTexture: InternalTexture;
  27615. /**
  27616. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27617. */
  27618. readonly premultipliedAlpha: boolean;
  27619. /**
  27620. * Creates a new engine
  27621. * @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
  27622. * @param antialias defines enable antialiasing (default: false)
  27623. * @param options defines further options to be sent to the getContext() function
  27624. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27625. */
  27626. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27627. private _disableTouchAction;
  27628. private _rebuildInternalTextures;
  27629. private _rebuildEffects;
  27630. /**
  27631. * Gets a boolean indicating if all created effects are ready
  27632. * @returns true if all effects are ready
  27633. */
  27634. areAllEffectsReady(): boolean;
  27635. private _rebuildBuffers;
  27636. private _initGLContext;
  27637. /**
  27638. * Gets version of the current webGL context
  27639. */
  27640. readonly webGLVersion: number;
  27641. /**
  27642. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27643. */
  27644. readonly isStencilEnable: boolean;
  27645. private _prepareWorkingCanvas;
  27646. /**
  27647. * Reset the texture cache to empty state
  27648. */
  27649. resetTextureCache(): void;
  27650. /**
  27651. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27652. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27653. * @returns true if engine is in deterministic lock step mode
  27654. */
  27655. isDeterministicLockStep(): boolean;
  27656. /**
  27657. * Gets the max steps when engine is running in deterministic lock step
  27658. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27659. * @returns the max steps
  27660. */
  27661. getLockstepMaxSteps(): number;
  27662. /**
  27663. * Gets an object containing information about the current webGL context
  27664. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27665. */
  27666. getGlInfo(): {
  27667. vendor: string;
  27668. renderer: string;
  27669. version: string;
  27670. };
  27671. /**
  27672. * Gets current aspect ratio
  27673. * @param camera defines the camera to use to get the aspect ratio
  27674. * @param useScreen defines if screen size must be used (or the current render target if any)
  27675. * @returns a number defining the aspect ratio
  27676. */
  27677. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27678. /**
  27679. * Gets current screen aspect ratio
  27680. * @returns a number defining the aspect ratio
  27681. */
  27682. getScreenAspectRatio(): number;
  27683. /**
  27684. * Gets the current render width
  27685. * @param useScreen defines if screen size must be used (or the current render target if any)
  27686. * @returns a number defining the current render width
  27687. */
  27688. getRenderWidth(useScreen?: boolean): number;
  27689. /**
  27690. * Gets the current render height
  27691. * @param useScreen defines if screen size must be used (or the current render target if any)
  27692. * @returns a number defining the current render height
  27693. */
  27694. getRenderHeight(useScreen?: boolean): number;
  27695. /**
  27696. * Gets the HTML canvas attached with the current webGL context
  27697. * @returns a HTML canvas
  27698. */
  27699. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27700. /**
  27701. * Gets the client rect of the HTML canvas attached with the current webGL context
  27702. * @returns a client rectanglee
  27703. */
  27704. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27705. /**
  27706. * Defines the hardware scaling level.
  27707. * By default the hardware scaling level is computed from the window device ratio.
  27708. * 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.
  27709. * @param level defines the level to use
  27710. */
  27711. setHardwareScalingLevel(level: number): void;
  27712. /**
  27713. * Gets the current hardware scaling level.
  27714. * By default the hardware scaling level is computed from the window device ratio.
  27715. * 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.
  27716. * @returns a number indicating the current hardware scaling level
  27717. */
  27718. getHardwareScalingLevel(): number;
  27719. /**
  27720. * Gets the list of loaded textures
  27721. * @returns an array containing all loaded textures
  27722. */
  27723. getLoadedTexturesCache(): InternalTexture[];
  27724. /**
  27725. * Gets the object containing all engine capabilities
  27726. * @returns the EngineCapabilities object
  27727. */
  27728. getCaps(): EngineCapabilities;
  27729. /**
  27730. * Gets the current depth function
  27731. * @returns a number defining the depth function
  27732. */
  27733. getDepthFunction(): Nullable<number>;
  27734. /**
  27735. * Sets the current depth function
  27736. * @param depthFunc defines the function to use
  27737. */
  27738. setDepthFunction(depthFunc: number): void;
  27739. /**
  27740. * Sets the current depth function to GREATER
  27741. */
  27742. setDepthFunctionToGreater(): void;
  27743. /**
  27744. * Sets the current depth function to GEQUAL
  27745. */
  27746. setDepthFunctionToGreaterOrEqual(): void;
  27747. /**
  27748. * Sets the current depth function to LESS
  27749. */
  27750. setDepthFunctionToLess(): void;
  27751. /**
  27752. * Sets the current depth function to LEQUAL
  27753. */
  27754. setDepthFunctionToLessOrEqual(): void;
  27755. /**
  27756. * Gets a boolean indicating if stencil buffer is enabled
  27757. * @returns the current stencil buffer state
  27758. */
  27759. getStencilBuffer(): boolean;
  27760. /**
  27761. * Enable or disable the stencil buffer
  27762. * @param enable defines if the stencil buffer must be enabled or disabled
  27763. */
  27764. setStencilBuffer(enable: boolean): void;
  27765. /**
  27766. * Gets the current stencil mask
  27767. * @returns a number defining the new stencil mask to use
  27768. */
  27769. getStencilMask(): number;
  27770. /**
  27771. * Sets the current stencil mask
  27772. * @param mask defines the new stencil mask to use
  27773. */
  27774. setStencilMask(mask: number): void;
  27775. /**
  27776. * Gets the current stencil function
  27777. * @returns a number defining the stencil function to use
  27778. */
  27779. getStencilFunction(): number;
  27780. /**
  27781. * Gets the current stencil reference value
  27782. * @returns a number defining the stencil reference value to use
  27783. */
  27784. getStencilFunctionReference(): number;
  27785. /**
  27786. * Gets the current stencil mask
  27787. * @returns a number defining the stencil mask to use
  27788. */
  27789. getStencilFunctionMask(): number;
  27790. /**
  27791. * Sets the current stencil function
  27792. * @param stencilFunc defines the new stencil function to use
  27793. */
  27794. setStencilFunction(stencilFunc: number): void;
  27795. /**
  27796. * Sets the current stencil reference
  27797. * @param reference defines the new stencil reference to use
  27798. */
  27799. setStencilFunctionReference(reference: number): void;
  27800. /**
  27801. * Sets the current stencil mask
  27802. * @param mask defines the new stencil mask to use
  27803. */
  27804. setStencilFunctionMask(mask: number): void;
  27805. /**
  27806. * Gets the current stencil operation when stencil fails
  27807. * @returns a number defining stencil operation to use when stencil fails
  27808. */
  27809. getStencilOperationFail(): number;
  27810. /**
  27811. * Gets the current stencil operation when depth fails
  27812. * @returns a number defining stencil operation to use when depth fails
  27813. */
  27814. getStencilOperationDepthFail(): number;
  27815. /**
  27816. * Gets the current stencil operation when stencil passes
  27817. * @returns a number defining stencil operation to use when stencil passes
  27818. */
  27819. getStencilOperationPass(): number;
  27820. /**
  27821. * Sets the stencil operation to use when stencil fails
  27822. * @param operation defines the stencil operation to use when stencil fails
  27823. */
  27824. setStencilOperationFail(operation: number): void;
  27825. /**
  27826. * Sets the stencil operation to use when depth fails
  27827. * @param operation defines the stencil operation to use when depth fails
  27828. */
  27829. setStencilOperationDepthFail(operation: number): void;
  27830. /**
  27831. * Sets the stencil operation to use when stencil passes
  27832. * @param operation defines the stencil operation to use when stencil passes
  27833. */
  27834. setStencilOperationPass(operation: number): void;
  27835. /**
  27836. * Sets a boolean indicating if the dithering state is enabled or disabled
  27837. * @param value defines the dithering state
  27838. */
  27839. setDitheringState(value: boolean): void;
  27840. /**
  27841. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27842. * @param value defines the rasterizer state
  27843. */
  27844. setRasterizerState(value: boolean): void;
  27845. /**
  27846. * stop executing a render loop function and remove it from the execution array
  27847. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27848. */
  27849. stopRenderLoop(renderFunction?: () => void): void;
  27850. /** @hidden */
  27851. _renderLoop(): void;
  27852. /**
  27853. * Register and execute a render loop. The engine can have more than one render function
  27854. * @param renderFunction defines the function to continuously execute
  27855. */
  27856. runRenderLoop(renderFunction: () => void): void;
  27857. /**
  27858. * Toggle full screen mode
  27859. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27860. */
  27861. switchFullscreen(requestPointerLock: boolean): void;
  27862. /**
  27863. * Enters full screen mode
  27864. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27865. */
  27866. enterFullscreen(requestPointerLock: boolean): void;
  27867. /**
  27868. * Exits full screen mode
  27869. */
  27870. exitFullscreen(): void;
  27871. /**
  27872. * Clear the current render buffer or the current render target (if any is set up)
  27873. * @param color defines the color to use
  27874. * @param backBuffer defines if the back buffer must be cleared
  27875. * @param depth defines if the depth buffer must be cleared
  27876. * @param stencil defines if the stencil buffer must be cleared
  27877. */
  27878. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27879. /**
  27880. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27881. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27882. * @param y defines the y-coordinate of the corner of the clear rectangle
  27883. * @param width defines the width of the clear rectangle
  27884. * @param height defines the height of the clear rectangle
  27885. * @param clearColor defines the clear color
  27886. */
  27887. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27888. /**
  27889. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27890. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27891. * @param y defines the y-coordinate of the corner of the clear rectangle
  27892. * @param width defines the width of the clear rectangle
  27893. * @param height defines the height of the clear rectangle
  27894. */
  27895. enableScissor(x: number, y: number, width: number, height: number): void;
  27896. /**
  27897. * Disable previously set scissor test rectangle
  27898. */
  27899. disableScissor(): void;
  27900. private _viewportCached;
  27901. /** @hidden */
  27902. _viewport(x: number, y: number, width: number, height: number): void;
  27903. /**
  27904. * Set the WebGL's viewport
  27905. * @param viewport defines the viewport element to be used
  27906. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27907. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27908. */
  27909. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27910. /**
  27911. * Directly set the WebGL Viewport
  27912. * @param x defines the x coordinate of the viewport (in screen space)
  27913. * @param y defines the y coordinate of the viewport (in screen space)
  27914. * @param width defines the width of the viewport (in screen space)
  27915. * @param height defines the height of the viewport (in screen space)
  27916. * @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
  27917. */
  27918. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27919. /**
  27920. * Begin a new frame
  27921. */
  27922. beginFrame(): void;
  27923. /**
  27924. * Enf the current frame
  27925. */
  27926. endFrame(): void;
  27927. /**
  27928. * Resize the view according to the canvas' size
  27929. */
  27930. resize(): void;
  27931. /**
  27932. * Force a specific size of the canvas
  27933. * @param width defines the new canvas' width
  27934. * @param height defines the new canvas' height
  27935. */
  27936. setSize(width: number, height: number): void;
  27937. /**
  27938. * Gets a boolean indicating if a webVR device was detected
  27939. * @returns true if a webVR device was detected
  27940. */
  27941. isVRDevicePresent(): boolean;
  27942. /**
  27943. * Gets the current webVR device
  27944. * @returns the current webVR device (or null)
  27945. */
  27946. getVRDevice(): any;
  27947. /**
  27948. * Initializes a webVR display and starts listening to display change events
  27949. * The onVRDisplayChangedObservable will be notified upon these changes
  27950. * @returns The onVRDisplayChangedObservable
  27951. */
  27952. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27953. /**
  27954. * Initializes a webVR display and starts listening to display change events
  27955. * The onVRDisplayChangedObservable will be notified upon these changes
  27956. * @returns A promise containing a VRDisplay and if vr is supported
  27957. */
  27958. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27959. /**
  27960. * Call this function to switch to webVR mode
  27961. * Will do nothing if webVR is not supported or if there is no webVR device
  27962. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27963. */
  27964. enableVR(): void;
  27965. /**
  27966. * Call this function to leave webVR mode
  27967. * Will do nothing if webVR is not supported or if there is no webVR device
  27968. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27969. */
  27970. disableVR(): void;
  27971. private _onVRFullScreenTriggered;
  27972. private _getVRDisplaysAsync;
  27973. /**
  27974. * Binds the frame buffer to the specified texture.
  27975. * @param texture The texture to render to or null for the default canvas
  27976. * @param faceIndex The face of the texture to render to in case of cube texture
  27977. * @param requiredWidth The width of the target to render to
  27978. * @param requiredHeight The height of the target to render to
  27979. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27980. * @param depthStencilTexture The depth stencil texture to use to render
  27981. * @param lodLevel defines le lod level to bind to the frame buffer
  27982. */
  27983. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27984. private bindUnboundFramebuffer;
  27985. /**
  27986. * Unbind the current render target texture from the webGL context
  27987. * @param texture defines the render target texture to unbind
  27988. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27989. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27990. */
  27991. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27992. /**
  27993. * Unbind a list of render target textures from the webGL context
  27994. * This is used only when drawBuffer extension or webGL2 are active
  27995. * @param textures defines the render target textures to unbind
  27996. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27997. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27998. */
  27999. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28000. /**
  28001. * Force the mipmap generation for the given render target texture
  28002. * @param texture defines the render target texture to use
  28003. */
  28004. generateMipMapsForCubemap(texture: InternalTexture): void;
  28005. /**
  28006. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28007. */
  28008. flushFramebuffer(): void;
  28009. /**
  28010. * Unbind the current render target and bind the default framebuffer
  28011. */
  28012. restoreDefaultFramebuffer(): void;
  28013. /**
  28014. * Create an uniform buffer
  28015. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28016. * @param elements defines the content of the uniform buffer
  28017. * @returns the webGL uniform buffer
  28018. */
  28019. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28020. /**
  28021. * Create a dynamic uniform buffer
  28022. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28023. * @param elements defines the content of the uniform buffer
  28024. * @returns the webGL uniform buffer
  28025. */
  28026. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28027. /**
  28028. * Update an existing uniform buffer
  28029. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28030. * @param uniformBuffer defines the target uniform buffer
  28031. * @param elements defines the content to update
  28032. * @param offset defines the offset in the uniform buffer where update should start
  28033. * @param count defines the size of the data to update
  28034. */
  28035. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28036. private _resetVertexBufferBinding;
  28037. /**
  28038. * Creates a vertex buffer
  28039. * @param data the data for the vertex buffer
  28040. * @returns the new WebGL static buffer
  28041. */
  28042. createVertexBuffer(data: DataArray): WebGLBuffer;
  28043. /**
  28044. * Creates a dynamic vertex buffer
  28045. * @param data the data for the dynamic vertex buffer
  28046. * @returns the new WebGL dynamic buffer
  28047. */
  28048. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28049. /**
  28050. * Update a dynamic index buffer
  28051. * @param indexBuffer defines the target index buffer
  28052. * @param indices defines the data to update
  28053. * @param offset defines the offset in the target index buffer where update should start
  28054. */
  28055. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28056. /**
  28057. * Updates a dynamic vertex buffer.
  28058. * @param vertexBuffer the vertex buffer to update
  28059. * @param data the data used to update the vertex buffer
  28060. * @param byteOffset the byte offset of the data
  28061. * @param byteLength the byte length of the data
  28062. */
  28063. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28064. private _resetIndexBufferBinding;
  28065. /**
  28066. * Creates a new index buffer
  28067. * @param indices defines the content of the index buffer
  28068. * @param updatable defines if the index buffer must be updatable
  28069. * @returns a new webGL buffer
  28070. */
  28071. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28072. /**
  28073. * Bind a webGL buffer to the webGL context
  28074. * @param buffer defines the buffer to bind
  28075. */
  28076. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28077. /**
  28078. * Bind an uniform buffer to the current webGL context
  28079. * @param buffer defines the buffer to bind
  28080. */
  28081. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28082. /**
  28083. * Bind a buffer to the current webGL context at a given location
  28084. * @param buffer defines the buffer to bind
  28085. * @param location defines the index where to bind the buffer
  28086. */
  28087. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28088. /**
  28089. * Bind a specific block at a given index in a specific shader program
  28090. * @param shaderProgram defines the shader program
  28091. * @param blockName defines the block name
  28092. * @param index defines the index where to bind the block
  28093. */
  28094. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28095. private bindIndexBuffer;
  28096. private bindBuffer;
  28097. /**
  28098. * update the bound buffer with the given data
  28099. * @param data defines the data to update
  28100. */
  28101. updateArrayBuffer(data: Float32Array): void;
  28102. private _vertexAttribPointer;
  28103. private _bindIndexBufferWithCache;
  28104. private _bindVertexBuffersAttributes;
  28105. /**
  28106. * Records a vertex array object
  28107. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28108. * @param vertexBuffers defines the list of vertex buffers to store
  28109. * @param indexBuffer defines the index buffer to store
  28110. * @param effect defines the effect to store
  28111. * @returns the new vertex array object
  28112. */
  28113. recordVertexArrayObject(vertexBuffers: {
  28114. [key: string]: VertexBuffer;
  28115. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28116. /**
  28117. * Bind a specific vertex array object
  28118. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28119. * @param vertexArrayObject defines the vertex array object to bind
  28120. * @param indexBuffer defines the index buffer to bind
  28121. */
  28122. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28123. /**
  28124. * Bind webGl buffers directly to the webGL context
  28125. * @param vertexBuffer defines the vertex buffer to bind
  28126. * @param indexBuffer defines the index buffer to bind
  28127. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28128. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28129. * @param effect defines the effect associated with the vertex buffer
  28130. */
  28131. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28132. private _unbindVertexArrayObject;
  28133. /**
  28134. * Bind a list of vertex buffers to the webGL context
  28135. * @param vertexBuffers defines the list of vertex buffers to bind
  28136. * @param indexBuffer defines the index buffer to bind
  28137. * @param effect defines the effect associated with the vertex buffers
  28138. */
  28139. bindBuffers(vertexBuffers: {
  28140. [key: string]: Nullable<VertexBuffer>;
  28141. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28142. /**
  28143. * Unbind all instance attributes
  28144. */
  28145. unbindInstanceAttributes(): void;
  28146. /**
  28147. * Release and free the memory of a vertex array object
  28148. * @param vao defines the vertex array object to delete
  28149. */
  28150. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28151. /** @hidden */
  28152. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28153. /**
  28154. * Creates a webGL buffer to use with instanciation
  28155. * @param capacity defines the size of the buffer
  28156. * @returns the webGL buffer
  28157. */
  28158. createInstancesBuffer(capacity: number): WebGLBuffer;
  28159. /**
  28160. * Delete a webGL buffer used with instanciation
  28161. * @param buffer defines the webGL buffer to delete
  28162. */
  28163. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28164. /**
  28165. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28166. * @param instancesBuffer defines the webGL buffer to update and bind
  28167. * @param data defines the data to store in the buffer
  28168. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28169. */
  28170. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28171. /**
  28172. * Apply all cached states (depth, culling, stencil and alpha)
  28173. */
  28174. applyStates(): void;
  28175. /**
  28176. * Send a draw order
  28177. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28178. * @param indexStart defines the starting index
  28179. * @param indexCount defines the number of index to draw
  28180. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28181. */
  28182. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28183. /**
  28184. * Draw a list of points
  28185. * @param verticesStart defines the index of first vertex to draw
  28186. * @param verticesCount defines the count of vertices to draw
  28187. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28188. */
  28189. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28190. /**
  28191. * Draw a list of unindexed primitives
  28192. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28193. * @param verticesStart defines the index of first vertex to draw
  28194. * @param verticesCount defines the count of vertices to draw
  28195. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28196. */
  28197. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28198. /**
  28199. * Draw a list of indexed primitives
  28200. * @param fillMode defines the primitive to use
  28201. * @param indexStart defines the starting index
  28202. * @param indexCount defines the number of index to draw
  28203. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28204. */
  28205. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28206. /**
  28207. * Draw a list of unindexed primitives
  28208. * @param fillMode defines the primitive to use
  28209. * @param verticesStart defines the index of first vertex to draw
  28210. * @param verticesCount defines the count of vertices to draw
  28211. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28212. */
  28213. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28214. private _drawMode;
  28215. /** @hidden */
  28216. _releaseEffect(effect: Effect): void;
  28217. /** @hidden */
  28218. _deleteProgram(program: WebGLProgram): void;
  28219. /**
  28220. * Create a new effect (used to store vertex/fragment shaders)
  28221. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28222. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28223. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28224. * @param samplers defines an array of string used to represent textures
  28225. * @param defines defines the string containing the defines to use to compile the shaders
  28226. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28227. * @param onCompiled defines a function to call when the effect creation is successful
  28228. * @param onError defines a function to call when the effect creation has failed
  28229. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28230. * @returns the new Effect
  28231. */
  28232. 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;
  28233. private _compileShader;
  28234. private _compileRawShader;
  28235. /**
  28236. * Directly creates a webGL program
  28237. * @param vertexCode defines the vertex shader code to use
  28238. * @param fragmentCode defines the fragment shader code to use
  28239. * @param context defines the webGL context to use (if not set, the current one will be used)
  28240. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28241. * @returns the new webGL program
  28242. */
  28243. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28244. /**
  28245. * Creates a webGL program
  28246. * @param vertexCode defines the vertex shader code to use
  28247. * @param fragmentCode defines the fragment shader code to use
  28248. * @param defines defines the string containing the defines to use to compile the shaders
  28249. * @param context defines the webGL context to use (if not set, the current one will be used)
  28250. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28251. * @returns the new webGL program
  28252. */
  28253. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28254. private _createShaderProgram;
  28255. private _finalizeProgram;
  28256. /** @hidden */
  28257. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28258. /** @hidden */
  28259. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28260. /**
  28261. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28262. * @param shaderProgram defines the webGL program to use
  28263. * @param uniformsNames defines the list of uniform names
  28264. * @returns an array of webGL uniform locations
  28265. */
  28266. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28267. /**
  28268. * Gets the lsit of active attributes for a given webGL program
  28269. * @param shaderProgram defines the webGL program to use
  28270. * @param attributesNames defines the list of attribute names to get
  28271. * @returns an array of indices indicating the offset of each attribute
  28272. */
  28273. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28274. /**
  28275. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28276. * @param effect defines the effect to activate
  28277. */
  28278. enableEffect(effect: Nullable<Effect>): void;
  28279. /**
  28280. * Set the value of an uniform to an array of int32
  28281. * @param uniform defines the webGL uniform location where to store the value
  28282. * @param array defines the array of int32 to store
  28283. */
  28284. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28285. /**
  28286. * Set the value of an uniform to an array of int32 (stored as vec2)
  28287. * @param uniform defines the webGL uniform location where to store the value
  28288. * @param array defines the array of int32 to store
  28289. */
  28290. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28291. /**
  28292. * Set the value of an uniform to an array of int32 (stored as vec3)
  28293. * @param uniform defines the webGL uniform location where to store the value
  28294. * @param array defines the array of int32 to store
  28295. */
  28296. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28297. /**
  28298. * Set the value of an uniform to an array of int32 (stored as vec4)
  28299. * @param uniform defines the webGL uniform location where to store the value
  28300. * @param array defines the array of int32 to store
  28301. */
  28302. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28303. /**
  28304. * Set the value of an uniform to an array of float32
  28305. * @param uniform defines the webGL uniform location where to store the value
  28306. * @param array defines the array of float32 to store
  28307. */
  28308. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28309. /**
  28310. * Set the value of an uniform to an array of float32 (stored as vec2)
  28311. * @param uniform defines the webGL uniform location where to store the value
  28312. * @param array defines the array of float32 to store
  28313. */
  28314. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28315. /**
  28316. * Set the value of an uniform to an array of float32 (stored as vec3)
  28317. * @param uniform defines the webGL uniform location where to store the value
  28318. * @param array defines the array of float32 to store
  28319. */
  28320. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28321. /**
  28322. * Set the value of an uniform to an array of float32 (stored as vec4)
  28323. * @param uniform defines the webGL uniform location where to store the value
  28324. * @param array defines the array of float32 to store
  28325. */
  28326. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28327. /**
  28328. * Set the value of an uniform to an array of number
  28329. * @param uniform defines the webGL uniform location where to store the value
  28330. * @param array defines the array of number to store
  28331. */
  28332. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28333. /**
  28334. * Set the value of an uniform to an array of number (stored as vec2)
  28335. * @param uniform defines the webGL uniform location where to store the value
  28336. * @param array defines the array of number to store
  28337. */
  28338. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28339. /**
  28340. * Set the value of an uniform to an array of number (stored as vec3)
  28341. * @param uniform defines the webGL uniform location where to store the value
  28342. * @param array defines the array of number to store
  28343. */
  28344. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28345. /**
  28346. * Set the value of an uniform to an array of number (stored as vec4)
  28347. * @param uniform defines the webGL uniform location where to store the value
  28348. * @param array defines the array of number to store
  28349. */
  28350. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28351. /**
  28352. * Set the value of an uniform to an array of float32 (stored as matrices)
  28353. * @param uniform defines the webGL uniform location where to store the value
  28354. * @param matrices defines the array of float32 to store
  28355. */
  28356. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28357. /**
  28358. * Set the value of an uniform to a matrix
  28359. * @param uniform defines the webGL uniform location where to store the value
  28360. * @param matrix defines the matrix to store
  28361. */
  28362. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28363. /**
  28364. * Set the value of an uniform to a matrix (3x3)
  28365. * @param uniform defines the webGL uniform location where to store the value
  28366. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28367. */
  28368. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28369. /**
  28370. * Set the value of an uniform to a matrix (2x2)
  28371. * @param uniform defines the webGL uniform location where to store the value
  28372. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28373. */
  28374. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28375. /**
  28376. * Set the value of an uniform to a number (int)
  28377. * @param uniform defines the webGL uniform location where to store the value
  28378. * @param value defines the int number to store
  28379. */
  28380. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28381. /**
  28382. * Set the value of an uniform to a number (float)
  28383. * @param uniform defines the webGL uniform location where to store the value
  28384. * @param value defines the float number to store
  28385. */
  28386. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28387. /**
  28388. * Set the value of an uniform to a vec2
  28389. * @param uniform defines the webGL uniform location where to store the value
  28390. * @param x defines the 1st component of the value
  28391. * @param y defines the 2nd component of the value
  28392. */
  28393. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28394. /**
  28395. * Set the value of an uniform to a vec3
  28396. * @param uniform defines the webGL uniform location where to store the value
  28397. * @param x defines the 1st component of the value
  28398. * @param y defines the 2nd component of the value
  28399. * @param z defines the 3rd component of the value
  28400. */
  28401. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28402. /**
  28403. * Set the value of an uniform to a boolean
  28404. * @param uniform defines the webGL uniform location where to store the value
  28405. * @param bool defines the boolean to store
  28406. */
  28407. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28408. /**
  28409. * Set the value of an uniform to a vec4
  28410. * @param uniform defines the webGL uniform location where to store the value
  28411. * @param x defines the 1st component of the value
  28412. * @param y defines the 2nd component of the value
  28413. * @param z defines the 3rd component of the value
  28414. * @param w defines the 4th component of the value
  28415. */
  28416. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28417. /**
  28418. * Set the value of an uniform to a Color3
  28419. * @param uniform defines the webGL uniform location where to store the value
  28420. * @param color3 defines the color to store
  28421. */
  28422. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28423. /**
  28424. * Set the value of an uniform to a Color3 and an alpha value
  28425. * @param uniform defines the webGL uniform location where to store the value
  28426. * @param color3 defines the color to store
  28427. * @param alpha defines the alpha component to store
  28428. */
  28429. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28430. /**
  28431. * Sets a Color4 on a uniform variable
  28432. * @param uniform defines the uniform location
  28433. * @param color4 defines the value to be set
  28434. */
  28435. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28436. /**
  28437. * Set various states to the webGL context
  28438. * @param culling defines backface culling state
  28439. * @param zOffset defines the value to apply to zOffset (0 by default)
  28440. * @param force defines if states must be applied even if cache is up to date
  28441. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28442. */
  28443. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28444. /**
  28445. * Set the z offset to apply to current rendering
  28446. * @param value defines the offset to apply
  28447. */
  28448. setZOffset(value: number): void;
  28449. /**
  28450. * Gets the current value of the zOffset
  28451. * @returns the current zOffset state
  28452. */
  28453. getZOffset(): number;
  28454. /**
  28455. * Enable or disable depth buffering
  28456. * @param enable defines the state to set
  28457. */
  28458. setDepthBuffer(enable: boolean): void;
  28459. /**
  28460. * Gets a boolean indicating if depth writing is enabled
  28461. * @returns the current depth writing state
  28462. */
  28463. getDepthWrite(): boolean;
  28464. /**
  28465. * Enable or disable depth writing
  28466. * @param enable defines the state to set
  28467. */
  28468. setDepthWrite(enable: boolean): void;
  28469. /**
  28470. * Enable or disable color writing
  28471. * @param enable defines the state to set
  28472. */
  28473. setColorWrite(enable: boolean): void;
  28474. /**
  28475. * Gets a boolean indicating if color writing is enabled
  28476. * @returns the current color writing state
  28477. */
  28478. getColorWrite(): boolean;
  28479. /**
  28480. * Sets alpha constants used by some alpha blending modes
  28481. * @param r defines the red component
  28482. * @param g defines the green component
  28483. * @param b defines the blue component
  28484. * @param a defines the alpha component
  28485. */
  28486. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28487. /**
  28488. * Sets the current alpha mode
  28489. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28490. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28491. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28492. */
  28493. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28494. /**
  28495. * Gets the current alpha mode
  28496. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28497. * @returns the current alpha mode
  28498. */
  28499. getAlphaMode(): number;
  28500. /**
  28501. * Clears the list of texture accessible through engine.
  28502. * This can help preventing texture load conflict due to name collision.
  28503. */
  28504. clearInternalTexturesCache(): void;
  28505. /**
  28506. * Force the entire cache to be cleared
  28507. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28508. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28509. */
  28510. wipeCaches(bruteForce?: boolean): void;
  28511. /**
  28512. * Set the compressed texture format to use, based on the formats you have, and the formats
  28513. * supported by the hardware / browser.
  28514. *
  28515. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28516. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28517. * to API arguments needed to compressed textures. This puts the burden on the container
  28518. * generator to house the arcane code for determining these for current & future formats.
  28519. *
  28520. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28521. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28522. *
  28523. * Note: The result of this call is not taken into account when a texture is base64.
  28524. *
  28525. * @param formatsAvailable defines the list of those format families you have created
  28526. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28527. *
  28528. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28529. * @returns The extension selected.
  28530. */
  28531. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28532. private _getSamplingParameters;
  28533. private _partialLoadImg;
  28534. private _cascadeLoadImgs;
  28535. /** @hidden */
  28536. _createTexture(): WebGLTexture;
  28537. /**
  28538. * Usually called from Texture.ts.
  28539. * Passed information to create a WebGLTexture
  28540. * @param urlArg defines a value which contains one of the following:
  28541. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28542. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28543. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28544. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28545. * @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)
  28546. * @param scene needed for loading to the correct scene
  28547. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28548. * @param onLoad optional callback to be called upon successful completion
  28549. * @param onError optional callback to be called upon failure
  28550. * @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
  28551. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28552. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28553. * @param forcedExtension defines the extension to use to pick the right loader
  28554. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28555. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28556. */
  28557. 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;
  28558. private _rescaleTexture;
  28559. /**
  28560. * Update a raw texture
  28561. * @param texture defines the texture to update
  28562. * @param data defines the data to store in the texture
  28563. * @param format defines the format of the data
  28564. * @param invertY defines if data must be stored with Y axis inverted
  28565. * @param compression defines the compression used (null by default)
  28566. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28567. */
  28568. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28569. /**
  28570. * Creates a raw texture
  28571. * @param data defines the data to store in the texture
  28572. * @param width defines the width of the texture
  28573. * @param height defines the height of the texture
  28574. * @param format defines the format of the data
  28575. * @param generateMipMaps defines if the engine should generate the mip levels
  28576. * @param invertY defines if data must be stored with Y axis inverted
  28577. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28578. * @param compression defines the compression used (null by default)
  28579. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28580. * @returns the raw texture inside an InternalTexture
  28581. */
  28582. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28583. private _unpackFlipYCached;
  28584. /**
  28585. * In case you are sharing the context with other applications, it might
  28586. * be interested to not cache the unpack flip y state to ensure a consistent
  28587. * value would be set.
  28588. */
  28589. enableUnpackFlipYCached: boolean;
  28590. /** @hidden */
  28591. _unpackFlipY(value: boolean): void;
  28592. /** @hidden */
  28593. _getUnpackAlignement(): number;
  28594. /**
  28595. * Creates a dynamic texture
  28596. * @param width defines the width of the texture
  28597. * @param height defines the height of the texture
  28598. * @param generateMipMaps defines if the engine should generate the mip levels
  28599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28600. * @returns the dynamic texture inside an InternalTexture
  28601. */
  28602. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28603. /**
  28604. * Update the sampling mode of a given texture
  28605. * @param samplingMode defines the required sampling mode
  28606. * @param texture defines the texture to update
  28607. */
  28608. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28609. /**
  28610. * Update the content of a dynamic texture
  28611. * @param texture defines the texture to update
  28612. * @param canvas defines the canvas containing the source
  28613. * @param invertY defines if data must be stored with Y axis inverted
  28614. * @param premulAlpha defines if alpha is stored as premultiplied
  28615. * @param format defines the format of the data
  28616. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28617. */
  28618. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28619. /**
  28620. * Update a video texture
  28621. * @param texture defines the texture to update
  28622. * @param video defines the video element to use
  28623. * @param invertY defines if data must be stored with Y axis inverted
  28624. */
  28625. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28626. /**
  28627. * Updates a depth texture Comparison Mode and Function.
  28628. * If the comparison Function is equal to 0, the mode will be set to none.
  28629. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28630. * @param texture The texture to set the comparison function for
  28631. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28632. */
  28633. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28634. private _setupDepthStencilTexture;
  28635. /**
  28636. * Creates a depth stencil texture.
  28637. * This is only available in WebGL 2 or with the depth texture extension available.
  28638. * @param size The size of face edge in the texture.
  28639. * @param options The options defining the texture.
  28640. * @returns The texture
  28641. */
  28642. createDepthStencilTexture(size: number | {
  28643. width: number;
  28644. height: number;
  28645. }, options: DepthTextureCreationOptions): InternalTexture;
  28646. /**
  28647. * Creates a depth stencil texture.
  28648. * This is only available in WebGL 2 or with the depth texture extension available.
  28649. * @param size The size of face edge in the texture.
  28650. * @param options The options defining the texture.
  28651. * @returns The texture
  28652. */
  28653. private _createDepthStencilTexture;
  28654. /**
  28655. * Creates a depth stencil cube texture.
  28656. * This is only available in WebGL 2.
  28657. * @param size The size of face edge in the cube texture.
  28658. * @param options The options defining the cube texture.
  28659. * @returns The cube texture
  28660. */
  28661. private _createDepthStencilCubeTexture;
  28662. /**
  28663. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28664. * @param renderTarget The render target to set the frame buffer for
  28665. */
  28666. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28667. /**
  28668. * Creates a new render target texture
  28669. * @param size defines the size of the texture
  28670. * @param options defines the options used to create the texture
  28671. * @returns a new render target texture stored in an InternalTexture
  28672. */
  28673. createRenderTargetTexture(size: number | {
  28674. width: number;
  28675. height: number;
  28676. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28677. /**
  28678. * Create a multi render target texture
  28679. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28680. * @param size defines the size of the texture
  28681. * @param options defines the creation options
  28682. * @returns the cube texture as an InternalTexture
  28683. */
  28684. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28685. private _setupFramebufferDepthAttachments;
  28686. /**
  28687. * Updates the sample count of a render target texture
  28688. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28689. * @param texture defines the texture to update
  28690. * @param samples defines the sample count to set
  28691. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28692. */
  28693. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28694. /**
  28695. * Update the sample count for a given multiple render target texture
  28696. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28697. * @param textures defines the textures to update
  28698. * @param samples defines the sample count to set
  28699. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28700. */
  28701. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28702. /** @hidden */
  28703. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28704. /** @hidden */
  28705. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28706. /** @hidden */
  28707. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28708. /** @hidden */
  28709. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28710. /**
  28711. * Creates a new render target cube texture
  28712. * @param size defines the size of the texture
  28713. * @param options defines the options used to create the texture
  28714. * @returns a new render target cube texture stored in an InternalTexture
  28715. */
  28716. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28717. /**
  28718. * Creates a cube texture
  28719. * @param rootUrl defines the url where the files to load is located
  28720. * @param scene defines the current scene
  28721. * @param files defines the list of files to load (1 per face)
  28722. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28723. * @param onLoad defines an optional callback raised when the texture is loaded
  28724. * @param onError defines an optional callback raised if there is an issue to load the texture
  28725. * @param format defines the format of the data
  28726. * @param forcedExtension defines the extension to use to pick the right loader
  28727. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28728. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28729. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28730. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28731. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28732. * @returns the cube texture as an InternalTexture
  28733. */
  28734. 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;
  28735. /**
  28736. * @hidden
  28737. */
  28738. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28739. /**
  28740. * Update a raw cube texture
  28741. * @param texture defines the texture to udpdate
  28742. * @param data defines the data to store
  28743. * @param format defines the data format
  28744. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28745. * @param invertY defines if data must be stored with Y axis inverted
  28746. * @param compression defines the compression used (null by default)
  28747. * @param level defines which level of the texture to update
  28748. */
  28749. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28750. /**
  28751. * Creates a new raw cube texture
  28752. * @param data defines the array of data to use to create each face
  28753. * @param size defines the size of the textures
  28754. * @param format defines the format of the data
  28755. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28756. * @param generateMipMaps defines if the engine should generate the mip levels
  28757. * @param invertY defines if data must be stored with Y axis inverted
  28758. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28759. * @param compression defines the compression used (null by default)
  28760. * @returns the cube texture as an InternalTexture
  28761. */
  28762. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28763. /**
  28764. * Creates a new raw cube texture from a specified url
  28765. * @param url defines the url where the data is located
  28766. * @param scene defines the current scene
  28767. * @param size defines the size of the textures
  28768. * @param format defines the format of the data
  28769. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28770. * @param noMipmap defines if the engine should avoid generating the mip levels
  28771. * @param callback defines a callback used to extract texture data from loaded data
  28772. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28773. * @param onLoad defines a callback called when texture is loaded
  28774. * @param onError defines a callback called if there is an error
  28775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28776. * @param invertY defines if data must be stored with Y axis inverted
  28777. * @returns the cube texture as an InternalTexture
  28778. */
  28779. 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;
  28780. /**
  28781. * Update a raw 3D texture
  28782. * @param texture defines the texture to update
  28783. * @param data defines the data to store
  28784. * @param format defines the data format
  28785. * @param invertY defines if data must be stored with Y axis inverted
  28786. * @param compression defines the used compression (can be null)
  28787. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28788. */
  28789. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28790. /**
  28791. * Creates a new raw 3D texture
  28792. * @param data defines the data used to create the texture
  28793. * @param width defines the width of the texture
  28794. * @param height defines the height of the texture
  28795. * @param depth defines the depth of the texture
  28796. * @param format defines the format of the texture
  28797. * @param generateMipMaps defines if the engine must generate mip levels
  28798. * @param invertY defines if data must be stored with Y axis inverted
  28799. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28800. * @param compression defines the compressed used (can be null)
  28801. * @param textureType defines the compressed used (can be null)
  28802. * @returns a new raw 3D texture (stored in an InternalTexture)
  28803. */
  28804. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28805. private _prepareWebGLTextureContinuation;
  28806. private _prepareWebGLTexture;
  28807. private _convertRGBtoRGBATextureData;
  28808. /** @hidden */
  28809. _releaseFramebufferObjects(texture: InternalTexture): void;
  28810. /** @hidden */
  28811. _releaseTexture(texture: InternalTexture): void;
  28812. private setProgram;
  28813. private _boundUniforms;
  28814. /**
  28815. * Binds an effect to the webGL context
  28816. * @param effect defines the effect to bind
  28817. */
  28818. bindSamplers(effect: Effect): void;
  28819. private _moveBoundTextureOnTop;
  28820. private _getCorrectTextureChannel;
  28821. private _linkTrackers;
  28822. private _removeDesignatedSlot;
  28823. private _activateCurrentTexture;
  28824. /** @hidden */
  28825. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28826. /** @hidden */
  28827. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28828. /**
  28829. * Sets a texture to the webGL context from a postprocess
  28830. * @param channel defines the channel to use
  28831. * @param postProcess defines the source postprocess
  28832. */
  28833. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28834. /**
  28835. * Binds the output of the passed in post process to the texture channel specified
  28836. * @param channel The channel the texture should be bound to
  28837. * @param postProcess The post process which's output should be bound
  28838. */
  28839. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28840. /**
  28841. * Unbind all textures from the webGL context
  28842. */
  28843. unbindAllTextures(): void;
  28844. /**
  28845. * Sets a texture to the according uniform.
  28846. * @param channel The texture channel
  28847. * @param uniform The uniform to set
  28848. * @param texture The texture to apply
  28849. */
  28850. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28851. /**
  28852. * Sets a depth stencil texture from a render target to the according uniform.
  28853. * @param channel The texture channel
  28854. * @param uniform The uniform to set
  28855. * @param texture The render target texture containing the depth stencil texture to apply
  28856. */
  28857. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28858. private _bindSamplerUniformToChannel;
  28859. private _getTextureWrapMode;
  28860. private _setTexture;
  28861. /**
  28862. * Sets an array of texture to the webGL context
  28863. * @param channel defines the channel where the texture array must be set
  28864. * @param uniform defines the associated uniform location
  28865. * @param textures defines the array of textures to bind
  28866. */
  28867. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28868. /** @hidden */
  28869. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28870. private _setTextureParameterFloat;
  28871. private _setTextureParameterInteger;
  28872. /**
  28873. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28874. * @param x defines the x coordinate of the rectangle where pixels must be read
  28875. * @param y defines the y coordinate of the rectangle where pixels must be read
  28876. * @param width defines the width of the rectangle where pixels must be read
  28877. * @param height defines the height of the rectangle where pixels must be read
  28878. * @returns a Uint8Array containing RGBA colors
  28879. */
  28880. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28881. /**
  28882. * Add an externaly attached data from its key.
  28883. * This method call will fail and return false, if such key already exists.
  28884. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28885. * @param key the unique key that identifies the data
  28886. * @param data the data object to associate to the key for this Engine instance
  28887. * @return true if no such key were already present and the data was added successfully, false otherwise
  28888. */
  28889. addExternalData<T>(key: string, data: T): boolean;
  28890. /**
  28891. * Get an externaly attached data from its key
  28892. * @param key the unique key that identifies the data
  28893. * @return the associated data, if present (can be null), or undefined if not present
  28894. */
  28895. getExternalData<T>(key: string): T;
  28896. /**
  28897. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28898. * @param key the unique key that identifies the data
  28899. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28900. * @return the associated data, can be null if the factory returned null.
  28901. */
  28902. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28903. /**
  28904. * Remove an externaly attached data from the Engine instance
  28905. * @param key the unique key that identifies the data
  28906. * @return true if the data was successfully removed, false if it doesn't exist
  28907. */
  28908. removeExternalData(key: string): boolean;
  28909. /**
  28910. * Unbind all vertex attributes from the webGL context
  28911. */
  28912. unbindAllAttributes(): void;
  28913. /**
  28914. * 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
  28915. */
  28916. releaseEffects(): void;
  28917. /**
  28918. * Dispose and release all associated resources
  28919. */
  28920. dispose(): void;
  28921. /**
  28922. * Display the loading screen
  28923. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28924. */
  28925. displayLoadingUI(): void;
  28926. /**
  28927. * Hide the loading screen
  28928. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28929. */
  28930. hideLoadingUI(): void;
  28931. /**
  28932. * Gets the current loading screen object
  28933. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28934. */
  28935. /**
  28936. * Sets the current loading screen object
  28937. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28938. */
  28939. loadingScreen: ILoadingScreen;
  28940. /**
  28941. * Sets the current loading screen text
  28942. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28943. */
  28944. loadingUIText: string;
  28945. /**
  28946. * Sets the current loading screen background color
  28947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28948. */
  28949. loadingUIBackgroundColor: string;
  28950. /**
  28951. * Attach a new callback raised when context lost event is fired
  28952. * @param callback defines the callback to call
  28953. */
  28954. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28955. /**
  28956. * Attach a new callback raised when context restored event is fired
  28957. * @param callback defines the callback to call
  28958. */
  28959. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28960. /**
  28961. * Gets the source code of the vertex shader associated with a specific webGL program
  28962. * @param program defines the program to use
  28963. * @returns a string containing the source code of the vertex shader associated with the program
  28964. */
  28965. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28966. /**
  28967. * Gets the source code of the fragment shader associated with a specific webGL program
  28968. * @param program defines the program to use
  28969. * @returns a string containing the source code of the fragment shader associated with the program
  28970. */
  28971. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28972. /**
  28973. * Get the current error code of the webGL context
  28974. * @returns the error code
  28975. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28976. */
  28977. getError(): number;
  28978. /**
  28979. * Gets the current framerate
  28980. * @returns a number representing the framerate
  28981. */
  28982. getFps(): number;
  28983. /**
  28984. * Gets the time spent between current and previous frame
  28985. * @returns a number representing the delta time in ms
  28986. */
  28987. getDeltaTime(): number;
  28988. private _measureFps;
  28989. /** @hidden */
  28990. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28991. private _canRenderToFloatFramebuffer;
  28992. private _canRenderToHalfFloatFramebuffer;
  28993. private _canRenderToFramebuffer;
  28994. /** @hidden */
  28995. _getWebGLTextureType(type: number): number;
  28996. private _getInternalFormat;
  28997. /** @hidden */
  28998. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28999. /** @hidden */
  29000. _getRGBAMultiSampleBufferFormat(type: number): number;
  29001. /** @hidden */
  29002. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  29003. /** @hidden */
  29004. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29005. private _partialLoadFile;
  29006. private _cascadeLoadFiles;
  29007. /**
  29008. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29009. * @returns true if the engine can be created
  29010. * @ignorenaming
  29011. */
  29012. static isSupported(): boolean;
  29013. }
  29014. }
  29015. declare module "babylonjs/Materials/effect" {
  29016. import { Observable } from "babylonjs/Misc/observable";
  29017. import { Nullable } from "babylonjs/types";
  29018. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29019. import { Engine } from "babylonjs/Engines/engine";
  29020. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29021. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29022. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29023. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29025. /**
  29026. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29027. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29028. */
  29029. export class EffectFallbacks {
  29030. private _defines;
  29031. private _currentRank;
  29032. private _maxRank;
  29033. private _mesh;
  29034. /**
  29035. * Removes the fallback from the bound mesh.
  29036. */
  29037. unBindMesh(): void;
  29038. /**
  29039. * Adds a fallback on the specified property.
  29040. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29041. * @param define The name of the define in the shader
  29042. */
  29043. addFallback(rank: number, define: string): void;
  29044. /**
  29045. * Sets the mesh to use CPU skinning when needing to fallback.
  29046. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29047. * @param mesh The mesh to use the fallbacks.
  29048. */
  29049. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29050. /**
  29051. * Checks to see if more fallbacks are still availible.
  29052. */
  29053. readonly isMoreFallbacks: boolean;
  29054. /**
  29055. * Removes the defines that shoould be removed when falling back.
  29056. * @param currentDefines defines the current define statements for the shader.
  29057. * @param effect defines the current effect we try to compile
  29058. * @returns The resulting defines with defines of the current rank removed.
  29059. */
  29060. reduce(currentDefines: string, effect: Effect): string;
  29061. }
  29062. /**
  29063. * Options to be used when creating an effect.
  29064. */
  29065. export class EffectCreationOptions {
  29066. /**
  29067. * Atrributes that will be used in the shader.
  29068. */
  29069. attributes: string[];
  29070. /**
  29071. * Uniform varible names that will be set in the shader.
  29072. */
  29073. uniformsNames: string[];
  29074. /**
  29075. * Uniform buffer varible names that will be set in the shader.
  29076. */
  29077. uniformBuffersNames: string[];
  29078. /**
  29079. * Sampler texture variable names that will be set in the shader.
  29080. */
  29081. samplers: string[];
  29082. /**
  29083. * Define statements that will be set in the shader.
  29084. */
  29085. defines: any;
  29086. /**
  29087. * Possible fallbacks for this effect to improve performance when needed.
  29088. */
  29089. fallbacks: Nullable<EffectFallbacks>;
  29090. /**
  29091. * Callback that will be called when the shader is compiled.
  29092. */
  29093. onCompiled: Nullable<(effect: Effect) => void>;
  29094. /**
  29095. * Callback that will be called if an error occurs during shader compilation.
  29096. */
  29097. onError: Nullable<(effect: Effect, errors: string) => void>;
  29098. /**
  29099. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29100. */
  29101. indexParameters: any;
  29102. /**
  29103. * Max number of lights that can be used in the shader.
  29104. */
  29105. maxSimultaneousLights: number;
  29106. /**
  29107. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29108. */
  29109. transformFeedbackVaryings: Nullable<string[]>;
  29110. }
  29111. /**
  29112. * Effect containing vertex and fragment shader that can be executed on an object.
  29113. */
  29114. export class Effect {
  29115. /**
  29116. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29117. */
  29118. static ShadersRepository: string;
  29119. /**
  29120. * Name of the effect.
  29121. */
  29122. name: any;
  29123. /**
  29124. * String container all the define statements that should be set on the shader.
  29125. */
  29126. defines: string;
  29127. /**
  29128. * Callback that will be called when the shader is compiled.
  29129. */
  29130. onCompiled: Nullable<(effect: Effect) => void>;
  29131. /**
  29132. * Callback that will be called if an error occurs during shader compilation.
  29133. */
  29134. onError: Nullable<(effect: Effect, errors: string) => void>;
  29135. /**
  29136. * Callback that will be called when effect is bound.
  29137. */
  29138. onBind: Nullable<(effect: Effect) => void>;
  29139. /**
  29140. * Unique ID of the effect.
  29141. */
  29142. uniqueId: number;
  29143. /**
  29144. * Observable that will be called when the shader is compiled.
  29145. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29146. */
  29147. onCompileObservable: Observable<Effect>;
  29148. /**
  29149. * Observable that will be called if an error occurs during shader compilation.
  29150. */
  29151. onErrorObservable: Observable<Effect>;
  29152. /** @hidden */
  29153. _onBindObservable: Nullable<Observable<Effect>>;
  29154. /**
  29155. * Observable that will be called when effect is bound.
  29156. */
  29157. readonly onBindObservable: Observable<Effect>;
  29158. /** @hidden */
  29159. _bonesComputationForcedToCPU: boolean;
  29160. private static _uniqueIdSeed;
  29161. private _engine;
  29162. private _uniformBuffersNames;
  29163. private _uniformsNames;
  29164. private _samplers;
  29165. private _isReady;
  29166. private _compilationError;
  29167. private _attributesNames;
  29168. private _attributes;
  29169. private _uniforms;
  29170. /**
  29171. * Key for the effect.
  29172. * @hidden
  29173. */
  29174. _key: string;
  29175. private _indexParameters;
  29176. private _fallbacks;
  29177. private _vertexSourceCode;
  29178. private _fragmentSourceCode;
  29179. private _vertexSourceCodeOverride;
  29180. private _fragmentSourceCodeOverride;
  29181. private _transformFeedbackVaryings;
  29182. /**
  29183. * Compiled shader to webGL program.
  29184. * @hidden
  29185. */
  29186. _program: WebGLProgram;
  29187. private _valueCache;
  29188. private static _baseCache;
  29189. /**
  29190. * Instantiates an effect.
  29191. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29192. * @param baseName Name of the effect.
  29193. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29194. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29195. * @param samplers List of sampler variables that will be passed to the shader.
  29196. * @param engine Engine to be used to render the effect
  29197. * @param defines Define statements to be added to the shader.
  29198. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29199. * @param onCompiled Callback that will be called when the shader is compiled.
  29200. * @param onError Callback that will be called if an error occurs during shader compilation.
  29201. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29202. */
  29203. 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);
  29204. /**
  29205. * Unique key for this effect
  29206. */
  29207. readonly key: string;
  29208. /**
  29209. * If the effect has been compiled and prepared.
  29210. * @returns if the effect is compiled and prepared.
  29211. */
  29212. isReady(): boolean;
  29213. /**
  29214. * The engine the effect was initialized with.
  29215. * @returns the engine.
  29216. */
  29217. getEngine(): Engine;
  29218. /**
  29219. * The compiled webGL program for the effect
  29220. * @returns the webGL program.
  29221. */
  29222. getProgram(): WebGLProgram;
  29223. /**
  29224. * The set of names of attribute variables for the shader.
  29225. * @returns An array of attribute names.
  29226. */
  29227. getAttributesNames(): string[];
  29228. /**
  29229. * Returns the attribute at the given index.
  29230. * @param index The index of the attribute.
  29231. * @returns The location of the attribute.
  29232. */
  29233. getAttributeLocation(index: number): number;
  29234. /**
  29235. * Returns the attribute based on the name of the variable.
  29236. * @param name of the attribute to look up.
  29237. * @returns the attribute location.
  29238. */
  29239. getAttributeLocationByName(name: string): number;
  29240. /**
  29241. * The number of attributes.
  29242. * @returns the numnber of attributes.
  29243. */
  29244. getAttributesCount(): number;
  29245. /**
  29246. * Gets the index of a uniform variable.
  29247. * @param uniformName of the uniform to look up.
  29248. * @returns the index.
  29249. */
  29250. getUniformIndex(uniformName: string): number;
  29251. /**
  29252. * Returns the attribute based on the name of the variable.
  29253. * @param uniformName of the uniform to look up.
  29254. * @returns the location of the uniform.
  29255. */
  29256. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29257. /**
  29258. * Returns an array of sampler variable names
  29259. * @returns The array of sampler variable neames.
  29260. */
  29261. getSamplers(): string[];
  29262. /**
  29263. * The error from the last compilation.
  29264. * @returns the error string.
  29265. */
  29266. getCompilationError(): string;
  29267. /**
  29268. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29269. * @param func The callback to be used.
  29270. */
  29271. executeWhenCompiled(func: (effect: Effect) => void): void;
  29272. private _checkIsReady;
  29273. /** @hidden */
  29274. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29275. /** @hidden */
  29276. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29277. /** @hidden */
  29278. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29279. private _processShaderConversion;
  29280. private _processIncludes;
  29281. private _processPrecision;
  29282. /**
  29283. * Recompiles the webGL program
  29284. * @param vertexSourceCode The source code for the vertex shader.
  29285. * @param fragmentSourceCode The source code for the fragment shader.
  29286. * @param onCompiled Callback called when completed.
  29287. * @param onError Callback called on error.
  29288. * @hidden
  29289. */
  29290. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29291. /**
  29292. * Gets the uniform locations of the the specified variable names
  29293. * @param names THe names of the variables to lookup.
  29294. * @returns Array of locations in the same order as variable names.
  29295. */
  29296. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29297. /**
  29298. * Prepares the effect
  29299. * @hidden
  29300. */
  29301. _prepareEffect(): void;
  29302. /**
  29303. * Checks if the effect is supported. (Must be called after compilation)
  29304. */
  29305. readonly isSupported: boolean;
  29306. /**
  29307. * Binds a texture to the engine to be used as output of the shader.
  29308. * @param channel Name of the output variable.
  29309. * @param texture Texture to bind.
  29310. * @hidden
  29311. */
  29312. _bindTexture(channel: string, texture: InternalTexture): void;
  29313. /**
  29314. * Sets a texture on the engine to be used in the shader.
  29315. * @param channel Name of the sampler variable.
  29316. * @param texture Texture to set.
  29317. */
  29318. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29319. /**
  29320. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29321. * @param channel Name of the sampler variable.
  29322. * @param texture Texture to set.
  29323. */
  29324. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29325. /**
  29326. * Sets an array of textures on the engine to be used in the shader.
  29327. * @param channel Name of the variable.
  29328. * @param textures Textures to set.
  29329. */
  29330. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29331. /**
  29332. * 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)
  29333. * @param channel Name of the sampler variable.
  29334. * @param postProcess Post process to get the input texture from.
  29335. */
  29336. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29337. /**
  29338. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29339. * 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)
  29340. * @param channel Name of the sampler variable.
  29341. * @param postProcess Post process to get the output texture from.
  29342. */
  29343. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29344. /** @hidden */
  29345. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29346. /** @hidden */
  29347. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29348. /** @hidden */
  29349. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29350. /** @hidden */
  29351. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29352. /**
  29353. * Binds a buffer to a uniform.
  29354. * @param buffer Buffer to bind.
  29355. * @param name Name of the uniform variable to bind to.
  29356. */
  29357. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29358. /**
  29359. * Binds block to a uniform.
  29360. * @param blockName Name of the block to bind.
  29361. * @param index Index to bind.
  29362. */
  29363. bindUniformBlock(blockName: string, index: number): void;
  29364. /**
  29365. * Sets an interger value on a uniform variable.
  29366. * @param uniformName Name of the variable.
  29367. * @param value Value to be set.
  29368. * @returns this effect.
  29369. */
  29370. setInt(uniformName: string, value: number): Effect;
  29371. /**
  29372. * Sets an int array on a uniform variable.
  29373. * @param uniformName Name of the variable.
  29374. * @param array array to be set.
  29375. * @returns this effect.
  29376. */
  29377. setIntArray(uniformName: string, array: Int32Array): Effect;
  29378. /**
  29379. * 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)
  29380. * @param uniformName Name of the variable.
  29381. * @param array array to be set.
  29382. * @returns this effect.
  29383. */
  29384. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29385. /**
  29386. * 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)
  29387. * @param uniformName Name of the variable.
  29388. * @param array array to be set.
  29389. * @returns this effect.
  29390. */
  29391. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29392. /**
  29393. * 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)
  29394. * @param uniformName Name of the variable.
  29395. * @param array array to be set.
  29396. * @returns this effect.
  29397. */
  29398. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29399. /**
  29400. * Sets an float array on a uniform variable.
  29401. * @param uniformName Name of the variable.
  29402. * @param array array to be set.
  29403. * @returns this effect.
  29404. */
  29405. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29406. /**
  29407. * 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)
  29408. * @param uniformName Name of the variable.
  29409. * @param array array to be set.
  29410. * @returns this effect.
  29411. */
  29412. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29413. /**
  29414. * 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)
  29415. * @param uniformName Name of the variable.
  29416. * @param array array to be set.
  29417. * @returns this effect.
  29418. */
  29419. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29420. /**
  29421. * 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)
  29422. * @param uniformName Name of the variable.
  29423. * @param array array to be set.
  29424. * @returns this effect.
  29425. */
  29426. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29427. /**
  29428. * Sets an array on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param array array to be set.
  29431. * @returns this effect.
  29432. */
  29433. setArray(uniformName: string, array: number[]): Effect;
  29434. /**
  29435. * 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)
  29436. * @param uniformName Name of the variable.
  29437. * @param array array to be set.
  29438. * @returns this effect.
  29439. */
  29440. setArray2(uniformName: string, array: number[]): Effect;
  29441. /**
  29442. * 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)
  29443. * @param uniformName Name of the variable.
  29444. * @param array array to be set.
  29445. * @returns this effect.
  29446. */
  29447. setArray3(uniformName: string, array: number[]): Effect;
  29448. /**
  29449. * 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)
  29450. * @param uniformName Name of the variable.
  29451. * @param array array to be set.
  29452. * @returns this effect.
  29453. */
  29454. setArray4(uniformName: string, array: number[]): Effect;
  29455. /**
  29456. * Sets matrices on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param matrices matrices to be set.
  29459. * @returns this effect.
  29460. */
  29461. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29462. /**
  29463. * Sets matrix on a uniform variable.
  29464. * @param uniformName Name of the variable.
  29465. * @param matrix matrix to be set.
  29466. * @returns this effect.
  29467. */
  29468. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29469. /**
  29470. * 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)
  29471. * @param uniformName Name of the variable.
  29472. * @param matrix matrix to be set.
  29473. * @returns this effect.
  29474. */
  29475. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29476. /**
  29477. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29478. * @param uniformName Name of the variable.
  29479. * @param matrix matrix to be set.
  29480. * @returns this effect.
  29481. */
  29482. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29483. /**
  29484. * Sets a float on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param value value to be set.
  29487. * @returns this effect.
  29488. */
  29489. setFloat(uniformName: string, value: number): Effect;
  29490. /**
  29491. * Sets a boolean on a uniform variable.
  29492. * @param uniformName Name of the variable.
  29493. * @param bool value to be set.
  29494. * @returns this effect.
  29495. */
  29496. setBool(uniformName: string, bool: boolean): Effect;
  29497. /**
  29498. * Sets a Vector2 on a uniform variable.
  29499. * @param uniformName Name of the variable.
  29500. * @param vector2 vector2 to be set.
  29501. * @returns this effect.
  29502. */
  29503. setVector2(uniformName: string, vector2: Vector2): Effect;
  29504. /**
  29505. * Sets a float2 on a uniform variable.
  29506. * @param uniformName Name of the variable.
  29507. * @param x First float in float2.
  29508. * @param y Second float in float2.
  29509. * @returns this effect.
  29510. */
  29511. setFloat2(uniformName: string, x: number, y: number): Effect;
  29512. /**
  29513. * Sets a Vector3 on a uniform variable.
  29514. * @param uniformName Name of the variable.
  29515. * @param vector3 Value to be set.
  29516. * @returns this effect.
  29517. */
  29518. setVector3(uniformName: string, vector3: Vector3): Effect;
  29519. /**
  29520. * Sets a float3 on a uniform variable.
  29521. * @param uniformName Name of the variable.
  29522. * @param x First float in float3.
  29523. * @param y Second float in float3.
  29524. * @param z Third float in float3.
  29525. * @returns this effect.
  29526. */
  29527. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29528. /**
  29529. * Sets a Vector4 on a uniform variable.
  29530. * @param uniformName Name of the variable.
  29531. * @param vector4 Value to be set.
  29532. * @returns this effect.
  29533. */
  29534. setVector4(uniformName: string, vector4: Vector4): Effect;
  29535. /**
  29536. * Sets a float4 on a uniform variable.
  29537. * @param uniformName Name of the variable.
  29538. * @param x First float in float4.
  29539. * @param y Second float in float4.
  29540. * @param z Third float in float4.
  29541. * @param w Fourth float in float4.
  29542. * @returns this effect.
  29543. */
  29544. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29545. /**
  29546. * Sets a Color3 on a uniform variable.
  29547. * @param uniformName Name of the variable.
  29548. * @param color3 Value to be set.
  29549. * @returns this effect.
  29550. */
  29551. setColor3(uniformName: string, color3: Color3): Effect;
  29552. /**
  29553. * Sets a Color4 on a uniform variable.
  29554. * @param uniformName Name of the variable.
  29555. * @param color3 Value to be set.
  29556. * @param alpha Alpha value to be set.
  29557. * @returns this effect.
  29558. */
  29559. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29560. /**
  29561. * Sets a Color4 on a uniform variable
  29562. * @param uniformName defines the name of the variable
  29563. * @param color4 defines the value to be set
  29564. * @returns this effect.
  29565. */
  29566. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29567. /**
  29568. * This function will add a new shader to the shader store
  29569. * @param name the name of the shader
  29570. * @param pixelShader optional pixel shader content
  29571. * @param vertexShader optional vertex shader content
  29572. */
  29573. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29574. /**
  29575. * Store of each shader (The can be looked up using effect.key)
  29576. */
  29577. static ShadersStore: {
  29578. [key: string]: string;
  29579. };
  29580. /**
  29581. * Store of each included file for a shader (The can be looked up using effect.key)
  29582. */
  29583. static IncludesShadersStore: {
  29584. [key: string]: string;
  29585. };
  29586. /**
  29587. * Resets the cache of effects.
  29588. */
  29589. static ResetCache(): void;
  29590. }
  29591. }
  29592. declare module "babylonjs/Materials/colorCurves" {
  29593. import { Effect } from "babylonjs/Materials/effect";
  29594. /**
  29595. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29596. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29597. * 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;
  29598. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29599. */
  29600. export class ColorCurves {
  29601. private _dirty;
  29602. private _tempColor;
  29603. private _globalCurve;
  29604. private _highlightsCurve;
  29605. private _midtonesCurve;
  29606. private _shadowsCurve;
  29607. private _positiveCurve;
  29608. private _negativeCurve;
  29609. private _globalHue;
  29610. private _globalDensity;
  29611. private _globalSaturation;
  29612. private _globalExposure;
  29613. /**
  29614. * Gets the global Hue value.
  29615. * 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).
  29616. */
  29617. /**
  29618. * Sets the global Hue value.
  29619. * 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).
  29620. */
  29621. globalHue: number;
  29622. /**
  29623. * Gets the global Density value.
  29624. * 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.
  29625. * Values less than zero provide a filter of opposite hue.
  29626. */
  29627. /**
  29628. * Sets the global Density value.
  29629. * 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.
  29630. * Values less than zero provide a filter of opposite hue.
  29631. */
  29632. globalDensity: number;
  29633. /**
  29634. * Gets the global Saturation value.
  29635. * 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.
  29636. */
  29637. /**
  29638. * Sets the global Saturation value.
  29639. * 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.
  29640. */
  29641. globalSaturation: number;
  29642. /**
  29643. * Gets the global Exposure value.
  29644. * 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.
  29645. */
  29646. /**
  29647. * Sets the global Exposure value.
  29648. * 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.
  29649. */
  29650. globalExposure: number;
  29651. private _highlightsHue;
  29652. private _highlightsDensity;
  29653. private _highlightsSaturation;
  29654. private _highlightsExposure;
  29655. /**
  29656. * Gets the highlights Hue value.
  29657. * 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).
  29658. */
  29659. /**
  29660. * Sets the highlights Hue value.
  29661. * 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).
  29662. */
  29663. highlightsHue: number;
  29664. /**
  29665. * Gets the highlights Density value.
  29666. * 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.
  29667. * Values less than zero provide a filter of opposite hue.
  29668. */
  29669. /**
  29670. * Sets the highlights Density value.
  29671. * 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.
  29672. * Values less than zero provide a filter of opposite hue.
  29673. */
  29674. highlightsDensity: number;
  29675. /**
  29676. * Gets the highlights Saturation value.
  29677. * 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.
  29678. */
  29679. /**
  29680. * Sets the highlights Saturation value.
  29681. * 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.
  29682. */
  29683. highlightsSaturation: number;
  29684. /**
  29685. * Gets the highlights Exposure value.
  29686. * 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.
  29687. */
  29688. /**
  29689. * Sets the highlights Exposure value.
  29690. * 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.
  29691. */
  29692. highlightsExposure: number;
  29693. private _midtonesHue;
  29694. private _midtonesDensity;
  29695. private _midtonesSaturation;
  29696. private _midtonesExposure;
  29697. /**
  29698. * Gets the midtones Hue value.
  29699. * 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).
  29700. */
  29701. /**
  29702. * Sets the midtones Hue value.
  29703. * 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).
  29704. */
  29705. midtonesHue: number;
  29706. /**
  29707. * Gets the midtones Density value.
  29708. * 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.
  29709. * Values less than zero provide a filter of opposite hue.
  29710. */
  29711. /**
  29712. * Sets the midtones Density value.
  29713. * 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.
  29714. * Values less than zero provide a filter of opposite hue.
  29715. */
  29716. midtonesDensity: number;
  29717. /**
  29718. * Gets the midtones Saturation value.
  29719. * 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.
  29720. */
  29721. /**
  29722. * Sets the midtones Saturation value.
  29723. * 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.
  29724. */
  29725. midtonesSaturation: number;
  29726. /**
  29727. * Gets the midtones Exposure value.
  29728. * 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.
  29729. */
  29730. /**
  29731. * Sets the midtones Exposure value.
  29732. * 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.
  29733. */
  29734. midtonesExposure: number;
  29735. private _shadowsHue;
  29736. private _shadowsDensity;
  29737. private _shadowsSaturation;
  29738. private _shadowsExposure;
  29739. /**
  29740. * Gets the shadows Hue value.
  29741. * 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).
  29742. */
  29743. /**
  29744. * Sets the shadows Hue value.
  29745. * 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).
  29746. */
  29747. shadowsHue: number;
  29748. /**
  29749. * Gets the shadows Density value.
  29750. * 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.
  29751. * Values less than zero provide a filter of opposite hue.
  29752. */
  29753. /**
  29754. * Sets the shadows Density value.
  29755. * 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.
  29756. * Values less than zero provide a filter of opposite hue.
  29757. */
  29758. shadowsDensity: number;
  29759. /**
  29760. * Gets the shadows Saturation value.
  29761. * 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.
  29762. */
  29763. /**
  29764. * Sets the shadows Saturation value.
  29765. * 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.
  29766. */
  29767. shadowsSaturation: number;
  29768. /**
  29769. * Gets the shadows Exposure value.
  29770. * 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.
  29771. */
  29772. /**
  29773. * Sets the shadows Exposure value.
  29774. * 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.
  29775. */
  29776. shadowsExposure: number;
  29777. /**
  29778. * Returns the class name
  29779. * @returns The class name
  29780. */
  29781. getClassName(): string;
  29782. /**
  29783. * Binds the color curves to the shader.
  29784. * @param colorCurves The color curve to bind
  29785. * @param effect The effect to bind to
  29786. * @param positiveUniform The positive uniform shader parameter
  29787. * @param neutralUniform The neutral uniform shader parameter
  29788. * @param negativeUniform The negative uniform shader parameter
  29789. */
  29790. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29791. /**
  29792. * Prepare the list of uniforms associated with the ColorCurves effects.
  29793. * @param uniformsList The list of uniforms used in the effect
  29794. */
  29795. static PrepareUniforms(uniformsList: string[]): void;
  29796. /**
  29797. * Returns color grading data based on a hue, density, saturation and exposure value.
  29798. * @param filterHue The hue of the color filter.
  29799. * @param filterDensity The density of the color filter.
  29800. * @param saturation The saturation.
  29801. * @param exposure The exposure.
  29802. * @param result The result data container.
  29803. */
  29804. private getColorGradingDataToRef;
  29805. /**
  29806. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29807. * @param value The input slider value in range [-100,100].
  29808. * @returns Adjusted value.
  29809. */
  29810. private static applyColorGradingSliderNonlinear;
  29811. /**
  29812. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29813. * @param hue The hue (H) input.
  29814. * @param saturation The saturation (S) input.
  29815. * @param brightness The brightness (B) input.
  29816. * @result An RGBA color represented as Vector4.
  29817. */
  29818. private static fromHSBToRef;
  29819. /**
  29820. * Returns a value clamped between min and max
  29821. * @param value The value to clamp
  29822. * @param min The minimum of value
  29823. * @param max The maximum of value
  29824. * @returns The clamped value.
  29825. */
  29826. private static clamp;
  29827. /**
  29828. * Clones the current color curve instance.
  29829. * @return The cloned curves
  29830. */
  29831. clone(): ColorCurves;
  29832. /**
  29833. * Serializes the current color curve instance to a json representation.
  29834. * @return a JSON representation
  29835. */
  29836. serialize(): any;
  29837. /**
  29838. * Parses the color curve from a json representation.
  29839. * @param source the JSON source to parse
  29840. * @return The parsed curves
  29841. */
  29842. static Parse(source: any): ColorCurves;
  29843. }
  29844. }
  29845. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29846. import { Observable } from "babylonjs/Misc/observable";
  29847. import { Nullable } from "babylonjs/types";
  29848. import { Color4 } from "babylonjs/Maths/math";
  29849. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29850. import { Effect } from "babylonjs/Materials/effect";
  29851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29852. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29853. /**
  29854. * Interface to follow in your material defines to integrate easily the
  29855. * Image proccessing functions.
  29856. * @hidden
  29857. */
  29858. export interface IImageProcessingConfigurationDefines {
  29859. IMAGEPROCESSING: boolean;
  29860. VIGNETTE: boolean;
  29861. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29862. VIGNETTEBLENDMODEOPAQUE: boolean;
  29863. TONEMAPPING: boolean;
  29864. TONEMAPPING_ACES: boolean;
  29865. CONTRAST: boolean;
  29866. EXPOSURE: boolean;
  29867. COLORCURVES: boolean;
  29868. COLORGRADING: boolean;
  29869. COLORGRADING3D: boolean;
  29870. SAMPLER3DGREENDEPTH: boolean;
  29871. SAMPLER3DBGRMAP: boolean;
  29872. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29873. }
  29874. /**
  29875. * @hidden
  29876. */
  29877. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29878. IMAGEPROCESSING: boolean;
  29879. VIGNETTE: boolean;
  29880. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29881. VIGNETTEBLENDMODEOPAQUE: boolean;
  29882. TONEMAPPING: boolean;
  29883. TONEMAPPING_ACES: boolean;
  29884. CONTRAST: boolean;
  29885. COLORCURVES: boolean;
  29886. COLORGRADING: boolean;
  29887. COLORGRADING3D: boolean;
  29888. SAMPLER3DGREENDEPTH: boolean;
  29889. SAMPLER3DBGRMAP: boolean;
  29890. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29891. EXPOSURE: boolean;
  29892. constructor();
  29893. }
  29894. /**
  29895. * This groups together the common properties used for image processing either in direct forward pass
  29896. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29897. * or not.
  29898. */
  29899. export class ImageProcessingConfiguration {
  29900. /**
  29901. * Default tone mapping applied in BabylonJS.
  29902. */
  29903. static readonly TONEMAPPING_STANDARD: number;
  29904. /**
  29905. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29906. * to other engines rendering to increase portability.
  29907. */
  29908. static readonly TONEMAPPING_ACES: number;
  29909. /**
  29910. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29911. */
  29912. colorCurves: Nullable<ColorCurves>;
  29913. private _colorCurvesEnabled;
  29914. /**
  29915. * Gets wether the color curves effect is enabled.
  29916. */
  29917. /**
  29918. * Sets wether the color curves effect is enabled.
  29919. */
  29920. colorCurvesEnabled: boolean;
  29921. private _colorGradingTexture;
  29922. /**
  29923. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29924. */
  29925. /**
  29926. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29927. */
  29928. colorGradingTexture: Nullable<BaseTexture>;
  29929. private _colorGradingEnabled;
  29930. /**
  29931. * Gets wether the color grading effect is enabled.
  29932. */
  29933. /**
  29934. * Sets wether the color grading effect is enabled.
  29935. */
  29936. colorGradingEnabled: boolean;
  29937. private _colorGradingWithGreenDepth;
  29938. /**
  29939. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29940. */
  29941. /**
  29942. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29943. */
  29944. colorGradingWithGreenDepth: boolean;
  29945. private _colorGradingBGR;
  29946. /**
  29947. * Gets wether the color grading texture contains BGR values.
  29948. */
  29949. /**
  29950. * Sets wether the color grading texture contains BGR values.
  29951. */
  29952. colorGradingBGR: boolean;
  29953. /** @hidden */
  29954. _exposure: number;
  29955. /**
  29956. * Gets the Exposure used in the effect.
  29957. */
  29958. /**
  29959. * Sets the Exposure used in the effect.
  29960. */
  29961. exposure: number;
  29962. private _toneMappingEnabled;
  29963. /**
  29964. * Gets wether the tone mapping effect is enabled.
  29965. */
  29966. /**
  29967. * Sets wether the tone mapping effect is enabled.
  29968. */
  29969. toneMappingEnabled: boolean;
  29970. private _toneMappingType;
  29971. /**
  29972. * Gets the type of tone mapping effect.
  29973. */
  29974. /**
  29975. * Sets the type of tone mapping effect used in BabylonJS.
  29976. */
  29977. toneMappingType: number;
  29978. protected _contrast: number;
  29979. /**
  29980. * Gets the contrast used in the effect.
  29981. */
  29982. /**
  29983. * Sets the contrast used in the effect.
  29984. */
  29985. contrast: number;
  29986. /**
  29987. * Vignette stretch size.
  29988. */
  29989. vignetteStretch: number;
  29990. /**
  29991. * Vignette centre X Offset.
  29992. */
  29993. vignetteCentreX: number;
  29994. /**
  29995. * Vignette centre Y Offset.
  29996. */
  29997. vignetteCentreY: number;
  29998. /**
  29999. * Vignette weight or intensity of the vignette effect.
  30000. */
  30001. vignetteWeight: number;
  30002. /**
  30003. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30004. * if vignetteEnabled is set to true.
  30005. */
  30006. vignetteColor: Color4;
  30007. /**
  30008. * Camera field of view used by the Vignette effect.
  30009. */
  30010. vignetteCameraFov: number;
  30011. private _vignetteBlendMode;
  30012. /**
  30013. * Gets the vignette blend mode allowing different kind of effect.
  30014. */
  30015. /**
  30016. * Sets the vignette blend mode allowing different kind of effect.
  30017. */
  30018. vignetteBlendMode: number;
  30019. private _vignetteEnabled;
  30020. /**
  30021. * Gets wether the vignette effect is enabled.
  30022. */
  30023. /**
  30024. * Sets wether the vignette effect is enabled.
  30025. */
  30026. vignetteEnabled: boolean;
  30027. private _applyByPostProcess;
  30028. /**
  30029. * Gets wether the image processing is applied through a post process or not.
  30030. */
  30031. /**
  30032. * Sets wether the image processing is applied through a post process or not.
  30033. */
  30034. applyByPostProcess: boolean;
  30035. private _isEnabled;
  30036. /**
  30037. * Gets wether the image processing is enabled or not.
  30038. */
  30039. /**
  30040. * Sets wether the image processing is enabled or not.
  30041. */
  30042. isEnabled: boolean;
  30043. /**
  30044. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30045. */
  30046. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30047. /**
  30048. * Method called each time the image processing information changes requires to recompile the effect.
  30049. */
  30050. protected _updateParameters(): void;
  30051. /**
  30052. * Gets the current class name.
  30053. * @return "ImageProcessingConfiguration"
  30054. */
  30055. getClassName(): string;
  30056. /**
  30057. * Prepare the list of uniforms associated with the Image Processing effects.
  30058. * @param uniforms The list of uniforms used in the effect
  30059. * @param defines the list of defines currently in use
  30060. */
  30061. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30062. /**
  30063. * Prepare the list of samplers associated with the Image Processing effects.
  30064. * @param samplersList The list of uniforms used in the effect
  30065. * @param defines the list of defines currently in use
  30066. */
  30067. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30068. /**
  30069. * Prepare the list of defines associated to the shader.
  30070. * @param defines the list of defines to complete
  30071. * @param forPostProcess Define if we are currently in post process mode or not
  30072. */
  30073. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30074. /**
  30075. * Returns true if all the image processing information are ready.
  30076. * @returns True if ready, otherwise, false
  30077. */
  30078. isReady(): boolean;
  30079. /**
  30080. * Binds the image processing to the shader.
  30081. * @param effect The effect to bind to
  30082. * @param aspectRatio Define the current aspect ratio of the effect
  30083. */
  30084. bind(effect: Effect, aspectRatio?: number): void;
  30085. /**
  30086. * Clones the current image processing instance.
  30087. * @return The cloned image processing
  30088. */
  30089. clone(): ImageProcessingConfiguration;
  30090. /**
  30091. * Serializes the current image processing instance to a json representation.
  30092. * @return a JSON representation
  30093. */
  30094. serialize(): any;
  30095. /**
  30096. * Parses the image processing from a json representation.
  30097. * @param source the JSON source to parse
  30098. * @return The parsed image processing
  30099. */
  30100. static Parse(source: any): ImageProcessingConfiguration;
  30101. private static _VIGNETTEMODE_MULTIPLY;
  30102. private static _VIGNETTEMODE_OPAQUE;
  30103. /**
  30104. * Used to apply the vignette as a mix with the pixel color.
  30105. */
  30106. static readonly VIGNETTEMODE_MULTIPLY: number;
  30107. /**
  30108. * Used to apply the vignette as a replacement of the pixel color.
  30109. */
  30110. static readonly VIGNETTEMODE_OPAQUE: number;
  30111. }
  30112. }
  30113. declare module "babylonjs/Materials/fresnelParameters" {
  30114. import { Color3 } from "babylonjs/Maths/math";
  30115. /**
  30116. * This represents all the required information to add a fresnel effect on a material:
  30117. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30118. */
  30119. export class FresnelParameters {
  30120. private _isEnabled;
  30121. /**
  30122. * Define if the fresnel effect is enable or not.
  30123. */
  30124. isEnabled: boolean;
  30125. /**
  30126. * Define the color used on edges (grazing angle)
  30127. */
  30128. leftColor: Color3;
  30129. /**
  30130. * Define the color used on center
  30131. */
  30132. rightColor: Color3;
  30133. /**
  30134. * Define bias applied to computed fresnel term
  30135. */
  30136. bias: number;
  30137. /**
  30138. * Defined the power exponent applied to fresnel term
  30139. */
  30140. power: number;
  30141. /**
  30142. * Clones the current fresnel and its valuues
  30143. * @returns a clone fresnel configuration
  30144. */
  30145. clone(): FresnelParameters;
  30146. /**
  30147. * Serializes the current fresnel parameters to a JSON representation.
  30148. * @return the JSON serialization
  30149. */
  30150. serialize(): any;
  30151. /**
  30152. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30153. * @param parsedFresnelParameters Define the JSON representation
  30154. * @returns the parsed parameters
  30155. */
  30156. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30157. }
  30158. }
  30159. declare module "babylonjs/Misc/decorators" {
  30160. import { Nullable } from "babylonjs/types";
  30161. import { Scene } from "babylonjs/scene";
  30162. import { IAnimatable } from "babylonjs/Misc/tools";
  30163. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30164. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30165. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30166. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30167. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30168. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30169. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30170. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30171. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30172. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30173. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30174. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30175. /**
  30176. * Decorator used to define property that can be serialized as reference to a camera
  30177. * @param sourceName defines the name of the property to decorate
  30178. */
  30179. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30180. /**
  30181. * Class used to help serialization objects
  30182. */
  30183. export class SerializationHelper {
  30184. /** hidden */
  30185. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30186. /** hidden */
  30187. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30188. /** hidden */
  30189. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30190. /** hidden */
  30191. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30192. /**
  30193. * Appends the serialized animations from the source animations
  30194. * @param source Source containing the animations
  30195. * @param destination Target to store the animations
  30196. */
  30197. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30198. /**
  30199. * Static function used to serialized a specific entity
  30200. * @param entity defines the entity to serialize
  30201. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30202. * @returns a JSON compatible object representing the serialization of the entity
  30203. */
  30204. static Serialize<T>(entity: T, serializationObject?: any): any;
  30205. /**
  30206. * Creates a new entity from a serialization data object
  30207. * @param creationFunction defines a function used to instanciated the new entity
  30208. * @param source defines the source serialization data
  30209. * @param scene defines the hosting scene
  30210. * @param rootUrl defines the root url for resources
  30211. * @returns a new entity
  30212. */
  30213. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30214. /**
  30215. * Clones an object
  30216. * @param creationFunction defines the function used to instanciate the new object
  30217. * @param source defines the source object
  30218. * @returns the cloned object
  30219. */
  30220. static Clone<T>(creationFunction: () => T, source: T): T;
  30221. /**
  30222. * Instanciates a new object based on a source one (some data will be shared between both object)
  30223. * @param creationFunction defines the function used to instanciate the new object
  30224. * @param source defines the source object
  30225. * @returns the new object
  30226. */
  30227. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30228. }
  30229. }
  30230. declare module "babylonjs/Cameras/camera" {
  30231. import { SmartArray } from "babylonjs/Misc/smartArray";
  30232. import { Observable } from "babylonjs/Misc/observable";
  30233. import { Nullable } from "babylonjs/types";
  30234. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30235. import { Scene } from "babylonjs/scene";
  30236. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30237. import { Node } from "babylonjs/node";
  30238. import { Mesh } from "babylonjs/Meshes/mesh";
  30239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30240. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30241. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30243. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30244. import { Ray } from "babylonjs/Culling/ray";
  30245. /**
  30246. * This is the base class of all the camera used in the application.
  30247. * @see http://doc.babylonjs.com/features/cameras
  30248. */
  30249. export class Camera extends Node {
  30250. /** @hidden */
  30251. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30252. /**
  30253. * This is the default projection mode used by the cameras.
  30254. * It helps recreating a feeling of perspective and better appreciate depth.
  30255. * This is the best way to simulate real life cameras.
  30256. */
  30257. static readonly PERSPECTIVE_CAMERA: number;
  30258. /**
  30259. * This helps creating camera with an orthographic mode.
  30260. * 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.
  30261. */
  30262. static readonly ORTHOGRAPHIC_CAMERA: number;
  30263. /**
  30264. * This is the default FOV mode for perspective cameras.
  30265. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30266. */
  30267. static readonly FOVMODE_VERTICAL_FIXED: number;
  30268. /**
  30269. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30270. */
  30271. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30272. /**
  30273. * This specifies ther is no need for a camera rig.
  30274. * Basically only one eye is rendered corresponding to the camera.
  30275. */
  30276. static readonly RIG_MODE_NONE: number;
  30277. /**
  30278. * Simulates a camera Rig with one blue eye and one red eye.
  30279. * This can be use with 3d blue and red glasses.
  30280. */
  30281. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30282. /**
  30283. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30284. */
  30285. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30286. /**
  30287. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30288. */
  30289. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30290. /**
  30291. * Defines that both eyes of the camera will be rendered over under each other.
  30292. */
  30293. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30294. /**
  30295. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30296. */
  30297. static readonly RIG_MODE_VR: number;
  30298. /**
  30299. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30300. */
  30301. static readonly RIG_MODE_WEBVR: number;
  30302. /**
  30303. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30304. */
  30305. static readonly RIG_MODE_CUSTOM: number;
  30306. /**
  30307. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30308. */
  30309. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30310. /**
  30311. * @hidden
  30312. * Might be removed once multiview will be a thing
  30313. */
  30314. static UseAlternateWebVRRendering: boolean;
  30315. /**
  30316. * Define the input manager associated with the camera.
  30317. */
  30318. inputs: CameraInputsManager<Camera>;
  30319. /** @hidden */
  30320. _position: Vector3;
  30321. /**
  30322. * Define the current local position of the camera in the scene
  30323. */
  30324. position: Vector3;
  30325. /**
  30326. * The vector the camera should consider as up.
  30327. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30328. */
  30329. upVector: Vector3;
  30330. /**
  30331. * Define the current limit on the left side for an orthographic camera
  30332. * In scene unit
  30333. */
  30334. orthoLeft: Nullable<number>;
  30335. /**
  30336. * Define the current limit on the right side for an orthographic camera
  30337. * In scene unit
  30338. */
  30339. orthoRight: Nullable<number>;
  30340. /**
  30341. * Define the current limit on the bottom side for an orthographic camera
  30342. * In scene unit
  30343. */
  30344. orthoBottom: Nullable<number>;
  30345. /**
  30346. * Define the current limit on the top side for an orthographic camera
  30347. * In scene unit
  30348. */
  30349. orthoTop: Nullable<number>;
  30350. /**
  30351. * Field Of View is set in Radians. (default is 0.8)
  30352. */
  30353. fov: number;
  30354. /**
  30355. * Define the minimum distance the camera can see from.
  30356. * This is important to note that the depth buffer are not infinite and the closer it starts
  30357. * the more your scene might encounter depth fighting issue.
  30358. */
  30359. minZ: number;
  30360. /**
  30361. * Define the maximum distance the camera can see to.
  30362. * This is important to note that the depth buffer are not infinite and the further it end
  30363. * the more your scene might encounter depth fighting issue.
  30364. */
  30365. maxZ: number;
  30366. /**
  30367. * Define the default inertia of the camera.
  30368. * This helps giving a smooth feeling to the camera movement.
  30369. */
  30370. inertia: number;
  30371. /**
  30372. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30373. */
  30374. mode: number;
  30375. /**
  30376. * Define wether the camera is intermediate.
  30377. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30378. */
  30379. isIntermediate: boolean;
  30380. /**
  30381. * Define the viewport of the camera.
  30382. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30383. */
  30384. viewport: Viewport;
  30385. /**
  30386. * Restricts the camera to viewing objects with the same layerMask.
  30387. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30388. */
  30389. layerMask: number;
  30390. /**
  30391. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30392. */
  30393. fovMode: number;
  30394. /**
  30395. * Rig mode of the camera.
  30396. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30397. * This is normally controlled byt the camera themselves as internal use.
  30398. */
  30399. cameraRigMode: number;
  30400. /**
  30401. * Defines the distance between both "eyes" in case of a RIG
  30402. */
  30403. interaxialDistance: number;
  30404. /**
  30405. * Defines if stereoscopic rendering is done side by side or over under.
  30406. */
  30407. isStereoscopicSideBySide: boolean;
  30408. /**
  30409. * 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
  30410. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30411. * else in the scene.
  30412. */
  30413. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30414. /**
  30415. * When set, the camera will render to this render target instead of the default canvas
  30416. */
  30417. outputRenderTarget: Nullable<RenderTargetTexture>;
  30418. /**
  30419. * Observable triggered when the camera view matrix has changed.
  30420. */
  30421. onViewMatrixChangedObservable: Observable<Camera>;
  30422. /**
  30423. * Observable triggered when the camera Projection matrix has changed.
  30424. */
  30425. onProjectionMatrixChangedObservable: Observable<Camera>;
  30426. /**
  30427. * Observable triggered when the inputs have been processed.
  30428. */
  30429. onAfterCheckInputsObservable: Observable<Camera>;
  30430. /**
  30431. * Observable triggered when reset has been called and applied to the camera.
  30432. */
  30433. onRestoreStateObservable: Observable<Camera>;
  30434. /** @hidden */
  30435. _cameraRigParams: any;
  30436. /** @hidden */
  30437. _rigCameras: Camera[];
  30438. /** @hidden */
  30439. _rigPostProcess: Nullable<PostProcess>;
  30440. protected _webvrViewMatrix: Matrix;
  30441. /** @hidden */
  30442. _skipRendering: boolean;
  30443. /** @hidden */
  30444. _alternateCamera: Camera;
  30445. /** @hidden */
  30446. _projectionMatrix: Matrix;
  30447. /** @hidden */
  30448. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30449. /** @hidden */
  30450. _activeMeshes: SmartArray<AbstractMesh>;
  30451. protected _globalPosition: Vector3;
  30452. /** hidden */
  30453. _computedViewMatrix: Matrix;
  30454. private _doNotComputeProjectionMatrix;
  30455. private _transformMatrix;
  30456. private _frustumPlanes;
  30457. private _refreshFrustumPlanes;
  30458. private _storedFov;
  30459. private _stateStored;
  30460. /**
  30461. * Instantiates a new camera object.
  30462. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30463. * @see http://doc.babylonjs.com/features/cameras
  30464. * @param name Defines the name of the camera in the scene
  30465. * @param position Defines the position of the camera
  30466. * @param scene Defines the scene the camera belongs too
  30467. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30468. */
  30469. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30470. /**
  30471. * Store current camera state (fov, position, etc..)
  30472. * @returns the camera
  30473. */
  30474. storeState(): Camera;
  30475. /**
  30476. * Restores the camera state values if it has been stored. You must call storeState() first
  30477. */
  30478. protected _restoreStateValues(): boolean;
  30479. /**
  30480. * Restored camera state. You must call storeState() first.
  30481. * @returns true if restored and false otherwise
  30482. */
  30483. restoreState(): boolean;
  30484. /**
  30485. * Gets the class name of the camera.
  30486. * @returns the class name
  30487. */
  30488. getClassName(): string;
  30489. /** @hidden */
  30490. readonly _isCamera: boolean;
  30491. /**
  30492. * Gets a string representation of the camera useful for debug purpose.
  30493. * @param fullDetails Defines that a more verboe level of logging is required
  30494. * @returns the string representation
  30495. */
  30496. toString(fullDetails?: boolean): string;
  30497. /**
  30498. * Gets the current world space position of the camera.
  30499. */
  30500. readonly globalPosition: Vector3;
  30501. /**
  30502. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30503. * @returns the active meshe list
  30504. */
  30505. getActiveMeshes(): SmartArray<AbstractMesh>;
  30506. /**
  30507. * Check wether a mesh is part of the current active mesh list of the camera
  30508. * @param mesh Defines the mesh to check
  30509. * @returns true if active, false otherwise
  30510. */
  30511. isActiveMesh(mesh: Mesh): boolean;
  30512. /**
  30513. * Is this camera ready to be used/rendered
  30514. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30515. * @return true if the camera is ready
  30516. */
  30517. isReady(completeCheck?: boolean): boolean;
  30518. /** @hidden */
  30519. _initCache(): void;
  30520. /** @hidden */
  30521. _updateCache(ignoreParentClass?: boolean): void;
  30522. /** @hidden */
  30523. _isSynchronized(): boolean;
  30524. /** @hidden */
  30525. _isSynchronizedViewMatrix(): boolean;
  30526. /** @hidden */
  30527. _isSynchronizedProjectionMatrix(): boolean;
  30528. /**
  30529. * Attach the input controls to a specific dom element to get the input from.
  30530. * @param element Defines the element the controls should be listened from
  30531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30532. */
  30533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30534. /**
  30535. * Detach the current controls from the specified dom element.
  30536. * @param element Defines the element to stop listening the inputs from
  30537. */
  30538. detachControl(element: HTMLElement): void;
  30539. /**
  30540. * Update the camera state according to the different inputs gathered during the frame.
  30541. */
  30542. update(): void;
  30543. /** @hidden */
  30544. _checkInputs(): void;
  30545. /** @hidden */
  30546. readonly rigCameras: Camera[];
  30547. /**
  30548. * Gets the post process used by the rig cameras
  30549. */
  30550. readonly rigPostProcess: Nullable<PostProcess>;
  30551. /**
  30552. * Internal, gets the first post proces.
  30553. * @returns the first post process to be run on this camera.
  30554. */
  30555. _getFirstPostProcess(): Nullable<PostProcess>;
  30556. private _cascadePostProcessesToRigCams;
  30557. /**
  30558. * Attach a post process to the camera.
  30559. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30560. * @param postProcess The post process to attach to the camera
  30561. * @param insertAt The position of the post process in case several of them are in use in the scene
  30562. * @returns the position the post process has been inserted at
  30563. */
  30564. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30565. /**
  30566. * Detach a post process to the camera.
  30567. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30568. * @param postProcess The post process to detach from the camera
  30569. */
  30570. detachPostProcess(postProcess: PostProcess): void;
  30571. /**
  30572. * Gets the current world matrix of the camera
  30573. */
  30574. getWorldMatrix(): Matrix;
  30575. /** @hidden */
  30576. _getViewMatrix(): Matrix;
  30577. /**
  30578. * Gets the current view matrix of the camera.
  30579. * @param force forces the camera to recompute the matrix without looking at the cached state
  30580. * @returns the view matrix
  30581. */
  30582. getViewMatrix(force?: boolean): Matrix;
  30583. /**
  30584. * Freeze the projection matrix.
  30585. * It will prevent the cache check of the camera projection compute and can speed up perf
  30586. * if no parameter of the camera are meant to change
  30587. * @param projection Defines manually a projection if necessary
  30588. */
  30589. freezeProjectionMatrix(projection?: Matrix): void;
  30590. /**
  30591. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30592. */
  30593. unfreezeProjectionMatrix(): void;
  30594. /**
  30595. * Gets the current projection matrix of the camera.
  30596. * @param force forces the camera to recompute the matrix without looking at the cached state
  30597. * @returns the projection matrix
  30598. */
  30599. getProjectionMatrix(force?: boolean): Matrix;
  30600. /**
  30601. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30602. * @returns a Matrix
  30603. */
  30604. getTransformationMatrix(): Matrix;
  30605. private _updateFrustumPlanes;
  30606. /**
  30607. * Checks if a cullable object (mesh...) is in the camera frustum
  30608. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30609. * @param target The object to check
  30610. * @returns true if the object is in frustum otherwise false
  30611. */
  30612. isInFrustum(target: ICullable): boolean;
  30613. /**
  30614. * Checks if a cullable object (mesh...) is in the camera frustum
  30615. * Unlike isInFrustum this cheks the full bounding box
  30616. * @param target The object to check
  30617. * @returns true if the object is in frustum otherwise false
  30618. */
  30619. isCompletelyInFrustum(target: ICullable): boolean;
  30620. /**
  30621. * Gets a ray in the forward direction from the camera.
  30622. * @param length Defines the length of the ray to create
  30623. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30624. * @param origin Defines the start point of the ray which defaults to the camera position
  30625. * @returns the forward ray
  30626. */
  30627. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30628. /**
  30629. * Releases resources associated with this node.
  30630. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30631. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30632. */
  30633. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30634. /** @hidden */
  30635. _isLeftCamera: boolean;
  30636. /**
  30637. * Gets the left camera of a rig setup in case of Rigged Camera
  30638. */
  30639. readonly isLeftCamera: boolean;
  30640. /** @hidden */
  30641. _isRightCamera: boolean;
  30642. /**
  30643. * Gets the right camera of a rig setup in case of Rigged Camera
  30644. */
  30645. readonly isRightCamera: boolean;
  30646. /**
  30647. * Gets the left camera of a rig setup in case of Rigged Camera
  30648. */
  30649. readonly leftCamera: Nullable<FreeCamera>;
  30650. /**
  30651. * Gets the right camera of a rig setup in case of Rigged Camera
  30652. */
  30653. readonly rightCamera: Nullable<FreeCamera>;
  30654. /**
  30655. * Gets the left camera target of a rig setup in case of Rigged Camera
  30656. * @returns the target position
  30657. */
  30658. getLeftTarget(): Nullable<Vector3>;
  30659. /**
  30660. * Gets the right camera target of a rig setup in case of Rigged Camera
  30661. * @returns the target position
  30662. */
  30663. getRightTarget(): Nullable<Vector3>;
  30664. /**
  30665. * @hidden
  30666. */
  30667. setCameraRigMode(mode: number, rigParams: any): void;
  30668. /** @hidden */
  30669. static _setStereoscopicRigMode(camera: Camera): void;
  30670. /** @hidden */
  30671. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30672. /** @hidden */
  30673. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30674. /** @hidden */
  30675. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30676. /** @hidden */
  30677. _getVRProjectionMatrix(): Matrix;
  30678. protected _updateCameraRotationMatrix(): void;
  30679. protected _updateWebVRCameraRotationMatrix(): void;
  30680. /**
  30681. * This function MUST be overwritten by the different WebVR cameras available.
  30682. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30683. * @hidden
  30684. */
  30685. _getWebVRProjectionMatrix(): Matrix;
  30686. /**
  30687. * This function MUST be overwritten by the different WebVR cameras available.
  30688. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30689. * @hidden
  30690. */
  30691. _getWebVRViewMatrix(): Matrix;
  30692. /** @hidden */
  30693. setCameraRigParameter(name: string, value: any): void;
  30694. /**
  30695. * needs to be overridden by children so sub has required properties to be copied
  30696. * @hidden
  30697. */
  30698. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30699. /**
  30700. * May need to be overridden by children
  30701. * @hidden
  30702. */
  30703. _updateRigCameras(): void;
  30704. /** @hidden */
  30705. _setupInputs(): void;
  30706. /**
  30707. * Serialiaze the camera setup to a json represention
  30708. * @returns the JSON representation
  30709. */
  30710. serialize(): any;
  30711. /**
  30712. * Clones the current camera.
  30713. * @param name The cloned camera name
  30714. * @returns the cloned camera
  30715. */
  30716. clone(name: string): Camera;
  30717. /**
  30718. * Gets the direction of the camera relative to a given local axis.
  30719. * @param localAxis Defines the reference axis to provide a relative direction.
  30720. * @return the direction
  30721. */
  30722. getDirection(localAxis: Vector3): Vector3;
  30723. /**
  30724. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30725. * @param localAxis Defines the reference axis to provide a relative direction.
  30726. * @param result Defines the vector to store the result in
  30727. */
  30728. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30729. /**
  30730. * Gets a camera constructor for a given camera type
  30731. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30732. * @param name The name of the camera the result will be able to instantiate
  30733. * @param scene The scene the result will construct the camera in
  30734. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30735. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30736. * @returns a factory method to construc the camera
  30737. */
  30738. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30739. /**
  30740. * Compute the world matrix of the camera.
  30741. * @returns the camera workd matrix
  30742. */
  30743. computeWorldMatrix(): Matrix;
  30744. /**
  30745. * Parse a JSON and creates the camera from the parsed information
  30746. * @param parsedCamera The JSON to parse
  30747. * @param scene The scene to instantiate the camera in
  30748. * @returns the newly constructed camera
  30749. */
  30750. static Parse(parsedCamera: any, scene: Scene): Camera;
  30751. }
  30752. }
  30753. declare module "babylonjs/Misc/tools" {
  30754. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30755. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30756. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30757. import { Observable } from "babylonjs/Misc/observable";
  30758. import { DomManagement } from "babylonjs/Misc/domManagement";
  30759. import { WebRequest } from "babylonjs/Misc/webRequest";
  30760. import { Camera } from "babylonjs/Cameras/camera";
  30761. import { Engine } from "babylonjs/Engines/engine";
  30762. import { Animation } from "babylonjs/Animations/animation";
  30763. /**
  30764. * Interface for any object that can request an animation frame
  30765. */
  30766. export interface ICustomAnimationFrameRequester {
  30767. /**
  30768. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30769. */
  30770. renderFunction?: Function;
  30771. /**
  30772. * Called to request the next frame to render to
  30773. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30774. */
  30775. requestAnimationFrame: Function;
  30776. /**
  30777. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30778. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30779. */
  30780. requestID?: number;
  30781. }
  30782. /**
  30783. * Interface containing an array of animations
  30784. */
  30785. export interface IAnimatable {
  30786. /**
  30787. * Array of animations
  30788. */
  30789. animations: Array<Animation>;
  30790. }
  30791. /** Interface used by value gradients (color, factor, ...) */
  30792. export interface IValueGradient {
  30793. /**
  30794. * Gets or sets the gradient value (between 0 and 1)
  30795. */
  30796. gradient: number;
  30797. }
  30798. /** Class used to store color4 gradient */
  30799. export class ColorGradient implements IValueGradient {
  30800. /**
  30801. * Gets or sets the gradient value (between 0 and 1)
  30802. */
  30803. gradient: number;
  30804. /**
  30805. * Gets or sets first associated color
  30806. */
  30807. color1: Color4;
  30808. /**
  30809. * Gets or sets second associated color
  30810. */
  30811. color2?: Color4;
  30812. /**
  30813. * Will get a color picked randomly between color1 and color2.
  30814. * If color2 is undefined then color1 will be used
  30815. * @param result defines the target Color4 to store the result in
  30816. */
  30817. getColorToRef(result: Color4): void;
  30818. }
  30819. /** Class used to store color 3 gradient */
  30820. export class Color3Gradient implements IValueGradient {
  30821. /**
  30822. * Gets or sets the gradient value (between 0 and 1)
  30823. */
  30824. gradient: number;
  30825. /**
  30826. * Gets or sets the associated color
  30827. */
  30828. color: Color3;
  30829. }
  30830. /** Class used to store factor gradient */
  30831. export class FactorGradient implements IValueGradient {
  30832. /**
  30833. * Gets or sets the gradient value (between 0 and 1)
  30834. */
  30835. gradient: number;
  30836. /**
  30837. * Gets or sets first associated factor
  30838. */
  30839. factor1: number;
  30840. /**
  30841. * Gets or sets second associated factor
  30842. */
  30843. factor2?: number;
  30844. /**
  30845. * Will get a number picked randomly between factor1 and factor2.
  30846. * If factor2 is undefined then factor1 will be used
  30847. * @returns the picked number
  30848. */
  30849. getFactor(): number;
  30850. }
  30851. /**
  30852. * @ignore
  30853. * Application error to support additional information when loading a file
  30854. */
  30855. export class LoadFileError extends Error {
  30856. /** defines the optional web request */
  30857. request?: WebRequest | undefined;
  30858. private static _setPrototypeOf;
  30859. /**
  30860. * Creates a new LoadFileError
  30861. * @param message defines the message of the error
  30862. * @param request defines the optional web request
  30863. */
  30864. constructor(message: string,
  30865. /** defines the optional web request */
  30866. request?: WebRequest | undefined);
  30867. }
  30868. /**
  30869. * Class used to define a retry strategy when error happens while loading assets
  30870. */
  30871. export class RetryStrategy {
  30872. /**
  30873. * Function used to defines an exponential back off strategy
  30874. * @param maxRetries defines the maximum number of retries (3 by default)
  30875. * @param baseInterval defines the interval between retries
  30876. * @returns the strategy function to use
  30877. */
  30878. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30879. }
  30880. /**
  30881. * File request interface
  30882. */
  30883. export interface IFileRequest {
  30884. /**
  30885. * Raised when the request is complete (success or error).
  30886. */
  30887. onCompleteObservable: Observable<IFileRequest>;
  30888. /**
  30889. * Aborts the request for a file.
  30890. */
  30891. abort: () => void;
  30892. }
  30893. /**
  30894. * Class containing a set of static utilities functions
  30895. */
  30896. export class Tools {
  30897. /**
  30898. * Gets or sets the base URL to use to load assets
  30899. */
  30900. static BaseUrl: string;
  30901. /**
  30902. * Enable/Disable Custom HTTP Request Headers globally.
  30903. * default = false
  30904. * @see CustomRequestHeaders
  30905. */
  30906. static UseCustomRequestHeaders: boolean;
  30907. /**
  30908. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30909. * i.e. when loading files, where the server/service expects an Authorization header
  30910. */
  30911. static CustomRequestHeaders: {
  30912. [key: string]: string;
  30913. };
  30914. /**
  30915. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30916. */
  30917. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30918. /**
  30919. * Default behaviour for cors in the application.
  30920. * It can be a string if the expected behavior is identical in the entire app.
  30921. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30922. */
  30923. static CorsBehavior: string | ((url: string | string[]) => string);
  30924. /**
  30925. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30926. * @ignorenaming
  30927. */
  30928. static UseFallbackTexture: boolean;
  30929. /**
  30930. * Use this object to register external classes like custom textures or material
  30931. * to allow the laoders to instantiate them
  30932. */
  30933. static RegisteredExternalClasses: {
  30934. [key: string]: Object;
  30935. };
  30936. /**
  30937. * Texture content used if a texture cannot loaded
  30938. * @ignorenaming
  30939. */
  30940. static fallbackTexture: string;
  30941. /**
  30942. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30943. * @param u defines the coordinate on X axis
  30944. * @param v defines the coordinate on Y axis
  30945. * @param width defines the width of the source data
  30946. * @param height defines the height of the source data
  30947. * @param pixels defines the source byte array
  30948. * @param color defines the output color
  30949. */
  30950. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30951. /**
  30952. * Interpolates between a and b via alpha
  30953. * @param a The lower value (returned when alpha = 0)
  30954. * @param b The upper value (returned when alpha = 1)
  30955. * @param alpha The interpolation-factor
  30956. * @return The mixed value
  30957. */
  30958. static Mix(a: number, b: number, alpha: number): number;
  30959. /**
  30960. * Tries to instantiate a new object from a given class name
  30961. * @param className defines the class name to instantiate
  30962. * @returns the new object or null if the system was not able to do the instantiation
  30963. */
  30964. static Instantiate(className: string): any;
  30965. /**
  30966. * Provides a slice function that will work even on IE
  30967. * @param data defines the array to slice
  30968. * @param start defines the start of the data (optional)
  30969. * @param end defines the end of the data (optional)
  30970. * @returns the new sliced array
  30971. */
  30972. static Slice<T>(data: T, start?: number, end?: number): T;
  30973. /**
  30974. * Polyfill for setImmediate
  30975. * @param action defines the action to execute after the current execution block
  30976. */
  30977. static SetImmediate(action: () => void): void;
  30978. /**
  30979. * Function indicating if a number is an exponent of 2
  30980. * @param value defines the value to test
  30981. * @returns true if the value is an exponent of 2
  30982. */
  30983. static IsExponentOfTwo(value: number): boolean;
  30984. private static _tmpFloatArray;
  30985. /**
  30986. * Returns the nearest 32-bit single precision float representation of a Number
  30987. * @param value A Number. If the parameter is of a different type, it will get converted
  30988. * to a number or to NaN if it cannot be converted
  30989. * @returns number
  30990. */
  30991. static FloatRound(value: number): number;
  30992. /**
  30993. * Find the next highest power of two.
  30994. * @param x Number to start search from.
  30995. * @return Next highest power of two.
  30996. */
  30997. static CeilingPOT(x: number): number;
  30998. /**
  30999. * Find the next lowest power of two.
  31000. * @param x Number to start search from.
  31001. * @return Next lowest power of two.
  31002. */
  31003. static FloorPOT(x: number): number;
  31004. /**
  31005. * Find the nearest power of two.
  31006. * @param x Number to start search from.
  31007. * @return Next nearest power of two.
  31008. */
  31009. static NearestPOT(x: number): number;
  31010. /**
  31011. * Get the closest exponent of two
  31012. * @param value defines the value to approximate
  31013. * @param max defines the maximum value to return
  31014. * @param mode defines how to define the closest value
  31015. * @returns closest exponent of two of the given value
  31016. */
  31017. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31018. /**
  31019. * Extracts the filename from a path
  31020. * @param path defines the path to use
  31021. * @returns the filename
  31022. */
  31023. static GetFilename(path: string): string;
  31024. /**
  31025. * Extracts the "folder" part of a path (everything before the filename).
  31026. * @param uri The URI to extract the info from
  31027. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31028. * @returns The "folder" part of the path
  31029. */
  31030. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31031. /**
  31032. * Extracts text content from a DOM element hierarchy
  31033. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31034. */
  31035. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31036. /**
  31037. * Convert an angle in radians to degrees
  31038. * @param angle defines the angle to convert
  31039. * @returns the angle in degrees
  31040. */
  31041. static ToDegrees(angle: number): number;
  31042. /**
  31043. * Convert an angle in degrees to radians
  31044. * @param angle defines the angle to convert
  31045. * @returns the angle in radians
  31046. */
  31047. static ToRadians(angle: number): number;
  31048. /**
  31049. * Encode a buffer to a base64 string
  31050. * @param buffer defines the buffer to encode
  31051. * @returns the encoded string
  31052. */
  31053. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31054. /**
  31055. * Extracts minimum and maximum values from a list of indexed positions
  31056. * @param positions defines the positions to use
  31057. * @param indices defines the indices to the positions
  31058. * @param indexStart defines the start index
  31059. * @param indexCount defines the end index
  31060. * @param bias defines bias value to add to the result
  31061. * @return minimum and maximum values
  31062. */
  31063. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31064. minimum: Vector3;
  31065. maximum: Vector3;
  31066. };
  31067. /**
  31068. * Extracts minimum and maximum values from a list of positions
  31069. * @param positions defines the positions to use
  31070. * @param start defines the start index in the positions array
  31071. * @param count defines the number of positions to handle
  31072. * @param bias defines bias value to add to the result
  31073. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31074. * @return minimum and maximum values
  31075. */
  31076. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31077. minimum: Vector3;
  31078. maximum: Vector3;
  31079. };
  31080. /**
  31081. * Returns an array if obj is not an array
  31082. * @param obj defines the object to evaluate as an array
  31083. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31084. * @returns either obj directly if obj is an array or a new array containing obj
  31085. */
  31086. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31087. /**
  31088. * Gets the pointer prefix to use
  31089. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31090. */
  31091. static GetPointerPrefix(): string;
  31092. /**
  31093. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31094. * @param func - the function to be called
  31095. * @param requester - the object that will request the next frame. Falls back to window.
  31096. * @returns frame number
  31097. */
  31098. static QueueNewFrame(func: () => void, requester?: any): number;
  31099. /**
  31100. * Ask the browser to promote the current element to fullscreen rendering mode
  31101. * @param element defines the DOM element to promote
  31102. */
  31103. static RequestFullscreen(element: HTMLElement): void;
  31104. /**
  31105. * Asks the browser to exit fullscreen mode
  31106. */
  31107. static ExitFullscreen(): void;
  31108. /**
  31109. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31110. * @param url define the url we are trying
  31111. * @param element define the dom element where to configure the cors policy
  31112. */
  31113. static SetCorsBehavior(url: string | string[], element: {
  31114. crossOrigin: string | null;
  31115. }): void;
  31116. /**
  31117. * Removes unwanted characters from an url
  31118. * @param url defines the url to clean
  31119. * @returns the cleaned url
  31120. */
  31121. static CleanUrl(url: string): string;
  31122. /**
  31123. * Gets or sets a function used to pre-process url before using them to load assets
  31124. */
  31125. static PreprocessUrl: (url: string) => string;
  31126. /**
  31127. * Loads an image as an HTMLImageElement.
  31128. * @param input url string, ArrayBuffer, or Blob to load
  31129. * @param onLoad callback called when the image successfully loads
  31130. * @param onError callback called when the image fails to load
  31131. * @param offlineProvider offline provider for caching
  31132. * @returns the HTMLImageElement of the loaded image
  31133. */
  31134. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31135. /**
  31136. * Loads a file
  31137. * @param url url string, ArrayBuffer, or Blob to load
  31138. * @param onSuccess callback called when the file successfully loads
  31139. * @param onProgress callback called while file is loading (if the server supports this mode)
  31140. * @param offlineProvider defines the offline provider for caching
  31141. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31142. * @param onError callback called when the file fails to load
  31143. * @returns a file request object
  31144. */
  31145. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31146. /**
  31147. * Load a script (identified by an url). When the url returns, the
  31148. * content of this file is added into a new script element, attached to the DOM (body element)
  31149. * @param scriptUrl defines the url of the script to laod
  31150. * @param onSuccess defines the callback called when the script is loaded
  31151. * @param onError defines the callback to call if an error occurs
  31152. */
  31153. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31154. /**
  31155. * Loads a file from a blob
  31156. * @param fileToLoad defines the blob to use
  31157. * @param callback defines the callback to call when data is loaded
  31158. * @param progressCallback defines the callback to call during loading process
  31159. * @returns a file request object
  31160. */
  31161. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31162. /**
  31163. * Loads a file
  31164. * @param fileToLoad defines the file to load
  31165. * @param callback defines the callback to call when data is loaded
  31166. * @param progressCallBack defines the callback to call during loading process
  31167. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31168. * @returns a file request object
  31169. */
  31170. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31171. /**
  31172. * Creates a data url from a given string content
  31173. * @param content defines the content to convert
  31174. * @returns the new data url link
  31175. */
  31176. static FileAsURL(content: string): string;
  31177. /**
  31178. * Format the given number to a specific decimal format
  31179. * @param value defines the number to format
  31180. * @param decimals defines the number of decimals to use
  31181. * @returns the formatted string
  31182. */
  31183. static Format(value: number, decimals?: number): string;
  31184. /**
  31185. * Checks if a given vector is inside a specific range
  31186. * @param v defines the vector to test
  31187. * @param min defines the minimum range
  31188. * @param max defines the maximum range
  31189. */
  31190. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31191. /**
  31192. * Tries to copy an object by duplicating every property
  31193. * @param source defines the source object
  31194. * @param destination defines the target object
  31195. * @param doNotCopyList defines a list of properties to avoid
  31196. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31197. */
  31198. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31199. /**
  31200. * Gets a boolean indicating if the given object has no own property
  31201. * @param obj defines the object to test
  31202. * @returns true if object has no own property
  31203. */
  31204. static IsEmpty(obj: any): boolean;
  31205. /**
  31206. * Function used to register events at window level
  31207. * @param events defines the events to register
  31208. */
  31209. static RegisterTopRootEvents(events: {
  31210. name: string;
  31211. handler: Nullable<(e: FocusEvent) => any>;
  31212. }[]): void;
  31213. /**
  31214. * Function used to unregister events from window level
  31215. * @param events defines the events to unregister
  31216. */
  31217. static UnregisterTopRootEvents(events: {
  31218. name: string;
  31219. handler: Nullable<(e: FocusEvent) => any>;
  31220. }[]): void;
  31221. /**
  31222. * @ignore
  31223. */
  31224. static _ScreenshotCanvas: HTMLCanvasElement;
  31225. /**
  31226. * Dumps the current bound framebuffer
  31227. * @param width defines the rendering width
  31228. * @param height defines the rendering height
  31229. * @param engine defines the hosting engine
  31230. * @param successCallback defines the callback triggered once the data are available
  31231. * @param mimeType defines the mime type of the result
  31232. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31233. */
  31234. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31235. /**
  31236. * Converts the canvas data to blob.
  31237. * This acts as a polyfill for browsers not supporting the to blob function.
  31238. * @param canvas Defines the canvas to extract the data from
  31239. * @param successCallback Defines the callback triggered once the data are available
  31240. * @param mimeType Defines the mime type of the result
  31241. */
  31242. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31243. /**
  31244. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31245. * @param successCallback defines the callback triggered once the data are available
  31246. * @param mimeType defines the mime type of the result
  31247. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31248. */
  31249. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31250. /**
  31251. * Downloads a blob in the browser
  31252. * @param blob defines the blob to download
  31253. * @param fileName defines the name of the downloaded file
  31254. */
  31255. static Download(blob: Blob, fileName: string): void;
  31256. /**
  31257. * Captures a screenshot of the current rendering
  31258. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31259. * @param engine defines the rendering engine
  31260. * @param camera defines the source camera
  31261. * @param size This parameter can be set to a single number or to an object with the
  31262. * following (optional) properties: precision, width, height. If a single number is passed,
  31263. * it will be used for both width and height. If an object is passed, the screenshot size
  31264. * will be derived from the parameters. The precision property is a multiplier allowing
  31265. * rendering at a higher or lower resolution
  31266. * @param successCallback defines the callback receives a single parameter which contains the
  31267. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31268. * src parameter of an <img> to display it
  31269. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31270. * Check your browser for supported MIME types
  31271. */
  31272. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31273. /**
  31274. * Generates an image screenshot from the specified camera.
  31275. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31276. * @param engine The engine to use for rendering
  31277. * @param camera The camera to use for rendering
  31278. * @param size This parameter can be set to a single number or to an object with the
  31279. * following (optional) properties: precision, width, height. If a single number is passed,
  31280. * it will be used for both width and height. If an object is passed, the screenshot size
  31281. * will be derived from the parameters. The precision property is a multiplier allowing
  31282. * rendering at a higher or lower resolution
  31283. * @param successCallback The callback receives a single parameter which contains the
  31284. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31285. * src parameter of an <img> to display it
  31286. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31287. * Check your browser for supported MIME types
  31288. * @param samples Texture samples (default: 1)
  31289. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31290. * @param fileName A name for for the downloaded file.
  31291. */
  31292. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31293. /**
  31294. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31295. * Be aware Math.random() could cause collisions, but:
  31296. * "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"
  31297. * @returns a pseudo random id
  31298. */
  31299. static RandomId(): string;
  31300. /**
  31301. * Test if the given uri is a base64 string
  31302. * @param uri The uri to test
  31303. * @return True if the uri is a base64 string or false otherwise
  31304. */
  31305. static IsBase64(uri: string): boolean;
  31306. /**
  31307. * Decode the given base64 uri.
  31308. * @param uri The uri to decode
  31309. * @return The decoded base64 data.
  31310. */
  31311. static DecodeBase64(uri: string): ArrayBuffer;
  31312. /**
  31313. * No log
  31314. */
  31315. static readonly NoneLogLevel: number;
  31316. /**
  31317. * Only message logs
  31318. */
  31319. static readonly MessageLogLevel: number;
  31320. /**
  31321. * Only warning logs
  31322. */
  31323. static readonly WarningLogLevel: number;
  31324. /**
  31325. * Only error logs
  31326. */
  31327. static readonly ErrorLogLevel: number;
  31328. /**
  31329. * All logs
  31330. */
  31331. static readonly AllLogLevel: number;
  31332. /**
  31333. * Gets a value indicating the number of loading errors
  31334. * @ignorenaming
  31335. */
  31336. static readonly errorsCount: number;
  31337. /**
  31338. * Callback called when a new log is added
  31339. */
  31340. static OnNewCacheEntry: (entry: string) => void;
  31341. /**
  31342. * Log a message to the console
  31343. * @param message defines the message to log
  31344. */
  31345. static Log(message: string): void;
  31346. /**
  31347. * Write a warning message to the console
  31348. * @param message defines the message to log
  31349. */
  31350. static Warn(message: string): void;
  31351. /**
  31352. * Write an error message to the console
  31353. * @param message defines the message to log
  31354. */
  31355. static Error(message: string): void;
  31356. /**
  31357. * Gets current log cache (list of logs)
  31358. */
  31359. static readonly LogCache: string;
  31360. /**
  31361. * Clears the log cache
  31362. */
  31363. static ClearLogCache(): void;
  31364. /**
  31365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31366. */
  31367. static LogLevels: number;
  31368. /**
  31369. * Checks if the loaded document was accessed via `file:`-Protocol.
  31370. * @returns boolean
  31371. */
  31372. static IsFileURL(): boolean;
  31373. /**
  31374. * Checks if the window object exists
  31375. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31376. */
  31377. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31378. /**
  31379. * No performance log
  31380. */
  31381. static readonly PerformanceNoneLogLevel: number;
  31382. /**
  31383. * Use user marks to log performance
  31384. */
  31385. static readonly PerformanceUserMarkLogLevel: number;
  31386. /**
  31387. * Log performance to the console
  31388. */
  31389. static readonly PerformanceConsoleLogLevel: number;
  31390. private static _performance;
  31391. /**
  31392. * Sets the current performance log level
  31393. */
  31394. static PerformanceLogLevel: number;
  31395. private static _StartPerformanceCounterDisabled;
  31396. private static _EndPerformanceCounterDisabled;
  31397. private static _StartUserMark;
  31398. private static _EndUserMark;
  31399. private static _StartPerformanceConsole;
  31400. private static _EndPerformanceConsole;
  31401. /**
  31402. * Starts a performance counter
  31403. */
  31404. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31405. /**
  31406. * Ends a specific performance coutner
  31407. */
  31408. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31409. /**
  31410. * Gets either window.performance.now() if supported or Date.now() else
  31411. */
  31412. static readonly Now: number;
  31413. /**
  31414. * This method will return the name of the class used to create the instance of the given object.
  31415. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31416. * @param object the object to get the class name from
  31417. * @param isType defines if the object is actually a type
  31418. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31419. */
  31420. static GetClassName(object: any, isType?: boolean): string;
  31421. /**
  31422. * Gets the first element of an array satisfying a given predicate
  31423. * @param array defines the array to browse
  31424. * @param predicate defines the predicate to use
  31425. * @returns null if not found or the element
  31426. */
  31427. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31428. /**
  31429. * This method will return the name of the full name of the class, including its owning module (if any).
  31430. * 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).
  31431. * @param object the object to get the class name from
  31432. * @param isType defines if the object is actually a type
  31433. * @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.
  31434. * @ignorenaming
  31435. */
  31436. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31437. /**
  31438. * Returns a promise that resolves after the given amount of time.
  31439. * @param delay Number of milliseconds to delay
  31440. * @returns Promise that resolves after the given amount of time
  31441. */
  31442. static DelayAsync(delay: number): Promise<void>;
  31443. /**
  31444. * Gets the current gradient from an array of IValueGradient
  31445. * @param ratio defines the current ratio to get
  31446. * @param gradients defines the array of IValueGradient
  31447. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31448. */
  31449. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31450. }
  31451. /**
  31452. * This class is used to track a performance counter which is number based.
  31453. * The user has access to many properties which give statistics of different nature.
  31454. *
  31455. * The implementer can track two kinds of Performance Counter: time and count.
  31456. * 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.
  31457. * 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.
  31458. */
  31459. export class PerfCounter {
  31460. /**
  31461. * Gets or sets a global boolean to turn on and off all the counters
  31462. */
  31463. static Enabled: boolean;
  31464. /**
  31465. * Returns the smallest value ever
  31466. */
  31467. readonly min: number;
  31468. /**
  31469. * Returns the biggest value ever
  31470. */
  31471. readonly max: number;
  31472. /**
  31473. * Returns the average value since the performance counter is running
  31474. */
  31475. readonly average: number;
  31476. /**
  31477. * Returns the average value of the last second the counter was monitored
  31478. */
  31479. readonly lastSecAverage: number;
  31480. /**
  31481. * Returns the current value
  31482. */
  31483. readonly current: number;
  31484. /**
  31485. * Gets the accumulated total
  31486. */
  31487. readonly total: number;
  31488. /**
  31489. * Gets the total value count
  31490. */
  31491. readonly count: number;
  31492. /**
  31493. * Creates a new counter
  31494. */
  31495. constructor();
  31496. /**
  31497. * Call this method to start monitoring a new frame.
  31498. * 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.
  31499. */
  31500. fetchNewFrame(): void;
  31501. /**
  31502. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31503. * @param newCount the count value to add to the monitored count
  31504. * @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.
  31505. */
  31506. addCount(newCount: number, fetchResult: boolean): void;
  31507. /**
  31508. * Start monitoring this performance counter
  31509. */
  31510. beginMonitoring(): void;
  31511. /**
  31512. * Compute the time lapsed since the previous beginMonitoring() call.
  31513. * @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
  31514. */
  31515. endMonitoring(newFrame?: boolean): void;
  31516. private _fetchResult;
  31517. private _startMonitoringTime;
  31518. private _min;
  31519. private _max;
  31520. private _average;
  31521. private _current;
  31522. private _totalValueCount;
  31523. private _totalAccumulated;
  31524. private _lastSecAverage;
  31525. private _lastSecAccumulated;
  31526. private _lastSecTime;
  31527. private _lastSecValueCount;
  31528. }
  31529. /**
  31530. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31531. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31532. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31533. * @param name The name of the class, case should be preserved
  31534. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31535. */
  31536. export function className(name: string, module?: string): (target: Object) => void;
  31537. /**
  31538. * An implementation of a loop for asynchronous functions.
  31539. */
  31540. export class AsyncLoop {
  31541. /**
  31542. * Defines the number of iterations for the loop
  31543. */
  31544. iterations: number;
  31545. /**
  31546. * Defines the current index of the loop.
  31547. */
  31548. index: number;
  31549. private _done;
  31550. private _fn;
  31551. private _successCallback;
  31552. /**
  31553. * Constructor.
  31554. * @param iterations the number of iterations.
  31555. * @param func the function to run each iteration
  31556. * @param successCallback the callback that will be called upon succesful execution
  31557. * @param offset starting offset.
  31558. */
  31559. constructor(
  31560. /**
  31561. * Defines the number of iterations for the loop
  31562. */
  31563. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31564. /**
  31565. * Execute the next iteration. Must be called after the last iteration was finished.
  31566. */
  31567. executeNext(): void;
  31568. /**
  31569. * Break the loop and run the success callback.
  31570. */
  31571. breakLoop(): void;
  31572. /**
  31573. * Create and run an async loop.
  31574. * @param iterations the number of iterations.
  31575. * @param fn the function to run each iteration
  31576. * @param successCallback the callback that will be called upon succesful execution
  31577. * @param offset starting offset.
  31578. * @returns the created async loop object
  31579. */
  31580. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31581. /**
  31582. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31583. * @param iterations total number of iterations
  31584. * @param syncedIterations number of synchronous iterations in each async iteration.
  31585. * @param fn the function to call each iteration.
  31586. * @param callback a success call back that will be called when iterating stops.
  31587. * @param breakFunction a break condition (optional)
  31588. * @param timeout timeout settings for the setTimeout function. default - 0.
  31589. * @returns the created async loop object
  31590. */
  31591. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31592. }
  31593. }
  31594. declare module "babylonjs/Collisions/collisionCoordinator" {
  31595. import { Nullable } from "babylonjs/types";
  31596. import { Scene } from "babylonjs/scene";
  31597. import { Vector3 } from "babylonjs/Maths/math";
  31598. import { Collider } from "babylonjs/Collisions/collider";
  31599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31600. /** @hidden */
  31601. export interface ICollisionCoordinator {
  31602. createCollider(): Collider;
  31603. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31604. init(scene: Scene): void;
  31605. }
  31606. /** @hidden */
  31607. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31608. private _scene;
  31609. private _scaledPosition;
  31610. private _scaledVelocity;
  31611. private _finalPosition;
  31612. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31613. createCollider(): Collider;
  31614. init(scene: Scene): void;
  31615. private _collideWithWorld;
  31616. }
  31617. }
  31618. declare module "babylonjs/Animations/animationGroup" {
  31619. import { Animatable } from "babylonjs/Animations/animatable";
  31620. import { Animation } from "babylonjs/Animations/animation";
  31621. import { Scene, IDisposable } from "babylonjs/scene";
  31622. import { Observable } from "babylonjs/Misc/observable";
  31623. import { Nullable } from "babylonjs/types";
  31624. /**
  31625. * This class defines the direct association between an animation and a target
  31626. */
  31627. export class TargetedAnimation {
  31628. /**
  31629. * Animation to perform
  31630. */
  31631. animation: Animation;
  31632. /**
  31633. * Target to animate
  31634. */
  31635. target: any;
  31636. }
  31637. /**
  31638. * Use this class to create coordinated animations on multiple targets
  31639. */
  31640. export class AnimationGroup implements IDisposable {
  31641. /** The name of the animation group */
  31642. name: string;
  31643. private _scene;
  31644. private _targetedAnimations;
  31645. private _animatables;
  31646. private _from;
  31647. private _to;
  31648. private _isStarted;
  31649. private _isPaused;
  31650. private _speedRatio;
  31651. /**
  31652. * Gets or sets the unique id of the node
  31653. */
  31654. uniqueId: number;
  31655. /**
  31656. * This observable will notify when one animation have ended
  31657. */
  31658. onAnimationEndObservable: Observable<TargetedAnimation>;
  31659. /**
  31660. * Observer raised when one animation loops
  31661. */
  31662. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31663. /**
  31664. * This observable will notify when all animations have ended.
  31665. */
  31666. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31667. /**
  31668. * This observable will notify when all animations have paused.
  31669. */
  31670. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31671. /**
  31672. * This observable will notify when all animations are playing.
  31673. */
  31674. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31675. /**
  31676. * Gets the first frame
  31677. */
  31678. readonly from: number;
  31679. /**
  31680. * Gets the last frame
  31681. */
  31682. readonly to: number;
  31683. /**
  31684. * Define if the animations are started
  31685. */
  31686. readonly isStarted: boolean;
  31687. /**
  31688. * Gets a value indicating that the current group is playing
  31689. */
  31690. readonly isPlaying: boolean;
  31691. /**
  31692. * Gets or sets the speed ratio to use for all animations
  31693. */
  31694. /**
  31695. * Gets or sets the speed ratio to use for all animations
  31696. */
  31697. speedRatio: number;
  31698. /**
  31699. * Gets the targeted animations for this animation group
  31700. */
  31701. readonly targetedAnimations: Array<TargetedAnimation>;
  31702. /**
  31703. * returning the list of animatables controlled by this animation group.
  31704. */
  31705. readonly animatables: Array<Animatable>;
  31706. /**
  31707. * Instantiates a new Animation Group.
  31708. * This helps managing several animations at once.
  31709. * @see http://doc.babylonjs.com/how_to/group
  31710. * @param name Defines the name of the group
  31711. * @param scene Defines the scene the group belongs to
  31712. */
  31713. constructor(
  31714. /** The name of the animation group */
  31715. name: string, scene?: Nullable<Scene>);
  31716. /**
  31717. * Add an animation (with its target) in the group
  31718. * @param animation defines the animation we want to add
  31719. * @param target defines the target of the animation
  31720. * @returns the TargetedAnimation object
  31721. */
  31722. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31723. /**
  31724. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31725. * It can add constant keys at begin or end
  31726. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31727. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31728. * @returns the animation group
  31729. */
  31730. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31731. /**
  31732. * Start all animations on given targets
  31733. * @param loop defines if animations must loop
  31734. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31735. * @param from defines the from key (optional)
  31736. * @param to defines the to key (optional)
  31737. * @returns the current animation group
  31738. */
  31739. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31740. /**
  31741. * Pause all animations
  31742. * @returns the animation group
  31743. */
  31744. pause(): AnimationGroup;
  31745. /**
  31746. * Play all animations to initial state
  31747. * This function will start() the animations if they were not started or will restart() them if they were paused
  31748. * @param loop defines if animations must loop
  31749. * @returns the animation group
  31750. */
  31751. play(loop?: boolean): AnimationGroup;
  31752. /**
  31753. * Reset all animations to initial state
  31754. * @returns the animation group
  31755. */
  31756. reset(): AnimationGroup;
  31757. /**
  31758. * Restart animations from key 0
  31759. * @returns the animation group
  31760. */
  31761. restart(): AnimationGroup;
  31762. /**
  31763. * Stop all animations
  31764. * @returns the animation group
  31765. */
  31766. stop(): AnimationGroup;
  31767. /**
  31768. * Set animation weight for all animatables
  31769. * @param weight defines the weight to use
  31770. * @return the animationGroup
  31771. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31772. */
  31773. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31774. /**
  31775. * Synchronize and normalize all animatables with a source animatable
  31776. * @param root defines the root animatable to synchronize with
  31777. * @return the animationGroup
  31778. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31779. */
  31780. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31781. /**
  31782. * Goes to a specific frame in this animation group
  31783. * @param frame the frame number to go to
  31784. * @return the animationGroup
  31785. */
  31786. goToFrame(frame: number): AnimationGroup;
  31787. /**
  31788. * Dispose all associated resources
  31789. */
  31790. dispose(): void;
  31791. private _checkAnimationGroupEnded;
  31792. /**
  31793. * Clone the current animation group and returns a copy
  31794. * @param newName defines the name of the new group
  31795. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31796. * @returns the new aniamtion group
  31797. */
  31798. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31799. /**
  31800. * Returns a new AnimationGroup object parsed from the source provided.
  31801. * @param parsedAnimationGroup defines the source
  31802. * @param scene defines the scene that will receive the animationGroup
  31803. * @returns a new AnimationGroup
  31804. */
  31805. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31806. /**
  31807. * Returns the string "AnimationGroup"
  31808. * @returns "AnimationGroup"
  31809. */
  31810. getClassName(): string;
  31811. /**
  31812. * Creates a detailled string about the object
  31813. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31814. * @returns a string representing the object
  31815. */
  31816. toString(fullDetails?: boolean): string;
  31817. }
  31818. }
  31819. declare module "babylonjs/scene" {
  31820. import { Nullable } from "babylonjs/types";
  31821. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31822. import { Observable } from "babylonjs/Misc/observable";
  31823. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31824. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31825. import { Geometry } from "babylonjs/Meshes/geometry";
  31826. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31827. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31829. import { Mesh } from "babylonjs/Meshes/mesh";
  31830. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31831. import { Bone } from "babylonjs/Bones/bone";
  31832. import { Skeleton } from "babylonjs/Bones/skeleton";
  31833. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31834. import { Camera } from "babylonjs/Cameras/camera";
  31835. import { AbstractScene } from "babylonjs/abstractScene";
  31836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31838. import { Material } from "babylonjs/Materials/material";
  31839. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31840. import { Effect } from "babylonjs/Materials/effect";
  31841. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31842. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31843. import { Light } from "babylonjs/Lights/light";
  31844. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31845. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31846. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31847. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31848. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31849. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31850. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31851. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31852. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31853. import { Engine } from "babylonjs/Engines/engine";
  31854. import { Node } from "babylonjs/node";
  31855. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31856. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31857. import { WebRequest } from "babylonjs/Misc/webRequest";
  31858. import { Ray } from "babylonjs/Culling/ray";
  31859. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31860. import { Animation } from "babylonjs/Animations/animation";
  31861. import { Animatable } from "babylonjs/Animations/animatable";
  31862. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31863. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31864. import { Collider } from "babylonjs/Collisions/collider";
  31865. /**
  31866. * Define an interface for all classes that will hold resources
  31867. */
  31868. export interface IDisposable {
  31869. /**
  31870. * Releases all held resources
  31871. */
  31872. dispose(): void;
  31873. }
  31874. /** Interface defining initialization parameters for Scene class */
  31875. export interface SceneOptions {
  31876. /**
  31877. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31878. * It will improve performance when the number of geometries becomes important.
  31879. */
  31880. useGeometryUniqueIdsMap?: boolean;
  31881. /**
  31882. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31883. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31884. */
  31885. useMaterialMeshMap?: boolean;
  31886. /**
  31887. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31888. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31889. */
  31890. useClonedMeshhMap?: boolean;
  31891. }
  31892. /**
  31893. * Represents a scene to be rendered by the engine.
  31894. * @see http://doc.babylonjs.com/features/scene
  31895. */
  31896. export class Scene extends AbstractScene implements IAnimatable {
  31897. private static _uniqueIdCounter;
  31898. /** The fog is deactivated */
  31899. static readonly FOGMODE_NONE: number;
  31900. /** The fog density is following an exponential function */
  31901. static readonly FOGMODE_EXP: number;
  31902. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31903. static readonly FOGMODE_EXP2: number;
  31904. /** The fog density is following a linear function. */
  31905. static readonly FOGMODE_LINEAR: number;
  31906. /**
  31907. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31908. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31909. */
  31910. static MinDeltaTime: number;
  31911. /**
  31912. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31913. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31914. */
  31915. static MaxDeltaTime: number;
  31916. /**
  31917. * Factory used to create the default material.
  31918. * @param name The name of the material to create
  31919. * @param scene The scene to create the material for
  31920. * @returns The default material
  31921. */
  31922. static DefaultMaterialFactory(scene: Scene): Material;
  31923. /**
  31924. * Factory used to create the a collision coordinator.
  31925. * @returns The collision coordinator
  31926. */
  31927. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31928. /** @hidden */
  31929. readonly _isScene: boolean;
  31930. /**
  31931. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31932. */
  31933. autoClear: boolean;
  31934. /**
  31935. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31936. */
  31937. autoClearDepthAndStencil: boolean;
  31938. /**
  31939. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31940. */
  31941. clearColor: Color4;
  31942. /**
  31943. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31944. */
  31945. ambientColor: Color3;
  31946. /** @hidden */
  31947. _environmentBRDFTexture: BaseTexture;
  31948. /** @hidden */
  31949. protected _environmentTexture: Nullable<BaseTexture>;
  31950. /**
  31951. * Texture used in all pbr material as the reflection texture.
  31952. * As in the majority of the scene they are the same (exception for multi room and so on),
  31953. * this is easier to reference from here than from all the materials.
  31954. */
  31955. /**
  31956. * Texture used in all pbr material as the reflection texture.
  31957. * As in the majority of the scene they are the same (exception for multi room and so on),
  31958. * this is easier to set here than in all the materials.
  31959. */
  31960. environmentTexture: Nullable<BaseTexture>;
  31961. /** @hidden */
  31962. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31963. /**
  31964. * Default image processing configuration used either in the rendering
  31965. * Forward main pass or through the imageProcessingPostProcess if present.
  31966. * As in the majority of the scene they are the same (exception for multi camera),
  31967. * this is easier to reference from here than from all the materials and post process.
  31968. *
  31969. * No setter as we it is a shared configuration, you can set the values instead.
  31970. */
  31971. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31972. private _forceWireframe;
  31973. /**
  31974. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31975. */
  31976. forceWireframe: boolean;
  31977. private _forcePointsCloud;
  31978. /**
  31979. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31980. */
  31981. forcePointsCloud: boolean;
  31982. /**
  31983. * Gets or sets the active clipplane 1
  31984. */
  31985. clipPlane: Nullable<Plane>;
  31986. /**
  31987. * Gets or sets the active clipplane 2
  31988. */
  31989. clipPlane2: Nullable<Plane>;
  31990. /**
  31991. * Gets or sets the active clipplane 3
  31992. */
  31993. clipPlane3: Nullable<Plane>;
  31994. /**
  31995. * Gets or sets the active clipplane 4
  31996. */
  31997. clipPlane4: Nullable<Plane>;
  31998. /**
  31999. * Gets or sets a boolean indicating if animations are enabled
  32000. */
  32001. animationsEnabled: boolean;
  32002. private _animationPropertiesOverride;
  32003. /**
  32004. * Gets or sets the animation properties override
  32005. */
  32006. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32007. /**
  32008. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32009. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32010. */
  32011. useConstantAnimationDeltaTime: boolean;
  32012. /**
  32013. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32014. * Please note that it requires to run a ray cast through the scene on every frame
  32015. */
  32016. constantlyUpdateMeshUnderPointer: boolean;
  32017. /**
  32018. * Defines the HTML cursor to use when hovering over interactive elements
  32019. */
  32020. hoverCursor: string;
  32021. /**
  32022. * Defines the HTML default cursor to use (empty by default)
  32023. */
  32024. defaultCursor: string;
  32025. /**
  32026. * This is used to call preventDefault() on pointer down
  32027. * in order to block unwanted artifacts like system double clicks
  32028. */
  32029. preventDefaultOnPointerDown: boolean;
  32030. /**
  32031. * This is used to call preventDefault() on pointer up
  32032. * in order to block unwanted artifacts like system double clicks
  32033. */
  32034. preventDefaultOnPointerUp: boolean;
  32035. /**
  32036. * Gets or sets user defined metadata
  32037. */
  32038. metadata: any;
  32039. /**
  32040. * For internal use only. Please do not use.
  32041. */
  32042. reservedDataStore: any;
  32043. /**
  32044. * Gets the name of the plugin used to load this scene (null by default)
  32045. */
  32046. loadingPluginName: string;
  32047. /**
  32048. * Use this array to add regular expressions used to disable offline support for specific urls
  32049. */
  32050. disableOfflineSupportExceptionRules: RegExp[];
  32051. /**
  32052. * An event triggered when the scene is disposed.
  32053. */
  32054. onDisposeObservable: Observable<Scene>;
  32055. private _onDisposeObserver;
  32056. /** Sets a function to be executed when this scene is disposed. */
  32057. onDispose: () => void;
  32058. /**
  32059. * An event triggered before rendering the scene (right after animations and physics)
  32060. */
  32061. onBeforeRenderObservable: Observable<Scene>;
  32062. private _onBeforeRenderObserver;
  32063. /** Sets a function to be executed before rendering this scene */
  32064. beforeRender: Nullable<() => void>;
  32065. /**
  32066. * An event triggered after rendering the scene
  32067. */
  32068. onAfterRenderObservable: Observable<Scene>;
  32069. private _onAfterRenderObserver;
  32070. /** Sets a function to be executed after rendering this scene */
  32071. afterRender: Nullable<() => void>;
  32072. /**
  32073. * An event triggered before animating the scene
  32074. */
  32075. onBeforeAnimationsObservable: Observable<Scene>;
  32076. /**
  32077. * An event triggered after animations processing
  32078. */
  32079. onAfterAnimationsObservable: Observable<Scene>;
  32080. /**
  32081. * An event triggered before draw calls are ready to be sent
  32082. */
  32083. onBeforeDrawPhaseObservable: Observable<Scene>;
  32084. /**
  32085. * An event triggered after draw calls have been sent
  32086. */
  32087. onAfterDrawPhaseObservable: Observable<Scene>;
  32088. /**
  32089. * An event triggered when the scene is ready
  32090. */
  32091. onReadyObservable: Observable<Scene>;
  32092. /**
  32093. * An event triggered before rendering a camera
  32094. */
  32095. onBeforeCameraRenderObservable: Observable<Camera>;
  32096. private _onBeforeCameraRenderObserver;
  32097. /** Sets a function to be executed before rendering a camera*/
  32098. beforeCameraRender: () => void;
  32099. /**
  32100. * An event triggered after rendering a camera
  32101. */
  32102. onAfterCameraRenderObservable: Observable<Camera>;
  32103. private _onAfterCameraRenderObserver;
  32104. /** Sets a function to be executed after rendering a camera*/
  32105. afterCameraRender: () => void;
  32106. /**
  32107. * An event triggered when active meshes evaluation is about to start
  32108. */
  32109. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32110. /**
  32111. * An event triggered when active meshes evaluation is done
  32112. */
  32113. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32114. /**
  32115. * An event triggered when particles rendering is about to start
  32116. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32117. */
  32118. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32119. /**
  32120. * An event triggered when particles rendering is done
  32121. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32122. */
  32123. onAfterParticlesRenderingObservable: Observable<Scene>;
  32124. /**
  32125. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32126. */
  32127. onDataLoadedObservable: Observable<Scene>;
  32128. /**
  32129. * An event triggered when a camera is created
  32130. */
  32131. onNewCameraAddedObservable: Observable<Camera>;
  32132. /**
  32133. * An event triggered when a camera is removed
  32134. */
  32135. onCameraRemovedObservable: Observable<Camera>;
  32136. /**
  32137. * An event triggered when a light is created
  32138. */
  32139. onNewLightAddedObservable: Observable<Light>;
  32140. /**
  32141. * An event triggered when a light is removed
  32142. */
  32143. onLightRemovedObservable: Observable<Light>;
  32144. /**
  32145. * An event triggered when a geometry is created
  32146. */
  32147. onNewGeometryAddedObservable: Observable<Geometry>;
  32148. /**
  32149. * An event triggered when a geometry is removed
  32150. */
  32151. onGeometryRemovedObservable: Observable<Geometry>;
  32152. /**
  32153. * An event triggered when a transform node is created
  32154. */
  32155. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32156. /**
  32157. * An event triggered when a transform node is removed
  32158. */
  32159. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32160. /**
  32161. * An event triggered when a mesh is created
  32162. */
  32163. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32164. /**
  32165. * An event triggered when a mesh is removed
  32166. */
  32167. onMeshRemovedObservable: Observable<AbstractMesh>;
  32168. /**
  32169. * An event triggered when a skeleton is created
  32170. */
  32171. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32172. /**
  32173. * An event triggered when a skeleton is removed
  32174. */
  32175. onSkeletonRemovedObservable: Observable<Skeleton>;
  32176. /**
  32177. * An event triggered when a material is created
  32178. */
  32179. onNewMaterialAddedObservable: Observable<Material>;
  32180. /**
  32181. * An event triggered when a material is removed
  32182. */
  32183. onMaterialRemovedObservable: Observable<Material>;
  32184. /**
  32185. * An event triggered when a texture is created
  32186. */
  32187. onNewTextureAddedObservable: Observable<BaseTexture>;
  32188. /**
  32189. * An event triggered when a texture is removed
  32190. */
  32191. onTextureRemovedObservable: Observable<BaseTexture>;
  32192. /**
  32193. * An event triggered when render targets are about to be rendered
  32194. * Can happen multiple times per frame.
  32195. */
  32196. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32197. /**
  32198. * An event triggered when render targets were rendered.
  32199. * Can happen multiple times per frame.
  32200. */
  32201. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32202. /**
  32203. * An event triggered before calculating deterministic simulation step
  32204. */
  32205. onBeforeStepObservable: Observable<Scene>;
  32206. /**
  32207. * An event triggered after calculating deterministic simulation step
  32208. */
  32209. onAfterStepObservable: Observable<Scene>;
  32210. /**
  32211. * An event triggered when the activeCamera property is updated
  32212. */
  32213. onActiveCameraChanged: Observable<Scene>;
  32214. /**
  32215. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32216. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32217. * 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)
  32218. */
  32219. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32220. /**
  32221. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32222. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32223. * 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)
  32224. */
  32225. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32226. /**
  32227. * This Observable will when a mesh has been imported into the scene.
  32228. */
  32229. onMeshImportedObservable: Observable<AbstractMesh>;
  32230. /**
  32231. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32232. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32233. */
  32234. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32235. /** @hidden */
  32236. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32237. /**
  32238. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32239. */
  32240. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32241. /**
  32242. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32243. */
  32244. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32245. /**
  32246. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32247. */
  32248. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32249. private _onPointerMove;
  32250. private _onPointerDown;
  32251. private _onPointerUp;
  32252. /** Callback called when a pointer move is detected */
  32253. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32254. /** Callback called when a pointer down is detected */
  32255. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32256. /** Callback called when a pointer up is detected */
  32257. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32258. /** Callback called when a pointer pick is detected */
  32259. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32260. /**
  32261. * 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).
  32262. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32263. */
  32264. onPrePointerObservable: Observable<PointerInfoPre>;
  32265. /**
  32266. * Observable event triggered each time an input event is received from the rendering canvas
  32267. */
  32268. onPointerObservable: Observable<PointerInfo>;
  32269. /**
  32270. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32271. */
  32272. readonly unTranslatedPointer: Vector2;
  32273. /** The distance in pixel that you have to move to prevent some events */
  32274. static DragMovementThreshold: number;
  32275. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32276. static LongPressDelay: number;
  32277. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32278. static DoubleClickDelay: number;
  32279. /** If you need to check double click without raising a single click at first click, enable this flag */
  32280. static ExclusiveDoubleClickMode: boolean;
  32281. private _initClickEvent;
  32282. private _initActionManager;
  32283. private _delayedSimpleClick;
  32284. private _delayedSimpleClickTimeout;
  32285. private _previousDelayedSimpleClickTimeout;
  32286. private _meshPickProceed;
  32287. private _previousButtonPressed;
  32288. private _currentPickResult;
  32289. private _previousPickResult;
  32290. private _totalPointersPressed;
  32291. private _doubleClickOccured;
  32292. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32293. cameraToUseForPointers: Nullable<Camera>;
  32294. private _pointerX;
  32295. private _pointerY;
  32296. private _unTranslatedPointerX;
  32297. private _unTranslatedPointerY;
  32298. private _startingPointerPosition;
  32299. private _previousStartingPointerPosition;
  32300. private _startingPointerTime;
  32301. private _previousStartingPointerTime;
  32302. private _pointerCaptures;
  32303. private _timeAccumulator;
  32304. private _currentStepId;
  32305. private _currentInternalStep;
  32306. /** @hidden */
  32307. _mirroredCameraPosition: Nullable<Vector3>;
  32308. /**
  32309. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32310. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32311. */
  32312. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32313. /**
  32314. * Observable event triggered each time an keyboard event is received from the hosting window
  32315. */
  32316. onKeyboardObservable: Observable<KeyboardInfo>;
  32317. private _onKeyDown;
  32318. private _onKeyUp;
  32319. private _onCanvasFocusObserver;
  32320. private _onCanvasBlurObserver;
  32321. private _useRightHandedSystem;
  32322. /**
  32323. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32324. */
  32325. useRightHandedSystem: boolean;
  32326. /**
  32327. * Sets the step Id used by deterministic lock step
  32328. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32329. * @param newStepId defines the step Id
  32330. */
  32331. setStepId(newStepId: number): void;
  32332. /**
  32333. * Gets the step Id used by deterministic lock step
  32334. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32335. * @returns the step Id
  32336. */
  32337. getStepId(): number;
  32338. /**
  32339. * Gets the internal step used by deterministic lock step
  32340. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32341. * @returns the internal step
  32342. */
  32343. getInternalStep(): number;
  32344. private _fogEnabled;
  32345. /**
  32346. * Gets or sets a boolean indicating if fog is enabled on this scene
  32347. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32348. * (Default is true)
  32349. */
  32350. fogEnabled: boolean;
  32351. private _fogMode;
  32352. /**
  32353. * Gets or sets the fog mode to use
  32354. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32355. * | mode | value |
  32356. * | --- | --- |
  32357. * | FOGMODE_NONE | 0 |
  32358. * | FOGMODE_EXP | 1 |
  32359. * | FOGMODE_EXP2 | 2 |
  32360. * | FOGMODE_LINEAR | 3 |
  32361. */
  32362. fogMode: number;
  32363. /**
  32364. * Gets or sets the fog color to use
  32365. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32366. * (Default is Color3(0.2, 0.2, 0.3))
  32367. */
  32368. fogColor: Color3;
  32369. /**
  32370. * Gets or sets the fog density to use
  32371. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32372. * (Default is 0.1)
  32373. */
  32374. fogDensity: number;
  32375. /**
  32376. * Gets or sets the fog start distance to use
  32377. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32378. * (Default is 0)
  32379. */
  32380. fogStart: number;
  32381. /**
  32382. * Gets or sets the fog end distance to use
  32383. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32384. * (Default is 1000)
  32385. */
  32386. fogEnd: number;
  32387. private _shadowsEnabled;
  32388. /**
  32389. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32390. */
  32391. shadowsEnabled: boolean;
  32392. private _lightsEnabled;
  32393. /**
  32394. * Gets or sets a boolean indicating if lights are enabled on this scene
  32395. */
  32396. lightsEnabled: boolean;
  32397. /** All of the active cameras added to this scene. */
  32398. activeCameras: Camera[];
  32399. private _activeCamera;
  32400. /** Gets or sets the current active camera */
  32401. activeCamera: Nullable<Camera>;
  32402. private _defaultMaterial;
  32403. /** The default material used on meshes when no material is affected */
  32404. /** The default material used on meshes when no material is affected */
  32405. defaultMaterial: Material;
  32406. private _texturesEnabled;
  32407. /**
  32408. * Gets or sets a boolean indicating if textures are enabled on this scene
  32409. */
  32410. texturesEnabled: boolean;
  32411. /**
  32412. * Gets or sets a boolean indicating if particles are enabled on this scene
  32413. */
  32414. particlesEnabled: boolean;
  32415. /**
  32416. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32417. */
  32418. spritesEnabled: boolean;
  32419. private _skeletonsEnabled;
  32420. /**
  32421. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32422. */
  32423. skeletonsEnabled: boolean;
  32424. /**
  32425. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32426. */
  32427. lensFlaresEnabled: boolean;
  32428. /**
  32429. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32430. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32431. */
  32432. collisionsEnabled: boolean;
  32433. private _collisionCoordinator;
  32434. /** @hidden */
  32435. readonly collisionCoordinator: ICollisionCoordinator;
  32436. /**
  32437. * Defines the gravity applied to this scene (used only for collisions)
  32438. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32439. */
  32440. gravity: Vector3;
  32441. /**
  32442. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32443. */
  32444. postProcessesEnabled: boolean;
  32445. /**
  32446. * The list of postprocesses added to the scene
  32447. */
  32448. postProcesses: PostProcess[];
  32449. /**
  32450. * Gets the current postprocess manager
  32451. */
  32452. postProcessManager: PostProcessManager;
  32453. /**
  32454. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32455. */
  32456. renderTargetsEnabled: boolean;
  32457. /**
  32458. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32459. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32460. */
  32461. dumpNextRenderTargets: boolean;
  32462. /**
  32463. * The list of user defined render targets added to the scene
  32464. */
  32465. customRenderTargets: RenderTargetTexture[];
  32466. /**
  32467. * Defines if texture loading must be delayed
  32468. * If true, textures will only be loaded when they need to be rendered
  32469. */
  32470. useDelayedTextureLoading: boolean;
  32471. /**
  32472. * Gets the list of meshes imported to the scene through SceneLoader
  32473. */
  32474. importedMeshesFiles: String[];
  32475. /**
  32476. * Gets or sets a boolean indicating if probes are enabled on this scene
  32477. */
  32478. probesEnabled: boolean;
  32479. /**
  32480. * Gets or sets the current offline provider to use to store scene data
  32481. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32482. */
  32483. offlineProvider: IOfflineProvider;
  32484. /**
  32485. * Gets or sets the action manager associated with the scene
  32486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32487. */
  32488. actionManager: AbstractActionManager;
  32489. private _meshesForIntersections;
  32490. /**
  32491. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32492. */
  32493. proceduralTexturesEnabled: boolean;
  32494. private _engine;
  32495. private _totalVertices;
  32496. /** @hidden */
  32497. _activeIndices: PerfCounter;
  32498. /** @hidden */
  32499. _activeParticles: PerfCounter;
  32500. /** @hidden */
  32501. _activeBones: PerfCounter;
  32502. private _animationRatio;
  32503. /** @hidden */
  32504. _animationTimeLast: number;
  32505. /** @hidden */
  32506. _animationTime: number;
  32507. /**
  32508. * Gets or sets a general scale for animation speed
  32509. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32510. */
  32511. animationTimeScale: number;
  32512. /** @hidden */
  32513. _cachedMaterial: Nullable<Material>;
  32514. /** @hidden */
  32515. _cachedEffect: Nullable<Effect>;
  32516. /** @hidden */
  32517. _cachedVisibility: Nullable<number>;
  32518. private _renderId;
  32519. private _frameId;
  32520. private _executeWhenReadyTimeoutId;
  32521. private _intermediateRendering;
  32522. private _viewUpdateFlag;
  32523. private _projectionUpdateFlag;
  32524. private _alternateViewUpdateFlag;
  32525. private _alternateProjectionUpdateFlag;
  32526. /** @hidden */
  32527. _toBeDisposed: Nullable<IDisposable>[];
  32528. private _activeRequests;
  32529. /** @hidden */
  32530. _pendingData: any[];
  32531. private _isDisposed;
  32532. /**
  32533. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32534. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32535. */
  32536. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32537. private _activeMeshes;
  32538. private _processedMaterials;
  32539. private _renderTargets;
  32540. /** @hidden */
  32541. _activeParticleSystems: SmartArray<IParticleSystem>;
  32542. private _activeSkeletons;
  32543. private _softwareSkinnedMeshes;
  32544. private _renderingManager;
  32545. /** @hidden */
  32546. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32547. private _transformMatrix;
  32548. private _sceneUbo;
  32549. private _alternateSceneUbo;
  32550. private _viewMatrix;
  32551. private _projectionMatrix;
  32552. private _alternateViewMatrix;
  32553. private _alternateProjectionMatrix;
  32554. private _alternateTransformMatrix;
  32555. private _useAlternateCameraConfiguration;
  32556. private _alternateRendering;
  32557. private _wheelEventName;
  32558. /** @hidden */
  32559. _forcedViewPosition: Nullable<Vector3>;
  32560. /** @hidden */
  32561. readonly _isAlternateRenderingEnabled: boolean;
  32562. private _frustumPlanes;
  32563. /**
  32564. * Gets the list of frustum planes (built from the active camera)
  32565. */
  32566. readonly frustumPlanes: Plane[];
  32567. /**
  32568. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32569. * This is useful if there are more lights that the maximum simulteanous authorized
  32570. */
  32571. requireLightSorting: boolean;
  32572. /** @hidden */
  32573. readonly useMaterialMeshMap: boolean;
  32574. /** @hidden */
  32575. readonly useClonedMeshhMap: boolean;
  32576. private _pointerOverMesh;
  32577. private _pickedDownMesh;
  32578. private _pickedUpMesh;
  32579. private _externalData;
  32580. private _uid;
  32581. /**
  32582. * @hidden
  32583. * Backing store of defined scene components.
  32584. */
  32585. _components: ISceneComponent[];
  32586. /**
  32587. * @hidden
  32588. * Backing store of defined scene components.
  32589. */
  32590. _serializableComponents: ISceneSerializableComponent[];
  32591. /**
  32592. * List of components to register on the next registration step.
  32593. */
  32594. private _transientComponents;
  32595. /**
  32596. * Registers the transient components if needed.
  32597. */
  32598. private _registerTransientComponents;
  32599. /**
  32600. * @hidden
  32601. * Add a component to the scene.
  32602. * Note that the ccomponent could be registered on th next frame if this is called after
  32603. * the register component stage.
  32604. * @param component Defines the component to add to the scene
  32605. */
  32606. _addComponent(component: ISceneComponent): void;
  32607. /**
  32608. * @hidden
  32609. * Gets a component from the scene.
  32610. * @param name defines the name of the component to retrieve
  32611. * @returns the component or null if not present
  32612. */
  32613. _getComponent(name: string): Nullable<ISceneComponent>;
  32614. /**
  32615. * @hidden
  32616. * Defines the actions happening before camera updates.
  32617. */
  32618. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32619. /**
  32620. * @hidden
  32621. * Defines the actions happening before clear the canvas.
  32622. */
  32623. _beforeClearStage: Stage<SimpleStageAction>;
  32624. /**
  32625. * @hidden
  32626. * Defines the actions when collecting render targets for the frame.
  32627. */
  32628. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32629. /**
  32630. * @hidden
  32631. * Defines the actions happening for one camera in the frame.
  32632. */
  32633. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32634. /**
  32635. * @hidden
  32636. * Defines the actions happening during the per mesh ready checks.
  32637. */
  32638. _isReadyForMeshStage: Stage<MeshStageAction>;
  32639. /**
  32640. * @hidden
  32641. * Defines the actions happening before evaluate active mesh checks.
  32642. */
  32643. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32644. /**
  32645. * @hidden
  32646. * Defines the actions happening during the evaluate sub mesh checks.
  32647. */
  32648. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32649. /**
  32650. * @hidden
  32651. * Defines the actions happening during the active mesh stage.
  32652. */
  32653. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32654. /**
  32655. * @hidden
  32656. * Defines the actions happening during the per camera render target step.
  32657. */
  32658. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32659. /**
  32660. * @hidden
  32661. * Defines the actions happening just before the active camera is drawing.
  32662. */
  32663. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32664. /**
  32665. * @hidden
  32666. * Defines the actions happening just before a render target is drawing.
  32667. */
  32668. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32669. /**
  32670. * @hidden
  32671. * Defines the actions happening just before a rendering group is drawing.
  32672. */
  32673. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32674. /**
  32675. * @hidden
  32676. * Defines the actions happening just before a mesh is drawing.
  32677. */
  32678. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32679. /**
  32680. * @hidden
  32681. * Defines the actions happening just after a mesh has been drawn.
  32682. */
  32683. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32684. /**
  32685. * @hidden
  32686. * Defines the actions happening just after a rendering group has been drawn.
  32687. */
  32688. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32689. /**
  32690. * @hidden
  32691. * Defines the actions happening just after the active camera has been drawn.
  32692. */
  32693. _afterCameraDrawStage: Stage<CameraStageAction>;
  32694. /**
  32695. * @hidden
  32696. * Defines the actions happening just after a render target has been drawn.
  32697. */
  32698. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32699. /**
  32700. * @hidden
  32701. * Defines the actions happening just after rendering all cameras and computing intersections.
  32702. */
  32703. _afterRenderStage: Stage<SimpleStageAction>;
  32704. /**
  32705. * @hidden
  32706. * Defines the actions happening when a pointer move event happens.
  32707. */
  32708. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32709. /**
  32710. * @hidden
  32711. * Defines the actions happening when a pointer down event happens.
  32712. */
  32713. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32714. /**
  32715. * @hidden
  32716. * Defines the actions happening when a pointer up event happens.
  32717. */
  32718. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32719. /**
  32720. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32721. */
  32722. private geometriesByUniqueId;
  32723. /**
  32724. * Creates a new Scene
  32725. * @param engine defines the engine to use to render this scene
  32726. * @param options defines the scene options
  32727. */
  32728. constructor(engine: Engine, options?: SceneOptions);
  32729. private _defaultMeshCandidates;
  32730. /**
  32731. * @hidden
  32732. */
  32733. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32734. private _defaultSubMeshCandidates;
  32735. /**
  32736. * @hidden
  32737. */
  32738. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32739. /**
  32740. * Sets the default candidate providers for the scene.
  32741. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32742. * and getCollidingSubMeshCandidates to their default function
  32743. */
  32744. setDefaultCandidateProviders(): void;
  32745. /**
  32746. * Gets the mesh that is currently under the pointer
  32747. */
  32748. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32749. /**
  32750. * Gets or sets the current on-screen X position of the pointer
  32751. */
  32752. pointerX: number;
  32753. /**
  32754. * Gets or sets the current on-screen Y position of the pointer
  32755. */
  32756. pointerY: number;
  32757. /**
  32758. * Gets the cached material (ie. the latest rendered one)
  32759. * @returns the cached material
  32760. */
  32761. getCachedMaterial(): Nullable<Material>;
  32762. /**
  32763. * Gets the cached effect (ie. the latest rendered one)
  32764. * @returns the cached effect
  32765. */
  32766. getCachedEffect(): Nullable<Effect>;
  32767. /**
  32768. * Gets the cached visibility state (ie. the latest rendered one)
  32769. * @returns the cached visibility state
  32770. */
  32771. getCachedVisibility(): Nullable<number>;
  32772. /**
  32773. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32774. * @param material defines the current material
  32775. * @param effect defines the current effect
  32776. * @param visibility defines the current visibility state
  32777. * @returns true if one parameter is not cached
  32778. */
  32779. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32780. /**
  32781. * Gets the engine associated with the scene
  32782. * @returns an Engine
  32783. */
  32784. getEngine(): Engine;
  32785. /**
  32786. * Gets the total number of vertices rendered per frame
  32787. * @returns the total number of vertices rendered per frame
  32788. */
  32789. getTotalVertices(): number;
  32790. /**
  32791. * Gets the performance counter for total vertices
  32792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32793. */
  32794. readonly totalVerticesPerfCounter: PerfCounter;
  32795. /**
  32796. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32797. * @returns the total number of active indices rendered per frame
  32798. */
  32799. getActiveIndices(): number;
  32800. /**
  32801. * Gets the performance counter for active indices
  32802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32803. */
  32804. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32805. /**
  32806. * Gets the total number of active particles rendered per frame
  32807. * @returns the total number of active particles rendered per frame
  32808. */
  32809. getActiveParticles(): number;
  32810. /**
  32811. * Gets the performance counter for active particles
  32812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32813. */
  32814. readonly activeParticlesPerfCounter: PerfCounter;
  32815. /**
  32816. * Gets the total number of active bones rendered per frame
  32817. * @returns the total number of active bones rendered per frame
  32818. */
  32819. getActiveBones(): number;
  32820. /**
  32821. * Gets the performance counter for active bones
  32822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32823. */
  32824. readonly activeBonesPerfCounter: PerfCounter;
  32825. /**
  32826. * Gets the array of active meshes
  32827. * @returns an array of AbstractMesh
  32828. */
  32829. getActiveMeshes(): SmartArray<AbstractMesh>;
  32830. /**
  32831. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32832. * @returns a number
  32833. */
  32834. getAnimationRatio(): number;
  32835. /**
  32836. * Gets an unique Id for the current render phase
  32837. * @returns a number
  32838. */
  32839. getRenderId(): number;
  32840. /**
  32841. * Gets an unique Id for the current frame
  32842. * @returns a number
  32843. */
  32844. getFrameId(): number;
  32845. /** Call this function if you want to manually increment the render Id*/
  32846. incrementRenderId(): void;
  32847. private _updatePointerPosition;
  32848. private _createUbo;
  32849. private _createAlternateUbo;
  32850. private _setRayOnPointerInfo;
  32851. /**
  32852. * Use this method to simulate a pointer move on a mesh
  32853. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32854. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32855. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32856. * @returns the current scene
  32857. */
  32858. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32859. private _processPointerMove;
  32860. private _checkPrePointerObservable;
  32861. /**
  32862. * Use this method to simulate a pointer down on a mesh
  32863. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32864. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32865. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32866. * @returns the current scene
  32867. */
  32868. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32869. private _processPointerDown;
  32870. /**
  32871. * Use this method to simulate a pointer up on a mesh
  32872. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32873. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32874. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32875. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32876. * @returns the current scene
  32877. */
  32878. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32879. private _processPointerUp;
  32880. /**
  32881. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32882. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32883. * @returns true if the pointer was captured
  32884. */
  32885. isPointerCaptured(pointerId?: number): boolean;
  32886. /** @hidden */
  32887. _isPointerSwiping(): boolean;
  32888. /**
  32889. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32890. * @param attachUp defines if you want to attach events to pointerup
  32891. * @param attachDown defines if you want to attach events to pointerdown
  32892. * @param attachMove defines if you want to attach events to pointermove
  32893. */
  32894. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32895. /** Detaches all event handlers*/
  32896. detachControl(): void;
  32897. /**
  32898. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32899. * Delay loaded resources are not taking in account
  32900. * @return true if all required resources are ready
  32901. */
  32902. isReady(): boolean;
  32903. /** Resets all cached information relative to material (including effect and visibility) */
  32904. resetCachedMaterial(): void;
  32905. /**
  32906. * Registers a function to be called before every frame render
  32907. * @param func defines the function to register
  32908. */
  32909. registerBeforeRender(func: () => void): void;
  32910. /**
  32911. * Unregisters a function called before every frame render
  32912. * @param func defines the function to unregister
  32913. */
  32914. unregisterBeforeRender(func: () => void): void;
  32915. /**
  32916. * Registers a function to be called after every frame render
  32917. * @param func defines the function to register
  32918. */
  32919. registerAfterRender(func: () => void): void;
  32920. /**
  32921. * Unregisters a function called after every frame render
  32922. * @param func defines the function to unregister
  32923. */
  32924. unregisterAfterRender(func: () => void): void;
  32925. private _executeOnceBeforeRender;
  32926. /**
  32927. * The provided function will run before render once and will be disposed afterwards.
  32928. * A timeout delay can be provided so that the function will be executed in N ms.
  32929. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32930. * @param func The function to be executed.
  32931. * @param timeout optional delay in ms
  32932. */
  32933. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32934. /** @hidden */
  32935. _addPendingData(data: any): void;
  32936. /** @hidden */
  32937. _removePendingData(data: any): void;
  32938. /**
  32939. * Returns the number of items waiting to be loaded
  32940. * @returns the number of items waiting to be loaded
  32941. */
  32942. getWaitingItemsCount(): number;
  32943. /**
  32944. * Returns a boolean indicating if the scene is still loading data
  32945. */
  32946. readonly isLoading: boolean;
  32947. /**
  32948. * Registers a function to be executed when the scene is ready
  32949. * @param {Function} func - the function to be executed
  32950. */
  32951. executeWhenReady(func: () => void): void;
  32952. /**
  32953. * Returns a promise that resolves when the scene is ready
  32954. * @returns A promise that resolves when the scene is ready
  32955. */
  32956. whenReadyAsync(): Promise<void>;
  32957. /** @hidden */
  32958. _checkIsReady(): void;
  32959. /**
  32960. * Gets all animatable attached to the scene
  32961. */
  32962. readonly animatables: Animatable[];
  32963. /**
  32964. * Resets the last animation time frame.
  32965. * Useful to override when animations start running when loading a scene for the first time.
  32966. */
  32967. resetLastAnimationTimeFrame(): void;
  32968. /** @hidden */
  32969. _switchToAlternateCameraConfiguration(active: boolean): void;
  32970. /**
  32971. * Gets the current view matrix
  32972. * @returns a Matrix
  32973. */
  32974. getViewMatrix(): Matrix;
  32975. /**
  32976. * Gets the current projection matrix
  32977. * @returns a Matrix
  32978. */
  32979. getProjectionMatrix(): Matrix;
  32980. /**
  32981. * Gets the current transform matrix
  32982. * @returns a Matrix made of View * Projection
  32983. */
  32984. getTransformMatrix(): Matrix;
  32985. /**
  32986. * Sets the current transform matrix
  32987. * @param view defines the View matrix to use
  32988. * @param projection defines the Projection matrix to use
  32989. */
  32990. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32991. /** @hidden */
  32992. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32993. /**
  32994. * Gets the uniform buffer used to store scene data
  32995. * @returns a UniformBuffer
  32996. */
  32997. getSceneUniformBuffer(): UniformBuffer;
  32998. /**
  32999. * Gets an unique (relatively to the current scene) Id
  33000. * @returns an unique number for the scene
  33001. */
  33002. getUniqueId(): number;
  33003. /**
  33004. * Add a mesh to the list of scene's meshes
  33005. * @param newMesh defines the mesh to add
  33006. * @param recursive if all child meshes should also be added to the scene
  33007. */
  33008. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33009. /**
  33010. * Remove a mesh for the list of scene's meshes
  33011. * @param toRemove defines the mesh to remove
  33012. * @param recursive if all child meshes should also be removed from the scene
  33013. * @returns the index where the mesh was in the mesh list
  33014. */
  33015. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33016. /**
  33017. * Add a transform node to the list of scene's transform nodes
  33018. * @param newTransformNode defines the transform node to add
  33019. */
  33020. addTransformNode(newTransformNode: TransformNode): void;
  33021. /**
  33022. * Remove a transform node for the list of scene's transform nodes
  33023. * @param toRemove defines the transform node to remove
  33024. * @returns the index where the transform node was in the transform node list
  33025. */
  33026. removeTransformNode(toRemove: TransformNode): number;
  33027. /**
  33028. * Remove a skeleton for the list of scene's skeletons
  33029. * @param toRemove defines the skeleton to remove
  33030. * @returns the index where the skeleton was in the skeleton list
  33031. */
  33032. removeSkeleton(toRemove: Skeleton): number;
  33033. /**
  33034. * Remove a morph target for the list of scene's morph targets
  33035. * @param toRemove defines the morph target to remove
  33036. * @returns the index where the morph target was in the morph target list
  33037. */
  33038. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33039. /**
  33040. * Remove a light for the list of scene's lights
  33041. * @param toRemove defines the light to remove
  33042. * @returns the index where the light was in the light list
  33043. */
  33044. removeLight(toRemove: Light): number;
  33045. /**
  33046. * Remove a camera for the list of scene's cameras
  33047. * @param toRemove defines the camera to remove
  33048. * @returns the index where the camera was in the camera list
  33049. */
  33050. removeCamera(toRemove: Camera): number;
  33051. /**
  33052. * Remove a particle system for the list of scene's particle systems
  33053. * @param toRemove defines the particle system to remove
  33054. * @returns the index where the particle system was in the particle system list
  33055. */
  33056. removeParticleSystem(toRemove: IParticleSystem): number;
  33057. /**
  33058. * Remove a animation for the list of scene's animations
  33059. * @param toRemove defines the animation to remove
  33060. * @returns the index where the animation was in the animation list
  33061. */
  33062. removeAnimation(toRemove: Animation): number;
  33063. /**
  33064. * Removes the given animation group from this scene.
  33065. * @param toRemove The animation group to remove
  33066. * @returns The index of the removed animation group
  33067. */
  33068. removeAnimationGroup(toRemove: AnimationGroup): number;
  33069. /**
  33070. * Removes the given multi-material from this scene.
  33071. * @param toRemove The multi-material to remove
  33072. * @returns The index of the removed multi-material
  33073. */
  33074. removeMultiMaterial(toRemove: MultiMaterial): number;
  33075. /**
  33076. * Removes the given material from this scene.
  33077. * @param toRemove The material to remove
  33078. * @returns The index of the removed material
  33079. */
  33080. removeMaterial(toRemove: Material): number;
  33081. /**
  33082. * Removes the given action manager from this scene.
  33083. * @param toRemove The action manager to remove
  33084. * @returns The index of the removed action manager
  33085. */
  33086. removeActionManager(toRemove: AbstractActionManager): number;
  33087. /**
  33088. * Removes the given texture from this scene.
  33089. * @param toRemove The texture to remove
  33090. * @returns The index of the removed texture
  33091. */
  33092. removeTexture(toRemove: BaseTexture): number;
  33093. /**
  33094. * Adds the given light to this scene
  33095. * @param newLight The light to add
  33096. */
  33097. addLight(newLight: Light): void;
  33098. /**
  33099. * Sorts the list list based on light priorities
  33100. */
  33101. sortLightsByPriority(): void;
  33102. /**
  33103. * Adds the given camera to this scene
  33104. * @param newCamera The camera to add
  33105. */
  33106. addCamera(newCamera: Camera): void;
  33107. /**
  33108. * Adds the given skeleton to this scene
  33109. * @param newSkeleton The skeleton to add
  33110. */
  33111. addSkeleton(newSkeleton: Skeleton): void;
  33112. /**
  33113. * Adds the given particle system to this scene
  33114. * @param newParticleSystem The particle system to add
  33115. */
  33116. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33117. /**
  33118. * Adds the given animation to this scene
  33119. * @param newAnimation The animation to add
  33120. */
  33121. addAnimation(newAnimation: Animation): void;
  33122. /**
  33123. * Adds the given animation group to this scene.
  33124. * @param newAnimationGroup The animation group to add
  33125. */
  33126. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33127. /**
  33128. * Adds the given multi-material to this scene
  33129. * @param newMultiMaterial The multi-material to add
  33130. */
  33131. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33132. /**
  33133. * Adds the given material to this scene
  33134. * @param newMaterial The material to add
  33135. */
  33136. addMaterial(newMaterial: Material): void;
  33137. /**
  33138. * Adds the given morph target to this scene
  33139. * @param newMorphTargetManager The morph target to add
  33140. */
  33141. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33142. /**
  33143. * Adds the given geometry to this scene
  33144. * @param newGeometry The geometry to add
  33145. */
  33146. addGeometry(newGeometry: Geometry): void;
  33147. /**
  33148. * Adds the given action manager to this scene
  33149. * @param newActionManager The action manager to add
  33150. */
  33151. addActionManager(newActionManager: AbstractActionManager): void;
  33152. /**
  33153. * Adds the given texture to this scene.
  33154. * @param newTexture The texture to add
  33155. */
  33156. addTexture(newTexture: BaseTexture): void;
  33157. /**
  33158. * Switch active camera
  33159. * @param newCamera defines the new active camera
  33160. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33161. */
  33162. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33163. /**
  33164. * sets the active camera of the scene using its ID
  33165. * @param id defines the camera's ID
  33166. * @return the new active camera or null if none found.
  33167. */
  33168. setActiveCameraByID(id: string): Nullable<Camera>;
  33169. /**
  33170. * sets the active camera of the scene using its name
  33171. * @param name defines the camera's name
  33172. * @returns the new active camera or null if none found.
  33173. */
  33174. setActiveCameraByName(name: string): Nullable<Camera>;
  33175. /**
  33176. * get an animation group using its name
  33177. * @param name defines the material's name
  33178. * @return the animation group or null if none found.
  33179. */
  33180. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33181. /**
  33182. * get a material using its id
  33183. * @param id defines the material's ID
  33184. * @return the material or null if none found.
  33185. */
  33186. getMaterialByID(id: string): Nullable<Material>;
  33187. /**
  33188. * Gets a material using its name
  33189. * @param name defines the material's name
  33190. * @return the material or null if none found.
  33191. */
  33192. getMaterialByName(name: string): Nullable<Material>;
  33193. /**
  33194. * Gets a camera using its id
  33195. * @param id defines the id to look for
  33196. * @returns the camera or null if not found
  33197. */
  33198. getCameraByID(id: string): Nullable<Camera>;
  33199. /**
  33200. * Gets a camera using its unique id
  33201. * @param uniqueId defines the unique id to look for
  33202. * @returns the camera or null if not found
  33203. */
  33204. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33205. /**
  33206. * Gets a camera using its name
  33207. * @param name defines the camera's name
  33208. * @return the camera or null if none found.
  33209. */
  33210. getCameraByName(name: string): Nullable<Camera>;
  33211. /**
  33212. * Gets a bone using its id
  33213. * @param id defines the bone's id
  33214. * @return the bone or null if not found
  33215. */
  33216. getBoneByID(id: string): Nullable<Bone>;
  33217. /**
  33218. * Gets a bone using its id
  33219. * @param name defines the bone's name
  33220. * @return the bone or null if not found
  33221. */
  33222. getBoneByName(name: string): Nullable<Bone>;
  33223. /**
  33224. * Gets a light node using its name
  33225. * @param name defines the the light's name
  33226. * @return the light or null if none found.
  33227. */
  33228. getLightByName(name: string): Nullable<Light>;
  33229. /**
  33230. * Gets a light node using its id
  33231. * @param id defines the light's id
  33232. * @return the light or null if none found.
  33233. */
  33234. getLightByID(id: string): Nullable<Light>;
  33235. /**
  33236. * Gets a light node using its scene-generated unique ID
  33237. * @param uniqueId defines the light's unique id
  33238. * @return the light or null if none found.
  33239. */
  33240. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33241. /**
  33242. * Gets a particle system by id
  33243. * @param id defines the particle system id
  33244. * @return the corresponding system or null if none found
  33245. */
  33246. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33247. /**
  33248. * Gets a geometry using its ID
  33249. * @param id defines the geometry's id
  33250. * @return the geometry or null if none found.
  33251. */
  33252. getGeometryByID(id: string): Nullable<Geometry>;
  33253. private _getGeometryByUniqueID;
  33254. /**
  33255. * Add a new geometry to this scene
  33256. * @param geometry defines the geometry to be added to the scene.
  33257. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33258. * @return a boolean defining if the geometry was added or not
  33259. */
  33260. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33261. /**
  33262. * Removes an existing geometry
  33263. * @param geometry defines the geometry to be removed from the scene
  33264. * @return a boolean defining if the geometry was removed or not
  33265. */
  33266. removeGeometry(geometry: Geometry): boolean;
  33267. /**
  33268. * Gets the list of geometries attached to the scene
  33269. * @returns an array of Geometry
  33270. */
  33271. getGeometries(): Geometry[];
  33272. /**
  33273. * Gets the first added mesh found of a given ID
  33274. * @param id defines the id to search for
  33275. * @return the mesh found or null if not found at all
  33276. */
  33277. getMeshByID(id: string): Nullable<AbstractMesh>;
  33278. /**
  33279. * Gets a list of meshes using their id
  33280. * @param id defines the id to search for
  33281. * @returns a list of meshes
  33282. */
  33283. getMeshesByID(id: string): Array<AbstractMesh>;
  33284. /**
  33285. * Gets the first added transform node found of a given ID
  33286. * @param id defines the id to search for
  33287. * @return the found transform node or null if not found at all.
  33288. */
  33289. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33290. /**
  33291. * Gets a list of transform nodes using their id
  33292. * @param id defines the id to search for
  33293. * @returns a list of transform nodes
  33294. */
  33295. getTransformNodesByID(id: string): Array<TransformNode>;
  33296. /**
  33297. * Gets a mesh with its auto-generated unique id
  33298. * @param uniqueId defines the unique id to search for
  33299. * @return the found mesh or null if not found at all.
  33300. */
  33301. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33302. /**
  33303. * Gets a the last added mesh using a given id
  33304. * @param id defines the id to search for
  33305. * @return the found mesh or null if not found at all.
  33306. */
  33307. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33308. /**
  33309. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33310. * @param id defines the id to search for
  33311. * @return the found node or null if not found at all
  33312. */
  33313. getLastEntryByID(id: string): Nullable<Node>;
  33314. /**
  33315. * Gets a node (Mesh, Camera, Light) using a given id
  33316. * @param id defines the id to search for
  33317. * @return the found node or null if not found at all
  33318. */
  33319. getNodeByID(id: string): Nullable<Node>;
  33320. /**
  33321. * Gets a node (Mesh, Camera, Light) using a given name
  33322. * @param name defines the name to search for
  33323. * @return the found node or null if not found at all.
  33324. */
  33325. getNodeByName(name: string): Nullable<Node>;
  33326. /**
  33327. * Gets a mesh using a given name
  33328. * @param name defines the name to search for
  33329. * @return the found mesh or null if not found at all.
  33330. */
  33331. getMeshByName(name: string): Nullable<AbstractMesh>;
  33332. /**
  33333. * Gets a transform node using a given name
  33334. * @param name defines the name to search for
  33335. * @return the found transform node or null if not found at all.
  33336. */
  33337. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33338. /**
  33339. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33340. * @param id defines the id to search for
  33341. * @return the found skeleton or null if not found at all.
  33342. */
  33343. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33344. /**
  33345. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33346. * @param id defines the id to search for
  33347. * @return the found skeleton or null if not found at all.
  33348. */
  33349. getSkeletonById(id: string): Nullable<Skeleton>;
  33350. /**
  33351. * Gets a skeleton using a given name
  33352. * @param name defines the name to search for
  33353. * @return the found skeleton or null if not found at all.
  33354. */
  33355. getSkeletonByName(name: string): Nullable<Skeleton>;
  33356. /**
  33357. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33358. * @param id defines the id to search for
  33359. * @return the found morph target manager or null if not found at all.
  33360. */
  33361. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33362. /**
  33363. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33364. * @param id defines the id to search for
  33365. * @return the found morph target or null if not found at all.
  33366. */
  33367. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33368. /**
  33369. * Gets a boolean indicating if the given mesh is active
  33370. * @param mesh defines the mesh to look for
  33371. * @returns true if the mesh is in the active list
  33372. */
  33373. isActiveMesh(mesh: AbstractMesh): boolean;
  33374. /**
  33375. * Return a unique id as a string which can serve as an identifier for the scene
  33376. */
  33377. readonly uid: string;
  33378. /**
  33379. * Add an externaly attached data from its key.
  33380. * This method call will fail and return false, if such key already exists.
  33381. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33382. * @param key the unique key that identifies the data
  33383. * @param data the data object to associate to the key for this Engine instance
  33384. * @return true if no such key were already present and the data was added successfully, false otherwise
  33385. */
  33386. addExternalData<T>(key: string, data: T): boolean;
  33387. /**
  33388. * Get an externaly attached data from its key
  33389. * @param key the unique key that identifies the data
  33390. * @return the associated data, if present (can be null), or undefined if not present
  33391. */
  33392. getExternalData<T>(key: string): Nullable<T>;
  33393. /**
  33394. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33395. * @param key the unique key that identifies the data
  33396. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33397. * @return the associated data, can be null if the factory returned null.
  33398. */
  33399. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33400. /**
  33401. * Remove an externaly attached data from the Engine instance
  33402. * @param key the unique key that identifies the data
  33403. * @return true if the data was successfully removed, false if it doesn't exist
  33404. */
  33405. removeExternalData(key: string): boolean;
  33406. private _evaluateSubMesh;
  33407. /**
  33408. * Clear the processed materials smart array preventing retention point in material dispose.
  33409. */
  33410. freeProcessedMaterials(): void;
  33411. private _preventFreeActiveMeshesAndRenderingGroups;
  33412. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33413. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33414. * when disposing several meshes in a row or a hierarchy of meshes.
  33415. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33416. */
  33417. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33418. /**
  33419. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33420. */
  33421. freeActiveMeshes(): void;
  33422. /**
  33423. * Clear the info related to rendering groups preventing retention points during dispose.
  33424. */
  33425. freeRenderingGroups(): void;
  33426. /** @hidden */
  33427. _isInIntermediateRendering(): boolean;
  33428. /**
  33429. * Lambda returning the list of potentially active meshes.
  33430. */
  33431. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33432. /**
  33433. * Lambda returning the list of potentially active sub meshes.
  33434. */
  33435. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33436. /**
  33437. * Lambda returning the list of potentially intersecting sub meshes.
  33438. */
  33439. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33440. /**
  33441. * Lambda returning the list of potentially colliding sub meshes.
  33442. */
  33443. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33444. private _activeMeshesFrozen;
  33445. /**
  33446. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33447. * @returns the current scene
  33448. */
  33449. freezeActiveMeshes(): Scene;
  33450. /**
  33451. * Use this function to restart evaluating active meshes on every frame
  33452. * @returns the current scene
  33453. */
  33454. unfreezeActiveMeshes(): Scene;
  33455. private _evaluateActiveMeshes;
  33456. private _activeMesh;
  33457. /**
  33458. * Update the transform matrix to update from the current active camera
  33459. * @param force defines a boolean used to force the update even if cache is up to date
  33460. */
  33461. updateTransformMatrix(force?: boolean): void;
  33462. /**
  33463. * 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)
  33464. * @param alternateCamera defines the camera to use
  33465. */
  33466. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33467. /** @hidden */
  33468. _allowPostProcessClearColor: boolean;
  33469. private _renderForCamera;
  33470. private _processSubCameras;
  33471. private _checkIntersections;
  33472. /** @hidden */
  33473. _advancePhysicsEngineStep(step: number): void;
  33474. /**
  33475. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33476. */
  33477. getDeterministicFrameTime: () => number;
  33478. /** @hidden */
  33479. _animate(): void;
  33480. /**
  33481. * Render the scene
  33482. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33483. */
  33484. render(updateCameras?: boolean): void;
  33485. /**
  33486. * Freeze all materials
  33487. * A frozen material will not be updatable but should be faster to render
  33488. */
  33489. freezeMaterials(): void;
  33490. /**
  33491. * Unfreeze all materials
  33492. * A frozen material will not be updatable but should be faster to render
  33493. */
  33494. unfreezeMaterials(): void;
  33495. /**
  33496. * Releases all held ressources
  33497. */
  33498. dispose(): void;
  33499. /**
  33500. * Gets if the scene is already disposed
  33501. */
  33502. readonly isDisposed: boolean;
  33503. /**
  33504. * Call this function to reduce memory footprint of the scene.
  33505. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33506. */
  33507. clearCachedVertexData(): void;
  33508. /**
  33509. * This function will remove the local cached buffer data from texture.
  33510. * It will save memory but will prevent the texture from being rebuilt
  33511. */
  33512. cleanCachedTextureBuffer(): void;
  33513. /**
  33514. * Get the world extend vectors with an optional filter
  33515. *
  33516. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33517. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33518. */
  33519. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33520. min: Vector3;
  33521. max: Vector3;
  33522. };
  33523. /**
  33524. * Creates a ray that can be used to pick in the scene
  33525. * @param x defines the x coordinate of the origin (on-screen)
  33526. * @param y defines the y coordinate of the origin (on-screen)
  33527. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33528. * @param camera defines the camera to use for the picking
  33529. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33530. * @returns a Ray
  33531. */
  33532. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33533. /**
  33534. * Creates a ray that can be used to pick in the scene
  33535. * @param x defines the x coordinate of the origin (on-screen)
  33536. * @param y defines the y coordinate of the origin (on-screen)
  33537. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33538. * @param result defines the ray where to store the picking ray
  33539. * @param camera defines the camera to use for the picking
  33540. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33541. * @returns the current scene
  33542. */
  33543. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33544. /**
  33545. * Creates a ray that can be used to pick in the scene
  33546. * @param x defines the x coordinate of the origin (on-screen)
  33547. * @param y defines the y coordinate of the origin (on-screen)
  33548. * @param camera defines the camera to use for the picking
  33549. * @returns a Ray
  33550. */
  33551. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33552. /**
  33553. * Creates a ray that can be used to pick in the scene
  33554. * @param x defines the x coordinate of the origin (on-screen)
  33555. * @param y defines the y coordinate of the origin (on-screen)
  33556. * @param result defines the ray where to store the picking ray
  33557. * @param camera defines the camera to use for the picking
  33558. * @returns the current scene
  33559. */
  33560. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33561. /** Launch a ray to try to pick a mesh in the scene
  33562. * @param x position on screen
  33563. * @param y position on screen
  33564. * @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
  33565. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33566. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33567. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33568. * @returns a PickingInfo
  33569. */
  33570. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33571. /** Use the given ray to pick a mesh in the scene
  33572. * @param ray The ray to use to pick meshes
  33573. * @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
  33574. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33575. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33576. * @returns a PickingInfo
  33577. */
  33578. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33579. /**
  33580. * Launch a ray to try to pick a mesh in the scene
  33581. * @param x X position on screen
  33582. * @param y Y position on screen
  33583. * @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
  33584. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33585. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33586. * @returns an array of PickingInfo
  33587. */
  33588. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33589. /**
  33590. * Launch a ray to try to pick a mesh in the scene
  33591. * @param ray Ray to use
  33592. * @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
  33593. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33594. * @returns an array of PickingInfo
  33595. */
  33596. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33597. /**
  33598. * Force the value of meshUnderPointer
  33599. * @param mesh defines the mesh to use
  33600. */
  33601. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33602. /**
  33603. * Gets the mesh under the pointer
  33604. * @returns a Mesh or null if no mesh is under the pointer
  33605. */
  33606. getPointerOverMesh(): Nullable<AbstractMesh>;
  33607. /** @hidden */
  33608. _rebuildGeometries(): void;
  33609. /** @hidden */
  33610. _rebuildTextures(): void;
  33611. private _getByTags;
  33612. /**
  33613. * Get a list of meshes by tags
  33614. * @param tagsQuery defines the tags query to use
  33615. * @param forEach defines a predicate used to filter results
  33616. * @returns an array of Mesh
  33617. */
  33618. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33619. /**
  33620. * Get a list of cameras by tags
  33621. * @param tagsQuery defines the tags query to use
  33622. * @param forEach defines a predicate used to filter results
  33623. * @returns an array of Camera
  33624. */
  33625. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33626. /**
  33627. * Get a list of lights by tags
  33628. * @param tagsQuery defines the tags query to use
  33629. * @param forEach defines a predicate used to filter results
  33630. * @returns an array of Light
  33631. */
  33632. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33633. /**
  33634. * Get a list of materials by tags
  33635. * @param tagsQuery defines the tags query to use
  33636. * @param forEach defines a predicate used to filter results
  33637. * @returns an array of Material
  33638. */
  33639. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33640. /**
  33641. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33642. * This allowed control for front to back rendering or reversly depending of the special needs.
  33643. *
  33644. * @param renderingGroupId The rendering group id corresponding to its index
  33645. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33646. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33647. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33648. */
  33649. 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;
  33650. /**
  33651. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33652. *
  33653. * @param renderingGroupId The rendering group id corresponding to its index
  33654. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33655. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33656. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33657. */
  33658. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33659. /**
  33660. * Gets the current auto clear configuration for one rendering group of the rendering
  33661. * manager.
  33662. * @param index the rendering group index to get the information for
  33663. * @returns The auto clear setup for the requested rendering group
  33664. */
  33665. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33666. private _blockMaterialDirtyMechanism;
  33667. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33668. blockMaterialDirtyMechanism: boolean;
  33669. /**
  33670. * Will flag all materials as dirty to trigger new shader compilation
  33671. * @param flag defines the flag used to specify which material part must be marked as dirty
  33672. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33673. */
  33674. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33675. /** @hidden */
  33676. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33677. /** @hidden */
  33678. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33679. }
  33680. }
  33681. declare module "babylonjs/assetContainer" {
  33682. import { AbstractScene } from "babylonjs/abstractScene";
  33683. import { Scene } from "babylonjs/scene";
  33684. import { Mesh } from "babylonjs/Meshes/mesh";
  33685. /**
  33686. * Set of assets to keep when moving a scene into an asset container.
  33687. */
  33688. export class KeepAssets extends AbstractScene {
  33689. }
  33690. /**
  33691. * Container with a set of assets that can be added or removed from a scene.
  33692. */
  33693. export class AssetContainer extends AbstractScene {
  33694. /**
  33695. * The scene the AssetContainer belongs to.
  33696. */
  33697. scene: Scene;
  33698. /**
  33699. * Instantiates an AssetContainer.
  33700. * @param scene The scene the AssetContainer belongs to.
  33701. */
  33702. constructor(scene: Scene);
  33703. /**
  33704. * Adds all the assets from the container to the scene.
  33705. */
  33706. addAllToScene(): void;
  33707. /**
  33708. * Removes all the assets in the container from the scene
  33709. */
  33710. removeAllFromScene(): void;
  33711. /**
  33712. * Disposes all the assets in the container
  33713. */
  33714. dispose(): void;
  33715. private _moveAssets;
  33716. /**
  33717. * Removes all the assets contained in the scene and adds them to the container.
  33718. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33719. */
  33720. moveAllFromScene(keepAssets?: KeepAssets): void;
  33721. /**
  33722. * 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.
  33723. * @returns the root mesh
  33724. */
  33725. createRootMesh(): Mesh;
  33726. }
  33727. }
  33728. declare module "babylonjs/abstractScene" {
  33729. import { Scene } from "babylonjs/scene";
  33730. import { Nullable } from "babylonjs/types";
  33731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33733. import { Geometry } from "babylonjs/Meshes/geometry";
  33734. import { Skeleton } from "babylonjs/Bones/skeleton";
  33735. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33736. import { AssetContainer } from "babylonjs/assetContainer";
  33737. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33738. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33739. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33740. import { Material } from "babylonjs/Materials/material";
  33741. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33742. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33743. import { Camera } from "babylonjs/Cameras/camera";
  33744. import { Light } from "babylonjs/Lights/light";
  33745. import { Node } from "babylonjs/node";
  33746. import { Animation } from "babylonjs/Animations/animation";
  33747. /**
  33748. * Defines how the parser contract is defined.
  33749. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33750. */
  33751. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33752. /**
  33753. * Defines how the individual parser contract is defined.
  33754. * These parser can parse an individual asset
  33755. */
  33756. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33757. /**
  33758. * Base class of the scene acting as a container for the different elements composing a scene.
  33759. * This class is dynamically extended by the different components of the scene increasing
  33760. * flexibility and reducing coupling
  33761. */
  33762. export abstract class AbstractScene {
  33763. /**
  33764. * Stores the list of available parsers in the application.
  33765. */
  33766. private static _BabylonFileParsers;
  33767. /**
  33768. * Stores the list of available individual parsers in the application.
  33769. */
  33770. private static _IndividualBabylonFileParsers;
  33771. /**
  33772. * Adds a parser in the list of available ones
  33773. * @param name Defines the name of the parser
  33774. * @param parser Defines the parser to add
  33775. */
  33776. static AddParser(name: string, parser: BabylonFileParser): void;
  33777. /**
  33778. * Gets a general parser from the list of avaialble ones
  33779. * @param name Defines the name of the parser
  33780. * @returns the requested parser or null
  33781. */
  33782. static GetParser(name: string): Nullable<BabylonFileParser>;
  33783. /**
  33784. * Adds n individual parser in the list of available ones
  33785. * @param name Defines the name of the parser
  33786. * @param parser Defines the parser to add
  33787. */
  33788. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33789. /**
  33790. * Gets an individual parser from the list of avaialble ones
  33791. * @param name Defines the name of the parser
  33792. * @returns the requested parser or null
  33793. */
  33794. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33795. /**
  33796. * Parser json data and populate both a scene and its associated container object
  33797. * @param jsonData Defines the data to parse
  33798. * @param scene Defines the scene to parse the data for
  33799. * @param container Defines the container attached to the parsing sequence
  33800. * @param rootUrl Defines the root url of the data
  33801. */
  33802. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33803. /**
  33804. * Gets the list of root nodes (ie. nodes with no parent)
  33805. */
  33806. rootNodes: Node[];
  33807. /** All of the cameras added to this scene
  33808. * @see http://doc.babylonjs.com/babylon101/cameras
  33809. */
  33810. cameras: Camera[];
  33811. /**
  33812. * All of the lights added to this scene
  33813. * @see http://doc.babylonjs.com/babylon101/lights
  33814. */
  33815. lights: Light[];
  33816. /**
  33817. * All of the (abstract) meshes added to this scene
  33818. */
  33819. meshes: AbstractMesh[];
  33820. /**
  33821. * The list of skeletons added to the scene
  33822. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33823. */
  33824. skeletons: Skeleton[];
  33825. /**
  33826. * All of the particle systems added to this scene
  33827. * @see http://doc.babylonjs.com/babylon101/particles
  33828. */
  33829. particleSystems: IParticleSystem[];
  33830. /**
  33831. * Gets a list of Animations associated with the scene
  33832. */
  33833. animations: Animation[];
  33834. /**
  33835. * All of the animation groups added to this scene
  33836. * @see http://doc.babylonjs.com/how_to/group
  33837. */
  33838. animationGroups: AnimationGroup[];
  33839. /**
  33840. * All of the multi-materials added to this scene
  33841. * @see http://doc.babylonjs.com/how_to/multi_materials
  33842. */
  33843. multiMaterials: MultiMaterial[];
  33844. /**
  33845. * All of the materials added to this scene
  33846. * In the context of a Scene, it is not supposed to be modified manually.
  33847. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33848. * Note also that the order of the Material wihin the array is not significant and might change.
  33849. * @see http://doc.babylonjs.com/babylon101/materials
  33850. */
  33851. materials: Material[];
  33852. /**
  33853. * The list of morph target managers added to the scene
  33854. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33855. */
  33856. morphTargetManagers: MorphTargetManager[];
  33857. /**
  33858. * The list of geometries used in the scene.
  33859. */
  33860. geometries: Geometry[];
  33861. /**
  33862. * All of the tranform nodes added to this scene
  33863. * In the context of a Scene, it is not supposed to be modified manually.
  33864. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33865. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33866. * @see http://doc.babylonjs.com/how_to/transformnode
  33867. */
  33868. transformNodes: TransformNode[];
  33869. /**
  33870. * ActionManagers available on the scene.
  33871. */
  33872. actionManagers: AbstractActionManager[];
  33873. /**
  33874. * Textures to keep.
  33875. */
  33876. textures: BaseTexture[];
  33877. }
  33878. }
  33879. declare module "babylonjs/Audio/sound" {
  33880. import { Observable } from "babylonjs/Misc/observable";
  33881. import { Vector3 } from "babylonjs/Maths/math";
  33882. import { Nullable } from "babylonjs/types";
  33883. import { Scene } from "babylonjs/scene";
  33884. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33885. /**
  33886. * Defines a sound that can be played in the application.
  33887. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33889. */
  33890. export class Sound {
  33891. /**
  33892. * The name of the sound in the scene.
  33893. */
  33894. name: string;
  33895. /**
  33896. * Does the sound autoplay once loaded.
  33897. */
  33898. autoplay: boolean;
  33899. /**
  33900. * Does the sound loop after it finishes playing once.
  33901. */
  33902. loop: boolean;
  33903. /**
  33904. * Does the sound use a custom attenuation curve to simulate the falloff
  33905. * happening when the source gets further away from the camera.
  33906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33907. */
  33908. useCustomAttenuation: boolean;
  33909. /**
  33910. * The sound track id this sound belongs to.
  33911. */
  33912. soundTrackId: number;
  33913. /**
  33914. * Is this sound currently played.
  33915. */
  33916. isPlaying: boolean;
  33917. /**
  33918. * Is this sound currently paused.
  33919. */
  33920. isPaused: boolean;
  33921. /**
  33922. * Does this sound enables spatial sound.
  33923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33924. */
  33925. spatialSound: boolean;
  33926. /**
  33927. * Define the reference distance the sound should be heard perfectly.
  33928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33929. */
  33930. refDistance: number;
  33931. /**
  33932. * Define the roll off factor of spatial sounds.
  33933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33934. */
  33935. rolloffFactor: number;
  33936. /**
  33937. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33939. */
  33940. maxDistance: number;
  33941. /**
  33942. * Define the distance attenuation model the sound will follow.
  33943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33944. */
  33945. distanceModel: string;
  33946. /**
  33947. * @hidden
  33948. * Back Compat
  33949. **/
  33950. onended: () => any;
  33951. /**
  33952. * Observable event when the current playing sound finishes.
  33953. */
  33954. onEndedObservable: Observable<Sound>;
  33955. private _panningModel;
  33956. private _playbackRate;
  33957. private _streaming;
  33958. private _startTime;
  33959. private _startOffset;
  33960. private _position;
  33961. /** @hidden */
  33962. _positionInEmitterSpace: boolean;
  33963. private _localDirection;
  33964. private _volume;
  33965. private _isReadyToPlay;
  33966. private _isDirectional;
  33967. private _readyToPlayCallback;
  33968. private _audioBuffer;
  33969. private _soundSource;
  33970. private _streamingSource;
  33971. private _soundPanner;
  33972. private _soundGain;
  33973. private _inputAudioNode;
  33974. private _outputAudioNode;
  33975. private _coneInnerAngle;
  33976. private _coneOuterAngle;
  33977. private _coneOuterGain;
  33978. private _scene;
  33979. private _connectedTransformNode;
  33980. private _customAttenuationFunction;
  33981. private _registerFunc;
  33982. private _isOutputConnected;
  33983. private _htmlAudioElement;
  33984. private _urlType;
  33985. /** @hidden */
  33986. static _SceneComponentInitialization: (scene: Scene) => void;
  33987. /**
  33988. * Create a sound and attach it to a scene
  33989. * @param name Name of your sound
  33990. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33991. * @param scene defines the scene the sound belongs to
  33992. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33993. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33994. */
  33995. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33996. /**
  33997. * Release the sound and its associated resources
  33998. */
  33999. dispose(): void;
  34000. /**
  34001. * Gets if the sounds is ready to be played or not.
  34002. * @returns true if ready, otherwise false
  34003. */
  34004. isReady(): boolean;
  34005. private _soundLoaded;
  34006. /**
  34007. * Sets the data of the sound from an audiobuffer
  34008. * @param audioBuffer The audioBuffer containing the data
  34009. */
  34010. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34011. /**
  34012. * Updates the current sounds options such as maxdistance, loop...
  34013. * @param options A JSON object containing values named as the object properties
  34014. */
  34015. updateOptions(options: any): void;
  34016. private _createSpatialParameters;
  34017. private _updateSpatialParameters;
  34018. /**
  34019. * Switch the panning model to HRTF:
  34020. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34022. */
  34023. switchPanningModelToHRTF(): void;
  34024. /**
  34025. * Switch the panning model to Equal Power:
  34026. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34028. */
  34029. switchPanningModelToEqualPower(): void;
  34030. private _switchPanningModel;
  34031. /**
  34032. * Connect this sound to a sound track audio node like gain...
  34033. * @param soundTrackAudioNode the sound track audio node to connect to
  34034. */
  34035. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34036. /**
  34037. * Transform this sound into a directional source
  34038. * @param coneInnerAngle Size of the inner cone in degree
  34039. * @param coneOuterAngle Size of the outer cone in degree
  34040. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34041. */
  34042. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34043. /**
  34044. * Gets or sets the inner angle for the directional cone.
  34045. */
  34046. /**
  34047. * Gets or sets the inner angle for the directional cone.
  34048. */
  34049. directionalConeInnerAngle: number;
  34050. /**
  34051. * Gets or sets the outer angle for the directional cone.
  34052. */
  34053. /**
  34054. * Gets or sets the outer angle for the directional cone.
  34055. */
  34056. directionalConeOuterAngle: number;
  34057. /**
  34058. * Sets the position of the emitter if spatial sound is enabled
  34059. * @param newPosition Defines the new posisiton
  34060. */
  34061. setPosition(newPosition: Vector3): void;
  34062. /**
  34063. * Sets the local direction of the emitter if spatial sound is enabled
  34064. * @param newLocalDirection Defines the new local direction
  34065. */
  34066. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34067. private _updateDirection;
  34068. /** @hidden */
  34069. updateDistanceFromListener(): void;
  34070. /**
  34071. * Sets a new custom attenuation function for the sound.
  34072. * @param callback Defines the function used for the attenuation
  34073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34074. */
  34075. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34076. /**
  34077. * Play the sound
  34078. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34079. * @param offset (optional) Start the sound setting it at a specific time
  34080. */
  34081. play(time?: number, offset?: number): void;
  34082. private _onended;
  34083. /**
  34084. * Stop the sound
  34085. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34086. */
  34087. stop(time?: number): void;
  34088. /**
  34089. * Put the sound in pause
  34090. */
  34091. pause(): void;
  34092. /**
  34093. * Sets a dedicated volume for this sounds
  34094. * @param newVolume Define the new volume of the sound
  34095. * @param time Define in how long the sound should be at this value
  34096. */
  34097. setVolume(newVolume: number, time?: number): void;
  34098. /**
  34099. * Set the sound play back rate
  34100. * @param newPlaybackRate Define the playback rate the sound should be played at
  34101. */
  34102. setPlaybackRate(newPlaybackRate: number): void;
  34103. /**
  34104. * Gets the volume of the sound.
  34105. * @returns the volume of the sound
  34106. */
  34107. getVolume(): number;
  34108. /**
  34109. * Attach the sound to a dedicated mesh
  34110. * @param transformNode The transform node to connect the sound with
  34111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34112. */
  34113. attachToMesh(transformNode: TransformNode): void;
  34114. /**
  34115. * Detach the sound from the previously attached mesh
  34116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34117. */
  34118. detachFromMesh(): void;
  34119. private _onRegisterAfterWorldMatrixUpdate;
  34120. /**
  34121. * Clone the current sound in the scene.
  34122. * @returns the new sound clone
  34123. */
  34124. clone(): Nullable<Sound>;
  34125. /**
  34126. * Gets the current underlying audio buffer containing the data
  34127. * @returns the audio buffer
  34128. */
  34129. getAudioBuffer(): Nullable<AudioBuffer>;
  34130. /**
  34131. * Serializes the Sound in a JSON representation
  34132. * @returns the JSON representation of the sound
  34133. */
  34134. serialize(): any;
  34135. /**
  34136. * Parse a JSON representation of a sound to innstantiate in a given scene
  34137. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34138. * @param scene Define the scene the new parsed sound should be created in
  34139. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34140. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34141. * @returns the newly parsed sound
  34142. */
  34143. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34144. }
  34145. }
  34146. declare module "babylonjs/Actions/directAudioActions" {
  34147. import { Action } from "babylonjs/Actions/action";
  34148. import { Condition } from "babylonjs/Actions/condition";
  34149. import { Sound } from "babylonjs/Audio/sound";
  34150. /**
  34151. * This defines an action helpful to play a defined sound on a triggered action.
  34152. */
  34153. export class PlaySoundAction extends Action {
  34154. private _sound;
  34155. /**
  34156. * Instantiate the action
  34157. * @param triggerOptions defines the trigger options
  34158. * @param sound defines the sound to play
  34159. * @param condition defines the trigger related conditions
  34160. */
  34161. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34162. /** @hidden */
  34163. _prepare(): void;
  34164. /**
  34165. * Execute the action and play the sound.
  34166. */
  34167. execute(): void;
  34168. /**
  34169. * Serializes the actions and its related information.
  34170. * @param parent defines the object to serialize in
  34171. * @returns the serialized object
  34172. */
  34173. serialize(parent: any): any;
  34174. }
  34175. /**
  34176. * This defines an action helpful to stop a defined sound on a triggered action.
  34177. */
  34178. export class StopSoundAction extends Action {
  34179. private _sound;
  34180. /**
  34181. * Instantiate the action
  34182. * @param triggerOptions defines the trigger options
  34183. * @param sound defines the sound to stop
  34184. * @param condition defines the trigger related conditions
  34185. */
  34186. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34187. /** @hidden */
  34188. _prepare(): void;
  34189. /**
  34190. * Execute the action and stop the sound.
  34191. */
  34192. execute(): void;
  34193. /**
  34194. * Serializes the actions and its related information.
  34195. * @param parent defines the object to serialize in
  34196. * @returns the serialized object
  34197. */
  34198. serialize(parent: any): any;
  34199. }
  34200. }
  34201. declare module "babylonjs/Actions/interpolateValueAction" {
  34202. import { Action } from "babylonjs/Actions/action";
  34203. import { Condition } from "babylonjs/Actions/condition";
  34204. import { Observable } from "babylonjs/Misc/observable";
  34205. /**
  34206. * This defines an action responsible to change the value of a property
  34207. * by interpolating between its current value and the newly set one once triggered.
  34208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34209. */
  34210. export class InterpolateValueAction extends Action {
  34211. /**
  34212. * Defines the path of the property where the value should be interpolated
  34213. */
  34214. propertyPath: string;
  34215. /**
  34216. * Defines the target value at the end of the interpolation.
  34217. */
  34218. value: any;
  34219. /**
  34220. * Defines the time it will take for the property to interpolate to the value.
  34221. */
  34222. duration: number;
  34223. /**
  34224. * Defines if the other scene animations should be stopped when the action has been triggered
  34225. */
  34226. stopOtherAnimations?: boolean;
  34227. /**
  34228. * Defines a callback raised once the interpolation animation has been done.
  34229. */
  34230. onInterpolationDone?: () => void;
  34231. /**
  34232. * Observable triggered once the interpolation animation has been done.
  34233. */
  34234. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34235. private _target;
  34236. private _effectiveTarget;
  34237. private _property;
  34238. /**
  34239. * Instantiate the action
  34240. * @param triggerOptions defines the trigger options
  34241. * @param target defines the object containing the value to interpolate
  34242. * @param propertyPath defines the path to the property in the target object
  34243. * @param value defines the target value at the end of the interpolation
  34244. * @param duration deines the time it will take for the property to interpolate to the value.
  34245. * @param condition defines the trigger related conditions
  34246. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34247. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34248. */
  34249. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34250. /** @hidden */
  34251. _prepare(): void;
  34252. /**
  34253. * Execute the action starts the value interpolation.
  34254. */
  34255. execute(): void;
  34256. /**
  34257. * Serializes the actions and its related information.
  34258. * @param parent defines the object to serialize in
  34259. * @returns the serialized object
  34260. */
  34261. serialize(parent: any): any;
  34262. }
  34263. }
  34264. declare module "babylonjs/Actions/index" {
  34265. export * from "babylonjs/Actions/action";
  34266. export * from "babylonjs/Actions/actionEvent";
  34267. export * from "babylonjs/Actions/actionManager";
  34268. export * from "babylonjs/Actions/condition";
  34269. export * from "babylonjs/Actions/directActions";
  34270. export * from "babylonjs/Actions/directAudioActions";
  34271. export * from "babylonjs/Actions/interpolateValueAction";
  34272. }
  34273. declare module "babylonjs/Animations/index" {
  34274. export * from "babylonjs/Animations/animatable";
  34275. export * from "babylonjs/Animations/animation";
  34276. export * from "babylonjs/Animations/animationGroup";
  34277. export * from "babylonjs/Animations/animationPropertiesOverride";
  34278. export * from "babylonjs/Animations/easing";
  34279. export * from "babylonjs/Animations/runtimeAnimation";
  34280. export * from "babylonjs/Animations/animationEvent";
  34281. export * from "babylonjs/Animations/animationGroup";
  34282. export * from "babylonjs/Animations/animationKey";
  34283. export * from "babylonjs/Animations/animationRange";
  34284. }
  34285. declare module "babylonjs/Audio/soundTrack" {
  34286. import { Sound } from "babylonjs/Audio/sound";
  34287. import { Analyser } from "babylonjs/Audio/analyser";
  34288. import { Scene } from "babylonjs/scene";
  34289. /**
  34290. * Options allowed during the creation of a sound track.
  34291. */
  34292. export interface ISoundTrackOptions {
  34293. /**
  34294. * The volume the sound track should take during creation
  34295. */
  34296. volume?: number;
  34297. /**
  34298. * Define if the sound track is the main sound track of the scene
  34299. */
  34300. mainTrack?: boolean;
  34301. }
  34302. /**
  34303. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34304. * It will be also used in a future release to apply effects on a specific track.
  34305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34306. */
  34307. export class SoundTrack {
  34308. /**
  34309. * The unique identifier of the sound track in the scene.
  34310. */
  34311. id: number;
  34312. /**
  34313. * The list of sounds included in the sound track.
  34314. */
  34315. soundCollection: Array<Sound>;
  34316. private _outputAudioNode;
  34317. private _scene;
  34318. private _isMainTrack;
  34319. private _connectedAnalyser;
  34320. private _options;
  34321. private _isInitialized;
  34322. /**
  34323. * Creates a new sound track.
  34324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34325. * @param scene Define the scene the sound track belongs to
  34326. * @param options
  34327. */
  34328. constructor(scene: Scene, options?: ISoundTrackOptions);
  34329. private _initializeSoundTrackAudioGraph;
  34330. /**
  34331. * Release the sound track and its associated resources
  34332. */
  34333. dispose(): void;
  34334. /**
  34335. * Adds a sound to this sound track
  34336. * @param sound define the cound to add
  34337. * @ignoreNaming
  34338. */
  34339. AddSound(sound: Sound): void;
  34340. /**
  34341. * Removes a sound to this sound track
  34342. * @param sound define the cound to remove
  34343. * @ignoreNaming
  34344. */
  34345. RemoveSound(sound: Sound): void;
  34346. /**
  34347. * Set a global volume for the full sound track.
  34348. * @param newVolume Define the new volume of the sound track
  34349. */
  34350. setVolume(newVolume: number): void;
  34351. /**
  34352. * Switch the panning model to HRTF:
  34353. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34355. */
  34356. switchPanningModelToHRTF(): void;
  34357. /**
  34358. * Switch the panning model to Equal Power:
  34359. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34361. */
  34362. switchPanningModelToEqualPower(): void;
  34363. /**
  34364. * Connect the sound track to an audio analyser allowing some amazing
  34365. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34367. * @param analyser The analyser to connect to the engine
  34368. */
  34369. connectToAnalyser(analyser: Analyser): void;
  34370. }
  34371. }
  34372. declare module "babylonjs/Audio/audioSceneComponent" {
  34373. import { Sound } from "babylonjs/Audio/sound";
  34374. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34375. import { Nullable } from "babylonjs/types";
  34376. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34377. import { Scene } from "babylonjs/scene";
  34378. import { AbstractScene } from "babylonjs/abstractScene";
  34379. module "babylonjs/abstractScene" {
  34380. interface AbstractScene {
  34381. /**
  34382. * The list of sounds used in the scene.
  34383. */
  34384. sounds: Nullable<Array<Sound>>;
  34385. }
  34386. }
  34387. module "babylonjs/scene" {
  34388. interface Scene {
  34389. /**
  34390. * @hidden
  34391. * Backing field
  34392. */
  34393. _mainSoundTrack: SoundTrack;
  34394. /**
  34395. * The main sound track played by the scene.
  34396. * It cotains your primary collection of sounds.
  34397. */
  34398. mainSoundTrack: SoundTrack;
  34399. /**
  34400. * The list of sound tracks added to the scene
  34401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34402. */
  34403. soundTracks: Nullable<Array<SoundTrack>>;
  34404. /**
  34405. * Gets a sound using a given name
  34406. * @param name defines the name to search for
  34407. * @return the found sound or null if not found at all.
  34408. */
  34409. getSoundByName(name: string): Nullable<Sound>;
  34410. /**
  34411. * Gets or sets if audio support is enabled
  34412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34413. */
  34414. audioEnabled: boolean;
  34415. /**
  34416. * Gets or sets if audio will be output to headphones
  34417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34418. */
  34419. headphone: boolean;
  34420. }
  34421. }
  34422. /**
  34423. * Defines the sound scene component responsible to manage any sounds
  34424. * in a given scene.
  34425. */
  34426. export class AudioSceneComponent implements ISceneSerializableComponent {
  34427. /**
  34428. * The component name helpfull to identify the component in the list of scene components.
  34429. */
  34430. readonly name: string;
  34431. /**
  34432. * The scene the component belongs to.
  34433. */
  34434. scene: Scene;
  34435. private _audioEnabled;
  34436. /**
  34437. * Gets whether audio is enabled or not.
  34438. * Please use related enable/disable method to switch state.
  34439. */
  34440. readonly audioEnabled: boolean;
  34441. private _headphone;
  34442. /**
  34443. * Gets whether audio is outputing to headphone or not.
  34444. * Please use the according Switch methods to change output.
  34445. */
  34446. readonly headphone: boolean;
  34447. /**
  34448. * Creates a new instance of the component for the given scene
  34449. * @param scene Defines the scene to register the component in
  34450. */
  34451. constructor(scene: Scene);
  34452. /**
  34453. * Registers the component in a given scene
  34454. */
  34455. register(): void;
  34456. /**
  34457. * Rebuilds the elements related to this component in case of
  34458. * context lost for instance.
  34459. */
  34460. rebuild(): void;
  34461. /**
  34462. * Serializes the component data to the specified json object
  34463. * @param serializationObject The object to serialize to
  34464. */
  34465. serialize(serializationObject: any): void;
  34466. /**
  34467. * Adds all the element from the container to the scene
  34468. * @param container the container holding the elements
  34469. */
  34470. addFromContainer(container: AbstractScene): void;
  34471. /**
  34472. * Removes all the elements in the container from the scene
  34473. * @param container contains the elements to remove
  34474. */
  34475. removeFromContainer(container: AbstractScene): void;
  34476. /**
  34477. * Disposes the component and the associated ressources.
  34478. */
  34479. dispose(): void;
  34480. /**
  34481. * Disables audio in the associated scene.
  34482. */
  34483. disableAudio(): void;
  34484. /**
  34485. * Enables audio in the associated scene.
  34486. */
  34487. enableAudio(): void;
  34488. /**
  34489. * Switch audio to headphone output.
  34490. */
  34491. switchAudioModeForHeadphones(): void;
  34492. /**
  34493. * Switch audio to normal speakers.
  34494. */
  34495. switchAudioModeForNormalSpeakers(): void;
  34496. private _afterRender;
  34497. }
  34498. }
  34499. declare module "babylonjs/Audio/weightedsound" {
  34500. import { Sound } from "babylonjs/Audio/sound";
  34501. /**
  34502. * Wraps one or more Sound objects and selects one with random weight for playback.
  34503. */
  34504. export class WeightedSound {
  34505. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34506. loop: boolean;
  34507. private _coneInnerAngle;
  34508. private _coneOuterAngle;
  34509. private _volume;
  34510. /** A Sound is currently playing. */
  34511. isPlaying: boolean;
  34512. /** A Sound is currently paused. */
  34513. isPaused: boolean;
  34514. private _sounds;
  34515. private _weights;
  34516. private _currentIndex?;
  34517. /**
  34518. * Creates a new WeightedSound from the list of sounds given.
  34519. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34520. * @param sounds Array of Sounds that will be selected from.
  34521. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34522. */
  34523. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34524. /**
  34525. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34526. */
  34527. /**
  34528. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34529. */
  34530. directionalConeInnerAngle: number;
  34531. /**
  34532. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34533. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34534. */
  34535. /**
  34536. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34537. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34538. */
  34539. directionalConeOuterAngle: number;
  34540. /**
  34541. * Playback volume.
  34542. */
  34543. /**
  34544. * Playback volume.
  34545. */
  34546. volume: number;
  34547. private _onended;
  34548. /**
  34549. * Suspend playback
  34550. */
  34551. pause(): void;
  34552. /**
  34553. * Stop playback
  34554. */
  34555. stop(): void;
  34556. /**
  34557. * Start playback.
  34558. * @param startOffset Position the clip head at a specific time in seconds.
  34559. */
  34560. play(startOffset?: number): void;
  34561. }
  34562. }
  34563. declare module "babylonjs/Audio/index" {
  34564. export * from "babylonjs/Audio/analyser";
  34565. export * from "babylonjs/Audio/audioEngine";
  34566. export * from "babylonjs/Audio/audioSceneComponent";
  34567. export * from "babylonjs/Audio/sound";
  34568. export * from "babylonjs/Audio/soundTrack";
  34569. export * from "babylonjs/Audio/weightedsound";
  34570. }
  34571. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34572. import { Behavior } from "babylonjs/Behaviors/behavior";
  34573. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34574. import { BackEase } from "babylonjs/Animations/easing";
  34575. /**
  34576. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34578. */
  34579. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34580. /**
  34581. * Gets the name of the behavior.
  34582. */
  34583. readonly name: string;
  34584. /**
  34585. * The easing function used by animations
  34586. */
  34587. static EasingFunction: BackEase;
  34588. /**
  34589. * The easing mode used by animations
  34590. */
  34591. static EasingMode: number;
  34592. /**
  34593. * The duration of the animation, in milliseconds
  34594. */
  34595. transitionDuration: number;
  34596. /**
  34597. * Length of the distance animated by the transition when lower radius is reached
  34598. */
  34599. lowerRadiusTransitionRange: number;
  34600. /**
  34601. * Length of the distance animated by the transition when upper radius is reached
  34602. */
  34603. upperRadiusTransitionRange: number;
  34604. private _autoTransitionRange;
  34605. /**
  34606. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34607. */
  34608. /**
  34609. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34610. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34611. */
  34612. autoTransitionRange: boolean;
  34613. private _attachedCamera;
  34614. private _onAfterCheckInputsObserver;
  34615. private _onMeshTargetChangedObserver;
  34616. /**
  34617. * Initializes the behavior.
  34618. */
  34619. init(): void;
  34620. /**
  34621. * Attaches the behavior to its arc rotate camera.
  34622. * @param camera Defines the camera to attach the behavior to
  34623. */
  34624. attach(camera: ArcRotateCamera): void;
  34625. /**
  34626. * Detaches the behavior from its current arc rotate camera.
  34627. */
  34628. detach(): void;
  34629. private _radiusIsAnimating;
  34630. private _radiusBounceTransition;
  34631. private _animatables;
  34632. private _cachedWheelPrecision;
  34633. /**
  34634. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34635. * @param radiusLimit The limit to check against.
  34636. * @return Bool to indicate if at limit.
  34637. */
  34638. private _isRadiusAtLimit;
  34639. /**
  34640. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34641. * @param radiusDelta The delta by which to animate to. Can be negative.
  34642. */
  34643. private _applyBoundRadiusAnimation;
  34644. /**
  34645. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34646. */
  34647. protected _clearAnimationLocks(): void;
  34648. /**
  34649. * Stops and removes all animations that have been applied to the camera
  34650. */
  34651. stopAllAnimations(): void;
  34652. }
  34653. }
  34654. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34655. import { Behavior } from "babylonjs/Behaviors/behavior";
  34656. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34657. import { ExponentialEase } from "babylonjs/Animations/easing";
  34658. import { Nullable } from "babylonjs/types";
  34659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34660. import { Vector3 } from "babylonjs/Maths/math";
  34661. /**
  34662. * 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.
  34663. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34664. */
  34665. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34666. /**
  34667. * Gets the name of the behavior.
  34668. */
  34669. readonly name: string;
  34670. private _mode;
  34671. private _radiusScale;
  34672. private _positionScale;
  34673. private _defaultElevation;
  34674. private _elevationReturnTime;
  34675. private _elevationReturnWaitTime;
  34676. private _zoomStopsAnimation;
  34677. private _framingTime;
  34678. /**
  34679. * The easing function used by animations
  34680. */
  34681. static EasingFunction: ExponentialEase;
  34682. /**
  34683. * The easing mode used by animations
  34684. */
  34685. static EasingMode: number;
  34686. /**
  34687. * Sets the current mode used by the behavior
  34688. */
  34689. /**
  34690. * Gets current mode used by the behavior.
  34691. */
  34692. mode: number;
  34693. /**
  34694. * Sets the scale applied to the radius (1 by default)
  34695. */
  34696. /**
  34697. * Gets the scale applied to the radius
  34698. */
  34699. radiusScale: number;
  34700. /**
  34701. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34702. */
  34703. /**
  34704. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34705. */
  34706. positionScale: number;
  34707. /**
  34708. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34709. * behaviour is triggered, in radians.
  34710. */
  34711. /**
  34712. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34713. * behaviour is triggered, in radians.
  34714. */
  34715. defaultElevation: number;
  34716. /**
  34717. * Sets the time (in milliseconds) taken to return to the default beta position.
  34718. * Negative value indicates camera should not return to default.
  34719. */
  34720. /**
  34721. * Gets the time (in milliseconds) taken to return to the default beta position.
  34722. * Negative value indicates camera should not return to default.
  34723. */
  34724. elevationReturnTime: number;
  34725. /**
  34726. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34727. */
  34728. /**
  34729. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34730. */
  34731. elevationReturnWaitTime: number;
  34732. /**
  34733. * Sets the flag that indicates if user zooming should stop animation.
  34734. */
  34735. /**
  34736. * Gets the flag that indicates if user zooming should stop animation.
  34737. */
  34738. zoomStopsAnimation: boolean;
  34739. /**
  34740. * Sets the transition time when framing the mesh, in milliseconds
  34741. */
  34742. /**
  34743. * Gets the transition time when framing the mesh, in milliseconds
  34744. */
  34745. framingTime: number;
  34746. /**
  34747. * Define if the behavior should automatically change the configured
  34748. * camera limits and sensibilities.
  34749. */
  34750. autoCorrectCameraLimitsAndSensibility: boolean;
  34751. private _onPrePointerObservableObserver;
  34752. private _onAfterCheckInputsObserver;
  34753. private _onMeshTargetChangedObserver;
  34754. private _attachedCamera;
  34755. private _isPointerDown;
  34756. private _lastInteractionTime;
  34757. /**
  34758. * Initializes the behavior.
  34759. */
  34760. init(): void;
  34761. /**
  34762. * Attaches the behavior to its arc rotate camera.
  34763. * @param camera Defines the camera to attach the behavior to
  34764. */
  34765. attach(camera: ArcRotateCamera): void;
  34766. /**
  34767. * Detaches the behavior from its current arc rotate camera.
  34768. */
  34769. detach(): void;
  34770. private _animatables;
  34771. private _betaIsAnimating;
  34772. private _betaTransition;
  34773. private _radiusTransition;
  34774. private _vectorTransition;
  34775. /**
  34776. * Targets the given mesh and updates zoom level accordingly.
  34777. * @param mesh The mesh to target.
  34778. * @param radius Optional. If a cached radius position already exists, overrides default.
  34779. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34780. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34781. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34782. */
  34783. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34784. /**
  34785. * Targets the given mesh with its children and updates zoom level accordingly.
  34786. * @param mesh The mesh to target.
  34787. * @param radius Optional. If a cached radius position already exists, overrides default.
  34788. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34789. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34790. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34791. */
  34792. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34793. /**
  34794. * Targets the given meshes with their children and updates zoom level accordingly.
  34795. * @param meshes The mesh to target.
  34796. * @param radius Optional. If a cached radius position already exists, overrides default.
  34797. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34798. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34799. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34800. */
  34801. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34802. /**
  34803. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34804. * @param minimumWorld Determines the smaller position of the bounding box extend
  34805. * @param maximumWorld Determines the bigger position of the bounding box extend
  34806. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34807. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34808. */
  34809. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34810. /**
  34811. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34812. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34813. * frustum width.
  34814. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34815. * to fully enclose the mesh in the viewing frustum.
  34816. */
  34817. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34818. /**
  34819. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34820. * is automatically returned to its default position (expected to be above ground plane).
  34821. */
  34822. private _maintainCameraAboveGround;
  34823. /**
  34824. * Returns the frustum slope based on the canvas ratio and camera FOV
  34825. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34826. */
  34827. private _getFrustumSlope;
  34828. /**
  34829. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34830. */
  34831. private _clearAnimationLocks;
  34832. /**
  34833. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34834. */
  34835. private _applyUserInteraction;
  34836. /**
  34837. * Stops and removes all animations that have been applied to the camera
  34838. */
  34839. stopAllAnimations(): void;
  34840. /**
  34841. * Gets a value indicating if the user is moving the camera
  34842. */
  34843. readonly isUserIsMoving: boolean;
  34844. /**
  34845. * The camera can move all the way towards the mesh.
  34846. */
  34847. static IgnoreBoundsSizeMode: number;
  34848. /**
  34849. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34850. */
  34851. static FitFrustumSidesMode: number;
  34852. }
  34853. }
  34854. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34855. import { Nullable } from "babylonjs/types";
  34856. import { Camera } from "babylonjs/Cameras/camera";
  34857. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34858. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34859. /**
  34860. * Base class for Camera Pointer Inputs.
  34861. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34862. * for example usage.
  34863. */
  34864. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34865. /**
  34866. * Defines the camera the input is attached to.
  34867. */
  34868. abstract camera: Camera;
  34869. /**
  34870. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34871. */
  34872. protected _altKey: boolean;
  34873. protected _ctrlKey: boolean;
  34874. protected _metaKey: boolean;
  34875. protected _shiftKey: boolean;
  34876. /**
  34877. * Which mouse buttons were pressed at time of last mouse event.
  34878. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34879. */
  34880. protected _buttonsPressed: number;
  34881. /**
  34882. * Defines the buttons associated with the input to handle camera move.
  34883. */
  34884. buttons: number[];
  34885. /**
  34886. * Attach the input controls to a specific dom element to get the input from.
  34887. * @param element Defines the element the controls should be listened from
  34888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34889. */
  34890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34891. /**
  34892. * Detach the current controls from the specified dom element.
  34893. * @param element Defines the element to stop listening the inputs from
  34894. */
  34895. detachControl(element: Nullable<HTMLElement>): void;
  34896. /**
  34897. * Gets the class name of the current input.
  34898. * @returns the class name
  34899. */
  34900. getClassName(): string;
  34901. /**
  34902. * Get the friendly name associated with the input class.
  34903. * @returns the input friendly name
  34904. */
  34905. getSimpleName(): string;
  34906. /**
  34907. * Called on pointer POINTERDOUBLETAP event.
  34908. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34909. */
  34910. protected onDoubleTap(type: string): void;
  34911. /**
  34912. * Called on pointer POINTERMOVE event if only a single touch is active.
  34913. * Override this method to provide functionality.
  34914. */
  34915. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34916. /**
  34917. * Called on pointer POINTERMOVE event if multiple touches are active.
  34918. * Override this method to provide functionality.
  34919. */
  34920. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34921. /**
  34922. * Called on JS contextmenu event.
  34923. * Override this method to provide functionality.
  34924. */
  34925. protected onContextMenu(evt: PointerEvent): void;
  34926. /**
  34927. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34928. * press.
  34929. * Override this method to provide functionality.
  34930. */
  34931. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34932. /**
  34933. * Called each time a new POINTERUP event occurs. Ie, for each button
  34934. * release.
  34935. * Override this method to provide functionality.
  34936. */
  34937. protected onButtonUp(evt: PointerEvent): void;
  34938. /**
  34939. * Called when window becomes inactive.
  34940. * Override this method to provide functionality.
  34941. */
  34942. protected onLostFocus(): void;
  34943. private _pointerInput;
  34944. private _observer;
  34945. private _onLostFocus;
  34946. }
  34947. }
  34948. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34949. import { Nullable } from "babylonjs/types";
  34950. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34951. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34952. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34953. /**
  34954. * Manage the pointers inputs to control an arc rotate camera.
  34955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34956. */
  34957. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34958. /**
  34959. * Defines the camera the input is attached to.
  34960. */
  34961. camera: ArcRotateCamera;
  34962. /**
  34963. * Gets the class name of the current input.
  34964. * @returns the class name
  34965. */
  34966. getClassName(): string;
  34967. /**
  34968. * Defines the buttons associated with the input to handle camera move.
  34969. */
  34970. buttons: number[];
  34971. /**
  34972. * Defines the pointer angular sensibility along the X axis or how fast is
  34973. * the camera rotating.
  34974. */
  34975. angularSensibilityX: number;
  34976. /**
  34977. * Defines the pointer angular sensibility along the Y axis or how fast is
  34978. * the camera rotating.
  34979. */
  34980. angularSensibilityY: number;
  34981. /**
  34982. * Defines the pointer pinch precision or how fast is the camera zooming.
  34983. */
  34984. pinchPrecision: number;
  34985. /**
  34986. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34987. * from 0.
  34988. * It defines the percentage of current camera.radius to use as delta when
  34989. * pinch zoom is used.
  34990. */
  34991. pinchDeltaPercentage: number;
  34992. /**
  34993. * Defines the pointer panning sensibility or how fast is the camera moving.
  34994. */
  34995. panningSensibility: number;
  34996. /**
  34997. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34998. */
  34999. multiTouchPanning: boolean;
  35000. /**
  35001. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35002. * zoom (pinch) through multitouch.
  35003. */
  35004. multiTouchPanAndZoom: boolean;
  35005. /**
  35006. * Revers pinch action direction.
  35007. */
  35008. pinchInwards: boolean;
  35009. private _isPanClick;
  35010. private _twoFingerActivityCount;
  35011. private _isPinching;
  35012. /**
  35013. * Called on pointer POINTERMOVE event if only a single touch is active.
  35014. */
  35015. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35016. /**
  35017. * Called on pointer POINTERDOUBLETAP event.
  35018. */
  35019. protected onDoubleTap(type: string): void;
  35020. /**
  35021. * Called on pointer POINTERMOVE event if multiple touches are active.
  35022. */
  35023. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35024. /**
  35025. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35026. * press.
  35027. */
  35028. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  35029. /**
  35030. * Called each time a new POINTERUP event occurs. Ie, for each button
  35031. * release.
  35032. */
  35033. protected onButtonUp(evt: PointerEvent): void;
  35034. /**
  35035. * Called when window becomes inactive.
  35036. */
  35037. protected onLostFocus(): void;
  35038. }
  35039. }
  35040. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35041. import { Nullable } from "babylonjs/types";
  35042. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35043. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35044. /**
  35045. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35047. */
  35048. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35049. /**
  35050. * Defines the camera the input is attached to.
  35051. */
  35052. camera: ArcRotateCamera;
  35053. /**
  35054. * Defines the list of key codes associated with the up action (increase alpha)
  35055. */
  35056. keysUp: number[];
  35057. /**
  35058. * Defines the list of key codes associated with the down action (decrease alpha)
  35059. */
  35060. keysDown: number[];
  35061. /**
  35062. * Defines the list of key codes associated with the left action (increase beta)
  35063. */
  35064. keysLeft: number[];
  35065. /**
  35066. * Defines the list of key codes associated with the right action (decrease beta)
  35067. */
  35068. keysRight: number[];
  35069. /**
  35070. * Defines the list of key codes associated with the reset action.
  35071. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35072. */
  35073. keysReset: number[];
  35074. /**
  35075. * Defines the panning sensibility of the inputs.
  35076. * (How fast is the camera paning)
  35077. */
  35078. panningSensibility: number;
  35079. /**
  35080. * Defines the zooming sensibility of the inputs.
  35081. * (How fast is the camera zooming)
  35082. */
  35083. zoomingSensibility: number;
  35084. /**
  35085. * Defines wether maintaining the alt key down switch the movement mode from
  35086. * orientation to zoom.
  35087. */
  35088. useAltToZoom: boolean;
  35089. /**
  35090. * Rotation speed of the camera
  35091. */
  35092. angularSpeed: number;
  35093. private _keys;
  35094. private _ctrlPressed;
  35095. private _altPressed;
  35096. private _onCanvasBlurObserver;
  35097. private _onKeyboardObserver;
  35098. private _engine;
  35099. private _scene;
  35100. /**
  35101. * Attach the input controls to a specific dom element to get the input from.
  35102. * @param element Defines the element the controls should be listened from
  35103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35104. */
  35105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35106. /**
  35107. * Detach the current controls from the specified dom element.
  35108. * @param element Defines the element to stop listening the inputs from
  35109. */
  35110. detachControl(element: Nullable<HTMLElement>): void;
  35111. /**
  35112. * Update the current camera state depending on the inputs that have been used this frame.
  35113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35114. */
  35115. checkInputs(): void;
  35116. /**
  35117. * Gets the class name of the current intput.
  35118. * @returns the class name
  35119. */
  35120. getClassName(): string;
  35121. /**
  35122. * Get the friendly name associated with the input class.
  35123. * @returns the input friendly name
  35124. */
  35125. getSimpleName(): string;
  35126. }
  35127. }
  35128. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35129. import { Nullable } from "babylonjs/types";
  35130. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35131. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35132. /**
  35133. * Manage the mouse wheel inputs to control an arc rotate camera.
  35134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35135. */
  35136. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35137. /**
  35138. * Defines the camera the input is attached to.
  35139. */
  35140. camera: ArcRotateCamera;
  35141. /**
  35142. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35143. */
  35144. wheelPrecision: number;
  35145. /**
  35146. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35147. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35148. */
  35149. wheelDeltaPercentage: number;
  35150. private _wheel;
  35151. private _observer;
  35152. /**
  35153. * Attach the input controls to a specific dom element to get the input from.
  35154. * @param element Defines the element the controls should be listened from
  35155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35156. */
  35157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35158. /**
  35159. * Detach the current controls from the specified dom element.
  35160. * @param element Defines the element to stop listening the inputs from
  35161. */
  35162. detachControl(element: Nullable<HTMLElement>): void;
  35163. /**
  35164. * Gets the class name of the current intput.
  35165. * @returns the class name
  35166. */
  35167. getClassName(): string;
  35168. /**
  35169. * Get the friendly name associated with the input class.
  35170. * @returns the input friendly name
  35171. */
  35172. getSimpleName(): string;
  35173. }
  35174. }
  35175. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35176. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35177. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35178. /**
  35179. * Default Inputs manager for the ArcRotateCamera.
  35180. * It groups all the default supported inputs for ease of use.
  35181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35182. */
  35183. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35184. /**
  35185. * Instantiates a new ArcRotateCameraInputsManager.
  35186. * @param camera Defines the camera the inputs belong to
  35187. */
  35188. constructor(camera: ArcRotateCamera);
  35189. /**
  35190. * Add mouse wheel input support to the input manager.
  35191. * @returns the current input manager
  35192. */
  35193. addMouseWheel(): ArcRotateCameraInputsManager;
  35194. /**
  35195. * Add pointers input support to the input manager.
  35196. * @returns the current input manager
  35197. */
  35198. addPointers(): ArcRotateCameraInputsManager;
  35199. /**
  35200. * Add keyboard input support to the input manager.
  35201. * @returns the current input manager
  35202. */
  35203. addKeyboard(): ArcRotateCameraInputsManager;
  35204. }
  35205. }
  35206. declare module "babylonjs/Cameras/arcRotateCamera" {
  35207. import { Observable } from "babylonjs/Misc/observable";
  35208. import { Nullable } from "babylonjs/types";
  35209. import { Scene } from "babylonjs/scene";
  35210. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35212. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35213. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35214. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35215. import { Camera } from "babylonjs/Cameras/camera";
  35216. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35217. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35218. import { Collider } from "babylonjs/Collisions/collider";
  35219. /**
  35220. * This represents an orbital type of camera.
  35221. *
  35222. * 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.
  35223. * 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.
  35224. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35225. */
  35226. export class ArcRotateCamera extends TargetCamera {
  35227. /**
  35228. * Defines the rotation angle of the camera along the longitudinal axis.
  35229. */
  35230. alpha: number;
  35231. /**
  35232. * Defines the rotation angle of the camera along the latitudinal axis.
  35233. */
  35234. beta: number;
  35235. /**
  35236. * Defines the radius of the camera from it s target point.
  35237. */
  35238. radius: number;
  35239. protected _target: Vector3;
  35240. protected _targetHost: Nullable<AbstractMesh>;
  35241. /**
  35242. * Defines the target point of the camera.
  35243. * The camera looks towards it form the radius distance.
  35244. */
  35245. target: Vector3;
  35246. /**
  35247. * Define the current local position of the camera in the scene
  35248. */
  35249. position: Vector3;
  35250. /**
  35251. * Current inertia value on the longitudinal axis.
  35252. * The bigger this number the longer it will take for the camera to stop.
  35253. */
  35254. inertialAlphaOffset: number;
  35255. /**
  35256. * Current inertia value on the latitudinal axis.
  35257. * The bigger this number the longer it will take for the camera to stop.
  35258. */
  35259. inertialBetaOffset: number;
  35260. /**
  35261. * Current inertia value on the radius axis.
  35262. * The bigger this number the longer it will take for the camera to stop.
  35263. */
  35264. inertialRadiusOffset: number;
  35265. /**
  35266. * Minimum allowed angle on the longitudinal axis.
  35267. * This can help limiting how the Camera is able to move in the scene.
  35268. */
  35269. lowerAlphaLimit: Nullable<number>;
  35270. /**
  35271. * Maximum allowed angle on the longitudinal axis.
  35272. * This can help limiting how the Camera is able to move in the scene.
  35273. */
  35274. upperAlphaLimit: Nullable<number>;
  35275. /**
  35276. * Minimum allowed angle on the latitudinal axis.
  35277. * This can help limiting how the Camera is able to move in the scene.
  35278. */
  35279. lowerBetaLimit: number;
  35280. /**
  35281. * Maximum allowed angle on the latitudinal axis.
  35282. * This can help limiting how the Camera is able to move in the scene.
  35283. */
  35284. upperBetaLimit: number;
  35285. /**
  35286. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35287. * This can help limiting how the Camera is able to move in the scene.
  35288. */
  35289. lowerRadiusLimit: Nullable<number>;
  35290. /**
  35291. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35292. * This can help limiting how the Camera is able to move in the scene.
  35293. */
  35294. upperRadiusLimit: Nullable<number>;
  35295. /**
  35296. * Defines the current inertia value used during panning of the camera along the X axis.
  35297. */
  35298. inertialPanningX: number;
  35299. /**
  35300. * Defines the current inertia value used during panning of the camera along the Y axis.
  35301. */
  35302. inertialPanningY: number;
  35303. /**
  35304. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35305. * Basically if your fingers moves away from more than this distance you will be considered
  35306. * in pinch mode.
  35307. */
  35308. pinchToPanMaxDistance: number;
  35309. /**
  35310. * Defines the maximum distance the camera can pan.
  35311. * This could help keeping the cammera always in your scene.
  35312. */
  35313. panningDistanceLimit: Nullable<number>;
  35314. /**
  35315. * Defines the target of the camera before paning.
  35316. */
  35317. panningOriginTarget: Vector3;
  35318. /**
  35319. * Defines the value of the inertia used during panning.
  35320. * 0 would mean stop inertia and one would mean no decelleration at all.
  35321. */
  35322. panningInertia: number;
  35323. /**
  35324. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35325. */
  35326. angularSensibilityX: number;
  35327. /**
  35328. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35329. */
  35330. angularSensibilityY: number;
  35331. /**
  35332. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35333. */
  35334. pinchPrecision: number;
  35335. /**
  35336. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35337. * It will be used instead of pinchDeltaPrecision if different from 0.
  35338. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35339. */
  35340. pinchDeltaPercentage: number;
  35341. /**
  35342. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35343. */
  35344. panningSensibility: number;
  35345. /**
  35346. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35347. */
  35348. keysUp: number[];
  35349. /**
  35350. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35351. */
  35352. keysDown: number[];
  35353. /**
  35354. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35355. */
  35356. keysLeft: number[];
  35357. /**
  35358. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35359. */
  35360. keysRight: number[];
  35361. /**
  35362. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35363. */
  35364. wheelPrecision: number;
  35365. /**
  35366. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35367. * It will be used instead of pinchDeltaPrecision if different from 0.
  35368. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35369. */
  35370. wheelDeltaPercentage: number;
  35371. /**
  35372. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35373. */
  35374. zoomOnFactor: number;
  35375. /**
  35376. * Defines a screen offset for the camera position.
  35377. */
  35378. targetScreenOffset: Vector2;
  35379. /**
  35380. * Allows the camera to be completely reversed.
  35381. * If false the camera can not arrive upside down.
  35382. */
  35383. allowUpsideDown: boolean;
  35384. /**
  35385. * Define if double tap/click is used to restore the previously saved state of the camera.
  35386. */
  35387. useInputToRestoreState: boolean;
  35388. /** @hidden */
  35389. _viewMatrix: Matrix;
  35390. /** @hidden */
  35391. _useCtrlForPanning: boolean;
  35392. /** @hidden */
  35393. _panningMouseButton: number;
  35394. /**
  35395. * Defines the input associated to the camera.
  35396. */
  35397. inputs: ArcRotateCameraInputsManager;
  35398. /** @hidden */
  35399. _reset: () => void;
  35400. /**
  35401. * Defines the allowed panning axis.
  35402. */
  35403. panningAxis: Vector3;
  35404. protected _localDirection: Vector3;
  35405. protected _transformedDirection: Vector3;
  35406. private _bouncingBehavior;
  35407. /**
  35408. * Gets the bouncing behavior of the camera if it has been enabled.
  35409. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35410. */
  35411. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35412. /**
  35413. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35414. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35415. */
  35416. useBouncingBehavior: boolean;
  35417. private _framingBehavior;
  35418. /**
  35419. * Gets the framing behavior of the camera if it has been enabled.
  35420. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35421. */
  35422. readonly framingBehavior: Nullable<FramingBehavior>;
  35423. /**
  35424. * Defines if the framing behavior of the camera is enabled on the camera.
  35425. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35426. */
  35427. useFramingBehavior: boolean;
  35428. private _autoRotationBehavior;
  35429. /**
  35430. * Gets the auto rotation behavior of the camera if it has been enabled.
  35431. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35432. */
  35433. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35434. /**
  35435. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35436. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35437. */
  35438. useAutoRotationBehavior: boolean;
  35439. /**
  35440. * Observable triggered when the mesh target has been changed on the camera.
  35441. */
  35442. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35443. /**
  35444. * Event raised when the camera is colliding with a mesh.
  35445. */
  35446. onCollide: (collidedMesh: AbstractMesh) => void;
  35447. /**
  35448. * Defines whether the camera should check collision with the objects oh the scene.
  35449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35450. */
  35451. checkCollisions: boolean;
  35452. /**
  35453. * Defines the collision radius of the camera.
  35454. * This simulates a sphere around the camera.
  35455. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35456. */
  35457. collisionRadius: Vector3;
  35458. protected _collider: Collider;
  35459. protected _previousPosition: Vector3;
  35460. protected _collisionVelocity: Vector3;
  35461. protected _newPosition: Vector3;
  35462. protected _previousAlpha: number;
  35463. protected _previousBeta: number;
  35464. protected _previousRadius: number;
  35465. protected _collisionTriggered: boolean;
  35466. protected _targetBoundingCenter: Nullable<Vector3>;
  35467. private _computationVector;
  35468. private _tempAxisVector;
  35469. private _tempAxisRotationMatrix;
  35470. /**
  35471. * Instantiates a new ArcRotateCamera in a given scene
  35472. * @param name Defines the name of the camera
  35473. * @param alpha Defines the camera rotation along the logitudinal axis
  35474. * @param beta Defines the camera rotation along the latitudinal axis
  35475. * @param radius Defines the camera distance from its target
  35476. * @param target Defines the camera target
  35477. * @param scene Defines the scene the camera belongs to
  35478. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35479. */
  35480. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35481. /** @hidden */
  35482. _initCache(): void;
  35483. /** @hidden */
  35484. _updateCache(ignoreParentClass?: boolean): void;
  35485. protected _getTargetPosition(): Vector3;
  35486. private _storedAlpha;
  35487. private _storedBeta;
  35488. private _storedRadius;
  35489. private _storedTarget;
  35490. /**
  35491. * Stores the current state of the camera (alpha, beta, radius and target)
  35492. * @returns the camera itself
  35493. */
  35494. storeState(): Camera;
  35495. /**
  35496. * @hidden
  35497. * Restored camera state. You must call storeState() first
  35498. */
  35499. _restoreStateValues(): boolean;
  35500. /** @hidden */
  35501. _isSynchronizedViewMatrix(): boolean;
  35502. /**
  35503. * Attached controls to the current camera.
  35504. * @param element Defines the element the controls should be listened from
  35505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35506. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35507. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35508. */
  35509. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35510. /**
  35511. * Detach the current controls from the camera.
  35512. * The camera will stop reacting to inputs.
  35513. * @param element Defines the element to stop listening the inputs from
  35514. */
  35515. detachControl(element: HTMLElement): void;
  35516. /** @hidden */
  35517. _checkInputs(): void;
  35518. protected _checkLimits(): void;
  35519. /**
  35520. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35521. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35522. */
  35523. rebuildAnglesAndRadius(updateView?: boolean): void;
  35524. /**
  35525. * Use a position to define the current camera related information like aplha, beta and radius
  35526. * @param position Defines the position to set the camera at
  35527. */
  35528. setPosition(position: Vector3): void;
  35529. /**
  35530. * Defines the target the camera should look at.
  35531. * This will automatically adapt alpha beta and radius to fit within the new target.
  35532. * @param target Defines the new target as a Vector or a mesh
  35533. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35534. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35535. */
  35536. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35537. /** @hidden */
  35538. _getViewMatrix(): Matrix;
  35539. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35540. /**
  35541. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35542. * @param meshes Defines the mesh to zoom on
  35543. * @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)
  35544. */
  35545. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35546. /**
  35547. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35548. * The target will be changed but the radius
  35549. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35550. * @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)
  35551. */
  35552. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35553. min: Vector3;
  35554. max: Vector3;
  35555. distance: number;
  35556. }, doNotUpdateMaxZ?: boolean): void;
  35557. /**
  35558. * @override
  35559. * Override Camera.createRigCamera
  35560. */
  35561. createRigCamera(name: string, cameraIndex: number): Camera;
  35562. /**
  35563. * @hidden
  35564. * @override
  35565. * Override Camera._updateRigCameras
  35566. */
  35567. _updateRigCameras(): void;
  35568. /**
  35569. * Destroy the camera and release the current resources hold by it.
  35570. */
  35571. dispose(): void;
  35572. /**
  35573. * Gets the current object class name.
  35574. * @return the class name
  35575. */
  35576. getClassName(): string;
  35577. }
  35578. }
  35579. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35580. import { Behavior } from "babylonjs/Behaviors/behavior";
  35581. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35582. /**
  35583. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35584. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35585. */
  35586. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35587. /**
  35588. * Gets the name of the behavior.
  35589. */
  35590. readonly name: string;
  35591. private _zoomStopsAnimation;
  35592. private _idleRotationSpeed;
  35593. private _idleRotationWaitTime;
  35594. private _idleRotationSpinupTime;
  35595. /**
  35596. * Sets the flag that indicates if user zooming should stop animation.
  35597. */
  35598. /**
  35599. * Gets the flag that indicates if user zooming should stop animation.
  35600. */
  35601. zoomStopsAnimation: boolean;
  35602. /**
  35603. * Sets the default speed at which the camera rotates around the model.
  35604. */
  35605. /**
  35606. * Gets the default speed at which the camera rotates around the model.
  35607. */
  35608. idleRotationSpeed: number;
  35609. /**
  35610. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35611. */
  35612. /**
  35613. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35614. */
  35615. idleRotationWaitTime: number;
  35616. /**
  35617. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35618. */
  35619. /**
  35620. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35621. */
  35622. idleRotationSpinupTime: number;
  35623. /**
  35624. * Gets a value indicating if the camera is currently rotating because of this behavior
  35625. */
  35626. readonly rotationInProgress: boolean;
  35627. private _onPrePointerObservableObserver;
  35628. private _onAfterCheckInputsObserver;
  35629. private _attachedCamera;
  35630. private _isPointerDown;
  35631. private _lastFrameTime;
  35632. private _lastInteractionTime;
  35633. private _cameraRotationSpeed;
  35634. /**
  35635. * Initializes the behavior.
  35636. */
  35637. init(): void;
  35638. /**
  35639. * Attaches the behavior to its arc rotate camera.
  35640. * @param camera Defines the camera to attach the behavior to
  35641. */
  35642. attach(camera: ArcRotateCamera): void;
  35643. /**
  35644. * Detaches the behavior from its current arc rotate camera.
  35645. */
  35646. detach(): void;
  35647. /**
  35648. * Returns true if user is scrolling.
  35649. * @return true if user is scrolling.
  35650. */
  35651. private _userIsZooming;
  35652. private _lastFrameRadius;
  35653. private _shouldAnimationStopForInteraction;
  35654. /**
  35655. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35656. */
  35657. private _applyUserInteraction;
  35658. private _userIsMoving;
  35659. }
  35660. }
  35661. declare module "babylonjs/Behaviors/Cameras/index" {
  35662. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35663. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35664. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35665. }
  35666. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35667. import { Mesh } from "babylonjs/Meshes/mesh";
  35668. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35669. import { Behavior } from "babylonjs/Behaviors/behavior";
  35670. /**
  35671. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35672. */
  35673. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35674. private ui;
  35675. /**
  35676. * The name of the behavior
  35677. */
  35678. name: string;
  35679. /**
  35680. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35681. */
  35682. distanceAwayFromFace: number;
  35683. /**
  35684. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35685. */
  35686. distanceAwayFromBottomOfFace: number;
  35687. private _faceVectors;
  35688. private _target;
  35689. private _scene;
  35690. private _onRenderObserver;
  35691. private _tmpMatrix;
  35692. private _tmpVector;
  35693. /**
  35694. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35695. * @param ui The transform node that should be attched to the mesh
  35696. */
  35697. constructor(ui: TransformNode);
  35698. /**
  35699. * Initializes the behavior
  35700. */
  35701. init(): void;
  35702. private _closestFace;
  35703. private _zeroVector;
  35704. private _lookAtTmpMatrix;
  35705. private _lookAtToRef;
  35706. /**
  35707. * Attaches the AttachToBoxBehavior to the passed in mesh
  35708. * @param target The mesh that the specified node will be attached to
  35709. */
  35710. attach(target: Mesh): void;
  35711. /**
  35712. * Detaches the behavior from the mesh
  35713. */
  35714. detach(): void;
  35715. }
  35716. }
  35717. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35718. import { Behavior } from "babylonjs/Behaviors/behavior";
  35719. import { Mesh } from "babylonjs/Meshes/mesh";
  35720. /**
  35721. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35722. */
  35723. export class FadeInOutBehavior implements Behavior<Mesh> {
  35724. /**
  35725. * Time in milliseconds to delay before fading in (Default: 0)
  35726. */
  35727. delay: number;
  35728. /**
  35729. * Time in milliseconds for the mesh to fade in (Default: 300)
  35730. */
  35731. fadeInTime: number;
  35732. private _millisecondsPerFrame;
  35733. private _hovered;
  35734. private _hoverValue;
  35735. private _ownerNode;
  35736. /**
  35737. * Instatiates the FadeInOutBehavior
  35738. */
  35739. constructor();
  35740. /**
  35741. * The name of the behavior
  35742. */
  35743. readonly name: string;
  35744. /**
  35745. * Initializes the behavior
  35746. */
  35747. init(): void;
  35748. /**
  35749. * Attaches the fade behavior on the passed in mesh
  35750. * @param ownerNode The mesh that will be faded in/out once attached
  35751. */
  35752. attach(ownerNode: Mesh): void;
  35753. /**
  35754. * Detaches the behavior from the mesh
  35755. */
  35756. detach(): void;
  35757. /**
  35758. * Triggers the mesh to begin fading in or out
  35759. * @param value if the object should fade in or out (true to fade in)
  35760. */
  35761. fadeIn(value: boolean): void;
  35762. private _update;
  35763. private _setAllVisibility;
  35764. }
  35765. }
  35766. declare module "babylonjs/Misc/pivotTools" {
  35767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35768. /**
  35769. * Class containing a set of static utilities functions for managing Pivots
  35770. * @hidden
  35771. */
  35772. export class PivotTools {
  35773. private static _PivotCached;
  35774. private static _OldPivotPoint;
  35775. private static _PivotTranslation;
  35776. private static _PivotTmpVector;
  35777. /** @hidden */
  35778. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35779. /** @hidden */
  35780. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35781. }
  35782. }
  35783. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35784. import { Scene } from "babylonjs/scene";
  35785. import { Vector4, Plane } from "babylonjs/Maths/math";
  35786. import { Mesh } from "babylonjs/Meshes/mesh";
  35787. /**
  35788. * Class containing static functions to help procedurally build meshes
  35789. */
  35790. export class PlaneBuilder {
  35791. /**
  35792. * Creates a plane mesh
  35793. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35794. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35795. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35799. * @param name defines the name of the mesh
  35800. * @param options defines the options used to create the mesh
  35801. * @param scene defines the hosting scene
  35802. * @returns the plane mesh
  35803. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35804. */
  35805. static CreatePlane(name: string, options: {
  35806. size?: number;
  35807. width?: number;
  35808. height?: number;
  35809. sideOrientation?: number;
  35810. frontUVs?: Vector4;
  35811. backUVs?: Vector4;
  35812. updatable?: boolean;
  35813. sourcePlane?: Plane;
  35814. }, scene: Scene): Mesh;
  35815. }
  35816. }
  35817. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35818. import { Behavior } from "babylonjs/Behaviors/behavior";
  35819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35820. import { Observable } from "babylonjs/Misc/observable";
  35821. import { Vector3 } from "babylonjs/Maths/math";
  35822. import { Ray } from "babylonjs/Culling/ray";
  35823. import "babylonjs/Meshes/Builders/planeBuilder";
  35824. /**
  35825. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35826. */
  35827. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35828. private static _AnyMouseID;
  35829. private _attachedNode;
  35830. private _dragPlane;
  35831. private _scene;
  35832. private _pointerObserver;
  35833. private _beforeRenderObserver;
  35834. private static _planeScene;
  35835. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35836. /**
  35837. * 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)
  35838. */
  35839. maxDragAngle: number;
  35840. /**
  35841. * @hidden
  35842. */
  35843. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35844. /**
  35845. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35846. */
  35847. currentDraggingPointerID: number;
  35848. /**
  35849. * The last position where the pointer hit the drag plane in world space
  35850. */
  35851. lastDragPosition: Vector3;
  35852. /**
  35853. * If the behavior is currently in a dragging state
  35854. */
  35855. dragging: boolean;
  35856. /**
  35857. * 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)
  35858. */
  35859. dragDeltaRatio: number;
  35860. /**
  35861. * If the drag plane orientation should be updated during the dragging (Default: true)
  35862. */
  35863. updateDragPlane: boolean;
  35864. private _debugMode;
  35865. private _moving;
  35866. /**
  35867. * Fires each time the attached mesh is dragged with the pointer
  35868. * * delta between last drag position and current drag position in world space
  35869. * * dragDistance along the drag axis
  35870. * * dragPlaneNormal normal of the current drag plane used during the drag
  35871. * * dragPlanePoint in world space where the drag intersects the drag plane
  35872. */
  35873. onDragObservable: Observable<{
  35874. delta: Vector3;
  35875. dragPlanePoint: Vector3;
  35876. dragPlaneNormal: Vector3;
  35877. dragDistance: number;
  35878. pointerId: number;
  35879. }>;
  35880. /**
  35881. * Fires each time a drag begins (eg. mouse down on mesh)
  35882. */
  35883. onDragStartObservable: Observable<{
  35884. dragPlanePoint: Vector3;
  35885. pointerId: number;
  35886. }>;
  35887. /**
  35888. * Fires each time a drag ends (eg. mouse release after drag)
  35889. */
  35890. onDragEndObservable: Observable<{
  35891. dragPlanePoint: Vector3;
  35892. pointerId: number;
  35893. }>;
  35894. /**
  35895. * If the attached mesh should be moved when dragged
  35896. */
  35897. moveAttached: boolean;
  35898. /**
  35899. * If the drag behavior will react to drag events (Default: true)
  35900. */
  35901. enabled: boolean;
  35902. /**
  35903. * If camera controls should be detached during the drag
  35904. */
  35905. detachCameraControls: boolean;
  35906. /**
  35907. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35908. */
  35909. useObjectOrienationForDragging: boolean;
  35910. private _options;
  35911. /**
  35912. * Creates a pointer drag behavior that can be attached to a mesh
  35913. * @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)
  35914. */
  35915. constructor(options?: {
  35916. dragAxis?: Vector3;
  35917. dragPlaneNormal?: Vector3;
  35918. });
  35919. /**
  35920. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35921. */
  35922. validateDrag: (targetPosition: Vector3) => boolean;
  35923. /**
  35924. * The name of the behavior
  35925. */
  35926. readonly name: string;
  35927. /**
  35928. * Initializes the behavior
  35929. */
  35930. init(): void;
  35931. private _tmpVector;
  35932. private _alternatePickedPoint;
  35933. private _worldDragAxis;
  35934. private _targetPosition;
  35935. private _attachedElement;
  35936. /**
  35937. * Attaches the drag behavior the passed in mesh
  35938. * @param ownerNode The mesh that will be dragged around once attached
  35939. */
  35940. attach(ownerNode: AbstractMesh): void;
  35941. /**
  35942. * Force relase the drag action by code.
  35943. */
  35944. releaseDrag(): void;
  35945. private _startDragRay;
  35946. private _lastPointerRay;
  35947. /**
  35948. * Simulates the start of a pointer drag event on the behavior
  35949. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35950. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35951. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35952. */
  35953. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35954. private _startDrag;
  35955. private _dragDelta;
  35956. private _moveDrag;
  35957. private _pickWithRayOnDragPlane;
  35958. private _pointA;
  35959. private _pointB;
  35960. private _pointC;
  35961. private _lineA;
  35962. private _lineB;
  35963. private _localAxis;
  35964. private _lookAt;
  35965. private _updateDragPlanePosition;
  35966. /**
  35967. * Detaches the behavior from the mesh
  35968. */
  35969. detach(): void;
  35970. }
  35971. }
  35972. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35973. import { Mesh } from "babylonjs/Meshes/mesh";
  35974. import { Behavior } from "babylonjs/Behaviors/behavior";
  35975. /**
  35976. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35977. */
  35978. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35979. private _dragBehaviorA;
  35980. private _dragBehaviorB;
  35981. private _startDistance;
  35982. private _initialScale;
  35983. private _targetScale;
  35984. private _ownerNode;
  35985. private _sceneRenderObserver;
  35986. /**
  35987. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35988. */
  35989. constructor();
  35990. /**
  35991. * The name of the behavior
  35992. */
  35993. readonly name: string;
  35994. /**
  35995. * Initializes the behavior
  35996. */
  35997. init(): void;
  35998. private _getCurrentDistance;
  35999. /**
  36000. * Attaches the scale behavior the passed in mesh
  36001. * @param ownerNode The mesh that will be scaled around once attached
  36002. */
  36003. attach(ownerNode: Mesh): void;
  36004. /**
  36005. * Detaches the behavior from the mesh
  36006. */
  36007. detach(): void;
  36008. }
  36009. }
  36010. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36011. import { Behavior } from "babylonjs/Behaviors/behavior";
  36012. import { Mesh } from "babylonjs/Meshes/mesh";
  36013. import { Observable } from "babylonjs/Misc/observable";
  36014. /**
  36015. * 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
  36016. */
  36017. export class SixDofDragBehavior implements Behavior<Mesh> {
  36018. private static _virtualScene;
  36019. private _ownerNode;
  36020. private _sceneRenderObserver;
  36021. private _scene;
  36022. private _targetPosition;
  36023. private _virtualOriginMesh;
  36024. private _virtualDragMesh;
  36025. private _pointerObserver;
  36026. private _moving;
  36027. private _startingOrientation;
  36028. /**
  36029. * 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)
  36030. */
  36031. private zDragFactor;
  36032. /**
  36033. * If the object should rotate to face the drag origin
  36034. */
  36035. rotateDraggedObject: boolean;
  36036. /**
  36037. * If the behavior is currently in a dragging state
  36038. */
  36039. dragging: boolean;
  36040. /**
  36041. * 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)
  36042. */
  36043. dragDeltaRatio: number;
  36044. /**
  36045. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36046. */
  36047. currentDraggingPointerID: number;
  36048. /**
  36049. * If camera controls should be detached during the drag
  36050. */
  36051. detachCameraControls: boolean;
  36052. /**
  36053. * Fires each time a drag starts
  36054. */
  36055. onDragStartObservable: Observable<{}>;
  36056. /**
  36057. * Fires each time a drag ends (eg. mouse release after drag)
  36058. */
  36059. onDragEndObservable: Observable<{}>;
  36060. /**
  36061. * 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
  36062. */
  36063. constructor();
  36064. /**
  36065. * The name of the behavior
  36066. */
  36067. readonly name: string;
  36068. /**
  36069. * Initializes the behavior
  36070. */
  36071. init(): void;
  36072. /**
  36073. * Attaches the scale behavior the passed in mesh
  36074. * @param ownerNode The mesh that will be scaled around once attached
  36075. */
  36076. attach(ownerNode: Mesh): void;
  36077. /**
  36078. * Detaches the behavior from the mesh
  36079. */
  36080. detach(): void;
  36081. }
  36082. }
  36083. declare module "babylonjs/Behaviors/Meshes/index" {
  36084. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36085. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36086. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36087. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36088. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36089. }
  36090. declare module "babylonjs/Behaviors/index" {
  36091. export * from "babylonjs/Behaviors/behavior";
  36092. export * from "babylonjs/Behaviors/Cameras/index";
  36093. export * from "babylonjs/Behaviors/Meshes/index";
  36094. }
  36095. declare module "babylonjs/Bones/boneIKController" {
  36096. import { Bone } from "babylonjs/Bones/bone";
  36097. import { Vector3 } from "babylonjs/Maths/math";
  36098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36099. import { Nullable } from "babylonjs/types";
  36100. /**
  36101. * Class used to apply inverse kinematics to bones
  36102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36103. */
  36104. export class BoneIKController {
  36105. private static _tmpVecs;
  36106. private static _tmpQuat;
  36107. private static _tmpMats;
  36108. /**
  36109. * Gets or sets the target mesh
  36110. */
  36111. targetMesh: AbstractMesh;
  36112. /** Gets or sets the mesh used as pole */
  36113. poleTargetMesh: AbstractMesh;
  36114. /**
  36115. * Gets or sets the bone used as pole
  36116. */
  36117. poleTargetBone: Nullable<Bone>;
  36118. /**
  36119. * Gets or sets the target position
  36120. */
  36121. targetPosition: Vector3;
  36122. /**
  36123. * Gets or sets the pole target position
  36124. */
  36125. poleTargetPosition: Vector3;
  36126. /**
  36127. * Gets or sets the pole target local offset
  36128. */
  36129. poleTargetLocalOffset: Vector3;
  36130. /**
  36131. * Gets or sets the pole angle
  36132. */
  36133. poleAngle: number;
  36134. /**
  36135. * Gets or sets the mesh associated with the controller
  36136. */
  36137. mesh: AbstractMesh;
  36138. /**
  36139. * 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)
  36140. */
  36141. slerpAmount: number;
  36142. private _bone1Quat;
  36143. private _bone1Mat;
  36144. private _bone2Ang;
  36145. private _bone1;
  36146. private _bone2;
  36147. private _bone1Length;
  36148. private _bone2Length;
  36149. private _maxAngle;
  36150. private _maxReach;
  36151. private _rightHandedSystem;
  36152. private _bendAxis;
  36153. private _slerping;
  36154. private _adjustRoll;
  36155. /**
  36156. * Gets or sets maximum allowed angle
  36157. */
  36158. maxAngle: number;
  36159. /**
  36160. * Creates a new BoneIKController
  36161. * @param mesh defines the mesh to control
  36162. * @param bone defines the bone to control
  36163. * @param options defines options to set up the controller
  36164. */
  36165. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36166. targetMesh?: AbstractMesh;
  36167. poleTargetMesh?: AbstractMesh;
  36168. poleTargetBone?: Bone;
  36169. poleTargetLocalOffset?: Vector3;
  36170. poleAngle?: number;
  36171. bendAxis?: Vector3;
  36172. maxAngle?: number;
  36173. slerpAmount?: number;
  36174. });
  36175. private _setMaxAngle;
  36176. /**
  36177. * Force the controller to update the bones
  36178. */
  36179. update(): void;
  36180. }
  36181. }
  36182. declare module "babylonjs/Bones/boneLookController" {
  36183. import { Vector3, Space } from "babylonjs/Maths/math";
  36184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36185. import { Bone } from "babylonjs/Bones/bone";
  36186. /**
  36187. * Class used to make a bone look toward a point in space
  36188. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36189. */
  36190. export class BoneLookController {
  36191. private static _tmpVecs;
  36192. private static _tmpQuat;
  36193. private static _tmpMats;
  36194. /**
  36195. * The target Vector3 that the bone will look at
  36196. */
  36197. target: Vector3;
  36198. /**
  36199. * The mesh that the bone is attached to
  36200. */
  36201. mesh: AbstractMesh;
  36202. /**
  36203. * The bone that will be looking to the target
  36204. */
  36205. bone: Bone;
  36206. /**
  36207. * The up axis of the coordinate system that is used when the bone is rotated
  36208. */
  36209. upAxis: Vector3;
  36210. /**
  36211. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36212. */
  36213. upAxisSpace: Space;
  36214. /**
  36215. * Used to make an adjustment to the yaw of the bone
  36216. */
  36217. adjustYaw: number;
  36218. /**
  36219. * Used to make an adjustment to the pitch of the bone
  36220. */
  36221. adjustPitch: number;
  36222. /**
  36223. * Used to make an adjustment to the roll of the bone
  36224. */
  36225. adjustRoll: number;
  36226. /**
  36227. * 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)
  36228. */
  36229. slerpAmount: number;
  36230. private _minYaw;
  36231. private _maxYaw;
  36232. private _minPitch;
  36233. private _maxPitch;
  36234. private _minYawSin;
  36235. private _minYawCos;
  36236. private _maxYawSin;
  36237. private _maxYawCos;
  36238. private _midYawConstraint;
  36239. private _minPitchTan;
  36240. private _maxPitchTan;
  36241. private _boneQuat;
  36242. private _slerping;
  36243. private _transformYawPitch;
  36244. private _transformYawPitchInv;
  36245. private _firstFrameSkipped;
  36246. private _yawRange;
  36247. private _fowardAxis;
  36248. /**
  36249. * Gets or sets the minimum yaw angle that the bone can look to
  36250. */
  36251. minYaw: number;
  36252. /**
  36253. * Gets or sets the maximum yaw angle that the bone can look to
  36254. */
  36255. maxYaw: number;
  36256. /**
  36257. * Gets or sets the minimum pitch angle that the bone can look to
  36258. */
  36259. minPitch: number;
  36260. /**
  36261. * Gets or sets the maximum pitch angle that the bone can look to
  36262. */
  36263. maxPitch: number;
  36264. /**
  36265. * Create a BoneLookController
  36266. * @param mesh the mesh that the bone belongs to
  36267. * @param bone the bone that will be looking to the target
  36268. * @param target the target Vector3 to look at
  36269. * @param options optional settings:
  36270. * * maxYaw: the maximum angle the bone will yaw to
  36271. * * minYaw: the minimum angle the bone will yaw to
  36272. * * maxPitch: the maximum angle the bone will pitch to
  36273. * * minPitch: the minimum angle the bone will yaw to
  36274. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36275. * * upAxis: the up axis of the coordinate system
  36276. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36277. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36278. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36279. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36280. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36281. * * adjustRoll: used to make an adjustment to the roll of the bone
  36282. **/
  36283. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36284. maxYaw?: number;
  36285. minYaw?: number;
  36286. maxPitch?: number;
  36287. minPitch?: number;
  36288. slerpAmount?: number;
  36289. upAxis?: Vector3;
  36290. upAxisSpace?: Space;
  36291. yawAxis?: Vector3;
  36292. pitchAxis?: Vector3;
  36293. adjustYaw?: number;
  36294. adjustPitch?: number;
  36295. adjustRoll?: number;
  36296. });
  36297. /**
  36298. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36299. */
  36300. update(): void;
  36301. private _getAngleDiff;
  36302. private _getAngleBetween;
  36303. private _isAngleBetween;
  36304. }
  36305. }
  36306. declare module "babylonjs/Bones/index" {
  36307. export * from "babylonjs/Bones/bone";
  36308. export * from "babylonjs/Bones/boneIKController";
  36309. export * from "babylonjs/Bones/boneLookController";
  36310. export * from "babylonjs/Bones/skeleton";
  36311. }
  36312. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36313. import { Nullable } from "babylonjs/types";
  36314. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36315. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36316. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36317. /**
  36318. * Manage the gamepad inputs to control an arc rotate camera.
  36319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36320. */
  36321. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36322. /**
  36323. * Defines the camera the input is attached to.
  36324. */
  36325. camera: ArcRotateCamera;
  36326. /**
  36327. * Defines the gamepad the input is gathering event from.
  36328. */
  36329. gamepad: Nullable<Gamepad>;
  36330. /**
  36331. * Defines the gamepad rotation sensiblity.
  36332. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36333. */
  36334. gamepadRotationSensibility: number;
  36335. /**
  36336. * Defines the gamepad move sensiblity.
  36337. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36338. */
  36339. gamepadMoveSensibility: number;
  36340. private _onGamepadConnectedObserver;
  36341. private _onGamepadDisconnectedObserver;
  36342. /**
  36343. * Attach the input controls to a specific dom element to get the input from.
  36344. * @param element Defines the element the controls should be listened from
  36345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36346. */
  36347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36348. /**
  36349. * Detach the current controls from the specified dom element.
  36350. * @param element Defines the element to stop listening the inputs from
  36351. */
  36352. detachControl(element: Nullable<HTMLElement>): void;
  36353. /**
  36354. * Update the current camera state depending on the inputs that have been used this frame.
  36355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36356. */
  36357. checkInputs(): void;
  36358. /**
  36359. * Gets the class name of the current intput.
  36360. * @returns the class name
  36361. */
  36362. getClassName(): string;
  36363. /**
  36364. * Get the friendly name associated with the input class.
  36365. * @returns the input friendly name
  36366. */
  36367. getSimpleName(): string;
  36368. }
  36369. }
  36370. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36371. import { Nullable } from "babylonjs/types";
  36372. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36373. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36374. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36375. interface ArcRotateCameraInputsManager {
  36376. /**
  36377. * Add orientation input support to the input manager.
  36378. * @returns the current input manager
  36379. */
  36380. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36381. }
  36382. }
  36383. /**
  36384. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36386. */
  36387. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36388. /**
  36389. * Defines the camera the input is attached to.
  36390. */
  36391. camera: ArcRotateCamera;
  36392. /**
  36393. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36394. */
  36395. alphaCorrection: number;
  36396. /**
  36397. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36398. */
  36399. gammaCorrection: number;
  36400. private _alpha;
  36401. private _gamma;
  36402. private _dirty;
  36403. private _deviceOrientationHandler;
  36404. /**
  36405. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36406. */
  36407. constructor();
  36408. /**
  36409. * Attach the input controls to a specific dom element to get the input from.
  36410. * @param element Defines the element the controls should be listened from
  36411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36412. */
  36413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36414. /** @hidden */
  36415. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36416. /**
  36417. * Update the current camera state depending on the inputs that have been used this frame.
  36418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36419. */
  36420. checkInputs(): void;
  36421. /**
  36422. * Detach the current controls from the specified dom element.
  36423. * @param element Defines the element to stop listening the inputs from
  36424. */
  36425. detachControl(element: Nullable<HTMLElement>): void;
  36426. /**
  36427. * Gets the class name of the current intput.
  36428. * @returns the class name
  36429. */
  36430. getClassName(): string;
  36431. /**
  36432. * Get the friendly name associated with the input class.
  36433. * @returns the input friendly name
  36434. */
  36435. getSimpleName(): string;
  36436. }
  36437. }
  36438. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36439. import { Nullable } from "babylonjs/types";
  36440. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36441. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36442. /**
  36443. * Listen to mouse events to control the camera.
  36444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36445. */
  36446. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36447. /**
  36448. * Defines the camera the input is attached to.
  36449. */
  36450. camera: FlyCamera;
  36451. /**
  36452. * Defines if touch is enabled. (Default is true.)
  36453. */
  36454. touchEnabled: boolean;
  36455. /**
  36456. * Defines the buttons associated with the input to handle camera rotation.
  36457. */
  36458. buttons: number[];
  36459. /**
  36460. * Assign buttons for Yaw control.
  36461. */
  36462. buttonsYaw: number[];
  36463. /**
  36464. * Assign buttons for Pitch control.
  36465. */
  36466. buttonsPitch: number[];
  36467. /**
  36468. * Assign buttons for Roll control.
  36469. */
  36470. buttonsRoll: number[];
  36471. /**
  36472. * Detect if any button is being pressed while mouse is moved.
  36473. * -1 = Mouse locked.
  36474. * 0 = Left button.
  36475. * 1 = Middle Button.
  36476. * 2 = Right Button.
  36477. */
  36478. activeButton: number;
  36479. /**
  36480. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36481. * Higher values reduce its sensitivity.
  36482. */
  36483. angularSensibility: number;
  36484. private _mousemoveCallback;
  36485. private _observer;
  36486. private _rollObserver;
  36487. private previousPosition;
  36488. private noPreventDefault;
  36489. private element;
  36490. /**
  36491. * Listen to mouse events to control the camera.
  36492. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36494. */
  36495. constructor(touchEnabled?: boolean);
  36496. /**
  36497. * Attach the mouse control to the HTML DOM element.
  36498. * @param element Defines the element that listens to the input events.
  36499. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36500. */
  36501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36502. /**
  36503. * Detach the current controls from the specified dom element.
  36504. * @param element Defines the element to stop listening the inputs from
  36505. */
  36506. detachControl(element: Nullable<HTMLElement>): void;
  36507. /**
  36508. * Gets the class name of the current input.
  36509. * @returns the class name.
  36510. */
  36511. getClassName(): string;
  36512. /**
  36513. * Get the friendly name associated with the input class.
  36514. * @returns the input's friendly name.
  36515. */
  36516. getSimpleName(): string;
  36517. private _pointerInput;
  36518. private _onMouseMove;
  36519. /**
  36520. * Rotate camera by mouse offset.
  36521. */
  36522. private rotateCamera;
  36523. }
  36524. }
  36525. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36526. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36527. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36528. /**
  36529. * Default Inputs manager for the FlyCamera.
  36530. * It groups all the default supported inputs for ease of use.
  36531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36532. */
  36533. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36534. /**
  36535. * Instantiates a new FlyCameraInputsManager.
  36536. * @param camera Defines the camera the inputs belong to.
  36537. */
  36538. constructor(camera: FlyCamera);
  36539. /**
  36540. * Add keyboard input support to the input manager.
  36541. * @returns the new FlyCameraKeyboardMoveInput().
  36542. */
  36543. addKeyboard(): FlyCameraInputsManager;
  36544. /**
  36545. * Add mouse input support to the input manager.
  36546. * @param touchEnabled Enable touch screen support.
  36547. * @returns the new FlyCameraMouseInput().
  36548. */
  36549. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36550. }
  36551. }
  36552. declare module "babylonjs/Cameras/flyCamera" {
  36553. import { Scene } from "babylonjs/scene";
  36554. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36556. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36557. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36558. /**
  36559. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36560. * such as in a 3D Space Shooter or a Flight Simulator.
  36561. */
  36562. export class FlyCamera extends TargetCamera {
  36563. /**
  36564. * Define the collision ellipsoid of the camera.
  36565. * This is helpful for simulating a camera body, like a player's body.
  36566. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36567. */
  36568. ellipsoid: Vector3;
  36569. /**
  36570. * Define an offset for the position of the ellipsoid around the camera.
  36571. * This can be helpful if the camera is attached away from the player's body center,
  36572. * such as at its head.
  36573. */
  36574. ellipsoidOffset: Vector3;
  36575. /**
  36576. * Enable or disable collisions of the camera with the rest of the scene objects.
  36577. */
  36578. checkCollisions: boolean;
  36579. /**
  36580. * Enable or disable gravity on the camera.
  36581. */
  36582. applyGravity: boolean;
  36583. /**
  36584. * Define the current direction the camera is moving to.
  36585. */
  36586. cameraDirection: Vector3;
  36587. /**
  36588. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36589. * This overrides and empties cameraRotation.
  36590. */
  36591. rotationQuaternion: Quaternion;
  36592. /**
  36593. * Track Roll to maintain the wanted Rolling when looking around.
  36594. */
  36595. _trackRoll: number;
  36596. /**
  36597. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36598. */
  36599. rollCorrect: number;
  36600. /**
  36601. * Mimic a banked turn, Rolling the camera when Yawing.
  36602. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36603. */
  36604. bankedTurn: boolean;
  36605. /**
  36606. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36607. */
  36608. bankedTurnLimit: number;
  36609. /**
  36610. * Value of 0 disables the banked Roll.
  36611. * Value of 1 is equal to the Yaw angle in radians.
  36612. */
  36613. bankedTurnMultiplier: number;
  36614. /**
  36615. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36616. */
  36617. inputs: FlyCameraInputsManager;
  36618. /**
  36619. * Gets the input sensibility for mouse input.
  36620. * Higher values reduce sensitivity.
  36621. */
  36622. /**
  36623. * Sets the input sensibility for a mouse input.
  36624. * Higher values reduce sensitivity.
  36625. */
  36626. angularSensibility: number;
  36627. /**
  36628. * Get the keys for camera movement forward.
  36629. */
  36630. /**
  36631. * Set the keys for camera movement forward.
  36632. */
  36633. keysForward: number[];
  36634. /**
  36635. * Get the keys for camera movement backward.
  36636. */
  36637. keysBackward: number[];
  36638. /**
  36639. * Get the keys for camera movement up.
  36640. */
  36641. /**
  36642. * Set the keys for camera movement up.
  36643. */
  36644. keysUp: number[];
  36645. /**
  36646. * Get the keys for camera movement down.
  36647. */
  36648. /**
  36649. * Set the keys for camera movement down.
  36650. */
  36651. keysDown: number[];
  36652. /**
  36653. * Get the keys for camera movement left.
  36654. */
  36655. /**
  36656. * Set the keys for camera movement left.
  36657. */
  36658. keysLeft: number[];
  36659. /**
  36660. * Set the keys for camera movement right.
  36661. */
  36662. /**
  36663. * Set the keys for camera movement right.
  36664. */
  36665. keysRight: number[];
  36666. /**
  36667. * Event raised when the camera collides with a mesh in the scene.
  36668. */
  36669. onCollide: (collidedMesh: AbstractMesh) => void;
  36670. private _collider;
  36671. private _needMoveForGravity;
  36672. private _oldPosition;
  36673. private _diffPosition;
  36674. private _newPosition;
  36675. /** @hidden */
  36676. _localDirection: Vector3;
  36677. /** @hidden */
  36678. _transformedDirection: Vector3;
  36679. /**
  36680. * Instantiates a FlyCamera.
  36681. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36682. * such as in a 3D Space Shooter or a Flight Simulator.
  36683. * @param name Define the name of the camera in the scene.
  36684. * @param position Define the starting position of the camera in the scene.
  36685. * @param scene Define the scene the camera belongs to.
  36686. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36687. */
  36688. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36689. /**
  36690. * Attach a control to the HTML DOM element.
  36691. * @param element Defines the element that listens to the input events.
  36692. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36693. */
  36694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36695. /**
  36696. * Detach a control from the HTML DOM element.
  36697. * The camera will stop reacting to that input.
  36698. * @param element Defines the element that listens to the input events.
  36699. */
  36700. detachControl(element: HTMLElement): void;
  36701. private _collisionMask;
  36702. /**
  36703. * Get the mask that the camera ignores in collision events.
  36704. */
  36705. /**
  36706. * Set the mask that the camera ignores in collision events.
  36707. */
  36708. collisionMask: number;
  36709. /** @hidden */
  36710. _collideWithWorld(displacement: Vector3): void;
  36711. /** @hidden */
  36712. private _onCollisionPositionChange;
  36713. /** @hidden */
  36714. _checkInputs(): void;
  36715. /** @hidden */
  36716. _decideIfNeedsToMove(): boolean;
  36717. /** @hidden */
  36718. _updatePosition(): void;
  36719. /**
  36720. * Restore the Roll to its target value at the rate specified.
  36721. * @param rate - Higher means slower restoring.
  36722. * @hidden
  36723. */
  36724. restoreRoll(rate: number): void;
  36725. /**
  36726. * Destroy the camera and release the current resources held by it.
  36727. */
  36728. dispose(): void;
  36729. /**
  36730. * Get the current object class name.
  36731. * @returns the class name.
  36732. */
  36733. getClassName(): string;
  36734. }
  36735. }
  36736. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36737. import { Nullable } from "babylonjs/types";
  36738. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36739. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36740. /**
  36741. * Listen to keyboard events to control the camera.
  36742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36743. */
  36744. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36745. /**
  36746. * Defines the camera the input is attached to.
  36747. */
  36748. camera: FlyCamera;
  36749. /**
  36750. * The list of keyboard keys used to control the forward move of the camera.
  36751. */
  36752. keysForward: number[];
  36753. /**
  36754. * The list of keyboard keys used to control the backward move of the camera.
  36755. */
  36756. keysBackward: number[];
  36757. /**
  36758. * The list of keyboard keys used to control the forward move of the camera.
  36759. */
  36760. keysUp: number[];
  36761. /**
  36762. * The list of keyboard keys used to control the backward move of the camera.
  36763. */
  36764. keysDown: number[];
  36765. /**
  36766. * The list of keyboard keys used to control the right strafe move of the camera.
  36767. */
  36768. keysRight: number[];
  36769. /**
  36770. * The list of keyboard keys used to control the left strafe move of the camera.
  36771. */
  36772. keysLeft: number[];
  36773. private _keys;
  36774. private _onCanvasBlurObserver;
  36775. private _onKeyboardObserver;
  36776. private _engine;
  36777. private _scene;
  36778. /**
  36779. * Attach the input controls to a specific dom element to get the input from.
  36780. * @param element Defines the element the controls should be listened from
  36781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36782. */
  36783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36784. /**
  36785. * Detach the current controls from the specified dom element.
  36786. * @param element Defines the element to stop listening the inputs from
  36787. */
  36788. detachControl(element: Nullable<HTMLElement>): void;
  36789. /**
  36790. * Gets the class name of the current intput.
  36791. * @returns the class name
  36792. */
  36793. getClassName(): string;
  36794. /** @hidden */
  36795. _onLostFocus(e: FocusEvent): void;
  36796. /**
  36797. * Get the friendly name associated with the input class.
  36798. * @returns the input friendly name
  36799. */
  36800. getSimpleName(): string;
  36801. /**
  36802. * Update the current camera state depending on the inputs that have been used this frame.
  36803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36804. */
  36805. checkInputs(): void;
  36806. }
  36807. }
  36808. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36809. import { Nullable } from "babylonjs/types";
  36810. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36811. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36812. /**
  36813. * Manage the mouse wheel inputs to control a follow camera.
  36814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36815. */
  36816. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36817. /**
  36818. * Defines the camera the input is attached to.
  36819. */
  36820. camera: FollowCamera;
  36821. /**
  36822. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36823. */
  36824. axisControlRadius: boolean;
  36825. /**
  36826. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36827. */
  36828. axisControlHeight: boolean;
  36829. /**
  36830. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36831. */
  36832. axisControlRotation: boolean;
  36833. /**
  36834. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36835. * relation to mouseWheel events.
  36836. */
  36837. wheelPrecision: number;
  36838. /**
  36839. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36840. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36841. */
  36842. wheelDeltaPercentage: number;
  36843. private _wheel;
  36844. private _observer;
  36845. /**
  36846. * Attach the input controls to a specific dom element to get the input from.
  36847. * @param element Defines the element the controls should be listened from
  36848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36849. */
  36850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36851. /**
  36852. * Detach the current controls from the specified dom element.
  36853. * @param element Defines the element to stop listening the inputs from
  36854. */
  36855. detachControl(element: Nullable<HTMLElement>): void;
  36856. /**
  36857. * Gets the class name of the current intput.
  36858. * @returns the class name
  36859. */
  36860. getClassName(): string;
  36861. /**
  36862. * Get the friendly name associated with the input class.
  36863. * @returns the input friendly name
  36864. */
  36865. getSimpleName(): string;
  36866. }
  36867. }
  36868. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36869. import { Nullable } from "babylonjs/types";
  36870. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36871. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36872. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36873. /**
  36874. * Manage the pointers inputs to control an follow camera.
  36875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36876. */
  36877. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36878. /**
  36879. * Defines the camera the input is attached to.
  36880. */
  36881. camera: FollowCamera;
  36882. /**
  36883. * Gets the class name of the current input.
  36884. * @returns the class name
  36885. */
  36886. getClassName(): string;
  36887. /**
  36888. * Defines the pointer angular sensibility along the X axis or how fast is
  36889. * the camera rotating.
  36890. * A negative number will reverse the axis direction.
  36891. */
  36892. angularSensibilityX: number;
  36893. /**
  36894. * Defines the pointer angular sensibility along the Y axis or how fast is
  36895. * the camera rotating.
  36896. * A negative number will reverse the axis direction.
  36897. */
  36898. angularSensibilityY: number;
  36899. /**
  36900. * Defines the pointer pinch precision or how fast is the camera zooming.
  36901. * A negative number will reverse the axis direction.
  36902. */
  36903. pinchPrecision: number;
  36904. /**
  36905. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36906. * from 0.
  36907. * It defines the percentage of current camera.radius to use as delta when
  36908. * pinch zoom is used.
  36909. */
  36910. pinchDeltaPercentage: number;
  36911. /**
  36912. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36913. */
  36914. axisXControlRadius: boolean;
  36915. /**
  36916. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36917. */
  36918. axisXControlHeight: boolean;
  36919. /**
  36920. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36921. */
  36922. axisXControlRotation: boolean;
  36923. /**
  36924. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36925. */
  36926. axisYControlRadius: boolean;
  36927. /**
  36928. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36929. */
  36930. axisYControlHeight: boolean;
  36931. /**
  36932. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36933. */
  36934. axisYControlRotation: boolean;
  36935. /**
  36936. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36937. */
  36938. axisPinchControlRadius: boolean;
  36939. /**
  36940. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36941. */
  36942. axisPinchControlHeight: boolean;
  36943. /**
  36944. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36945. */
  36946. axisPinchControlRotation: boolean;
  36947. /**
  36948. * Log error messages if basic misconfiguration has occurred.
  36949. */
  36950. warningEnable: boolean;
  36951. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36952. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36953. private _warningCounter;
  36954. private _warning;
  36955. }
  36956. }
  36957. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36958. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36959. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36960. /**
  36961. * Default Inputs manager for the FollowCamera.
  36962. * It groups all the default supported inputs for ease of use.
  36963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36964. */
  36965. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36966. /**
  36967. * Instantiates a new FollowCameraInputsManager.
  36968. * @param camera Defines the camera the inputs belong to
  36969. */
  36970. constructor(camera: FollowCamera);
  36971. /**
  36972. * Add keyboard input support to the input manager.
  36973. * @returns the current input manager
  36974. */
  36975. addKeyboard(): FollowCameraInputsManager;
  36976. /**
  36977. * Add mouse wheel input support to the input manager.
  36978. * @returns the current input manager
  36979. */
  36980. addMouseWheel(): FollowCameraInputsManager;
  36981. /**
  36982. * Add pointers input support to the input manager.
  36983. * @returns the current input manager
  36984. */
  36985. addPointers(): FollowCameraInputsManager;
  36986. /**
  36987. * Add orientation input support to the input manager.
  36988. * @returns the current input manager
  36989. */
  36990. addVRDeviceOrientation(): FollowCameraInputsManager;
  36991. }
  36992. }
  36993. declare module "babylonjs/Cameras/followCamera" {
  36994. import { Nullable } from "babylonjs/types";
  36995. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36996. import { Scene } from "babylonjs/scene";
  36997. import { Vector3 } from "babylonjs/Maths/math";
  36998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36999. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37000. /**
  37001. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37002. * an arc rotate version arcFollowCamera are available.
  37003. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37004. */
  37005. export class FollowCamera extends TargetCamera {
  37006. /**
  37007. * Distance the follow camera should follow an object at
  37008. */
  37009. radius: number;
  37010. /**
  37011. * Minimum allowed distance of the camera to the axis of rotation
  37012. * (The camera can not get closer).
  37013. * This can help limiting how the Camera is able to move in the scene.
  37014. */
  37015. lowerRadiusLimit: Nullable<number>;
  37016. /**
  37017. * Maximum allowed distance of the camera to the axis of rotation
  37018. * (The camera can not get further).
  37019. * This can help limiting how the Camera is able to move in the scene.
  37020. */
  37021. upperRadiusLimit: Nullable<number>;
  37022. /**
  37023. * Define a rotation offset between the camera and the object it follows
  37024. */
  37025. rotationOffset: number;
  37026. /**
  37027. * Minimum allowed angle to camera position relative to target object.
  37028. * This can help limiting how the Camera is able to move in the scene.
  37029. */
  37030. lowerRotationOffsetLimit: Nullable<number>;
  37031. /**
  37032. * Maximum allowed angle to camera position relative to target object.
  37033. * This can help limiting how the Camera is able to move in the scene.
  37034. */
  37035. upperRotationOffsetLimit: Nullable<number>;
  37036. /**
  37037. * Define a height offset between the camera and the object it follows.
  37038. * It can help following an object from the top (like a car chaing a plane)
  37039. */
  37040. heightOffset: number;
  37041. /**
  37042. * Minimum allowed height of camera position relative to target object.
  37043. * This can help limiting how the Camera is able to move in the scene.
  37044. */
  37045. lowerHeightOffsetLimit: Nullable<number>;
  37046. /**
  37047. * Maximum allowed height of camera position relative to target object.
  37048. * This can help limiting how the Camera is able to move in the scene.
  37049. */
  37050. upperHeightOffsetLimit: Nullable<number>;
  37051. /**
  37052. * Define how fast the camera can accelerate to follow it s target.
  37053. */
  37054. cameraAcceleration: number;
  37055. /**
  37056. * Define the speed limit of the camera following an object.
  37057. */
  37058. maxCameraSpeed: number;
  37059. /**
  37060. * Define the target of the camera.
  37061. */
  37062. lockedTarget: Nullable<AbstractMesh>;
  37063. /**
  37064. * Defines the input associated with the camera.
  37065. */
  37066. inputs: FollowCameraInputsManager;
  37067. /**
  37068. * Instantiates the follow camera.
  37069. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37070. * @param name Define the name of the camera in the scene
  37071. * @param position Define the position of the camera
  37072. * @param scene Define the scene the camera belong to
  37073. * @param lockedTarget Define the target of the camera
  37074. */
  37075. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37076. private _follow;
  37077. /**
  37078. * Attached controls to the current camera.
  37079. * @param element Defines the element the controls should be listened from
  37080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37081. */
  37082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37083. /**
  37084. * Detach the current controls from the camera.
  37085. * The camera will stop reacting to inputs.
  37086. * @param element Defines the element to stop listening the inputs from
  37087. */
  37088. detachControl(element: HTMLElement): void;
  37089. /** @hidden */
  37090. _checkInputs(): void;
  37091. private _checkLimits;
  37092. /**
  37093. * Gets the camera class name.
  37094. * @returns the class name
  37095. */
  37096. getClassName(): string;
  37097. }
  37098. /**
  37099. * Arc Rotate version of the follow camera.
  37100. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37101. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37102. */
  37103. export class ArcFollowCamera extends TargetCamera {
  37104. /** The longitudinal angle of the camera */
  37105. alpha: number;
  37106. /** The latitudinal angle of the camera */
  37107. beta: number;
  37108. /** The radius of the camera from its target */
  37109. radius: number;
  37110. /** Define the camera target (the messh it should follow) */
  37111. target: Nullable<AbstractMesh>;
  37112. private _cartesianCoordinates;
  37113. /**
  37114. * Instantiates a new ArcFollowCamera
  37115. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37116. * @param name Define the name of the camera
  37117. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37118. * @param beta Define the rotation angle of the camera around the elevation axis
  37119. * @param radius Define the radius of the camera from its target point
  37120. * @param target Define the target of the camera
  37121. * @param scene Define the scene the camera belongs to
  37122. */
  37123. constructor(name: string,
  37124. /** The longitudinal angle of the camera */
  37125. alpha: number,
  37126. /** The latitudinal angle of the camera */
  37127. beta: number,
  37128. /** The radius of the camera from its target */
  37129. radius: number,
  37130. /** Define the camera target (the messh it should follow) */
  37131. target: Nullable<AbstractMesh>, scene: Scene);
  37132. private _follow;
  37133. /** @hidden */
  37134. _checkInputs(): void;
  37135. /**
  37136. * Returns the class name of the object.
  37137. * It is mostly used internally for serialization purposes.
  37138. */
  37139. getClassName(): string;
  37140. }
  37141. }
  37142. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37143. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37144. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37145. import { Nullable } from "babylonjs/types";
  37146. /**
  37147. * Manage the keyboard inputs to control the movement of a follow camera.
  37148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37149. */
  37150. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37151. /**
  37152. * Defines the camera the input is attached to.
  37153. */
  37154. camera: FollowCamera;
  37155. /**
  37156. * Defines the list of key codes associated with the up action (increase heightOffset)
  37157. */
  37158. keysHeightOffsetIncr: number[];
  37159. /**
  37160. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37161. */
  37162. keysHeightOffsetDecr: number[];
  37163. /**
  37164. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37165. */
  37166. keysHeightOffsetModifierAlt: boolean;
  37167. /**
  37168. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37169. */
  37170. keysHeightOffsetModifierCtrl: boolean;
  37171. /**
  37172. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37173. */
  37174. keysHeightOffsetModifierShift: boolean;
  37175. /**
  37176. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37177. */
  37178. keysRotationOffsetIncr: number[];
  37179. /**
  37180. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37181. */
  37182. keysRotationOffsetDecr: number[];
  37183. /**
  37184. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37185. */
  37186. keysRotationOffsetModifierAlt: boolean;
  37187. /**
  37188. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37189. */
  37190. keysRotationOffsetModifierCtrl: boolean;
  37191. /**
  37192. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37193. */
  37194. keysRotationOffsetModifierShift: boolean;
  37195. /**
  37196. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37197. */
  37198. keysRadiusIncr: number[];
  37199. /**
  37200. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37201. */
  37202. keysRadiusDecr: number[];
  37203. /**
  37204. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37205. */
  37206. keysRadiusModifierAlt: boolean;
  37207. /**
  37208. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37209. */
  37210. keysRadiusModifierCtrl: boolean;
  37211. /**
  37212. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37213. */
  37214. keysRadiusModifierShift: boolean;
  37215. /**
  37216. * Defines the rate of change of heightOffset.
  37217. */
  37218. heightSensibility: number;
  37219. /**
  37220. * Defines the rate of change of rotationOffset.
  37221. */
  37222. rotationSensibility: number;
  37223. /**
  37224. * Defines the rate of change of radius.
  37225. */
  37226. radiusSensibility: number;
  37227. private _keys;
  37228. private _ctrlPressed;
  37229. private _altPressed;
  37230. private _shiftPressed;
  37231. private _onCanvasBlurObserver;
  37232. private _onKeyboardObserver;
  37233. private _engine;
  37234. private _scene;
  37235. /**
  37236. * Attach the input controls to a specific dom element to get the input from.
  37237. * @param element Defines the element the controls should be listened from
  37238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37239. */
  37240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37241. /**
  37242. * Detach the current controls from the specified dom element.
  37243. * @param element Defines the element to stop listening the inputs from
  37244. */
  37245. detachControl(element: Nullable<HTMLElement>): void;
  37246. /**
  37247. * Update the current camera state depending on the inputs that have been used this frame.
  37248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37249. */
  37250. checkInputs(): void;
  37251. /**
  37252. * Gets the class name of the current input.
  37253. * @returns the class name
  37254. */
  37255. getClassName(): string;
  37256. /**
  37257. * Get the friendly name associated with the input class.
  37258. * @returns the input friendly name
  37259. */
  37260. getSimpleName(): string;
  37261. /**
  37262. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37263. * allow modification of the heightOffset value.
  37264. */
  37265. private _modifierHeightOffset;
  37266. /**
  37267. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37268. * allow modification of the rotationOffset value.
  37269. */
  37270. private _modifierRotationOffset;
  37271. /**
  37272. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37273. * allow modification of the radius value.
  37274. */
  37275. private _modifierRadius;
  37276. }
  37277. }
  37278. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37279. import { Nullable } from "babylonjs/types";
  37280. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37281. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37282. module "babylonjs/Cameras/freeCameraInputsManager" {
  37283. interface FreeCameraInputsManager {
  37284. /**
  37285. * Add orientation input support to the input manager.
  37286. * @returns the current input manager
  37287. */
  37288. addDeviceOrientation(): FreeCameraInputsManager;
  37289. }
  37290. }
  37291. /**
  37292. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37293. * Screen rotation is taken into account.
  37294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37295. */
  37296. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37297. private _camera;
  37298. private _screenOrientationAngle;
  37299. private _constantTranform;
  37300. private _screenQuaternion;
  37301. private _alpha;
  37302. private _beta;
  37303. private _gamma;
  37304. /**
  37305. * Instantiates a new input
  37306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37307. */
  37308. constructor();
  37309. /**
  37310. * Define the camera controlled by the input.
  37311. */
  37312. camera: FreeCamera;
  37313. /**
  37314. * Attach the input controls to a specific dom element to get the input from.
  37315. * @param element Defines the element the controls should be listened from
  37316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37317. */
  37318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37319. private _orientationChanged;
  37320. private _deviceOrientation;
  37321. /**
  37322. * Detach the current controls from the specified dom element.
  37323. * @param element Defines the element to stop listening the inputs from
  37324. */
  37325. detachControl(element: Nullable<HTMLElement>): void;
  37326. /**
  37327. * Update the current camera state depending on the inputs that have been used this frame.
  37328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37329. */
  37330. checkInputs(): void;
  37331. /**
  37332. * Gets the class name of the current intput.
  37333. * @returns the class name
  37334. */
  37335. getClassName(): string;
  37336. /**
  37337. * Get the friendly name associated with the input class.
  37338. * @returns the input friendly name
  37339. */
  37340. getSimpleName(): string;
  37341. }
  37342. }
  37343. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37344. import { Nullable } from "babylonjs/types";
  37345. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37346. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37347. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37348. /**
  37349. * Manage the gamepad inputs to control a free camera.
  37350. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37351. */
  37352. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37353. /**
  37354. * Define the camera the input is attached to.
  37355. */
  37356. camera: FreeCamera;
  37357. /**
  37358. * Define the Gamepad controlling the input
  37359. */
  37360. gamepad: Nullable<Gamepad>;
  37361. /**
  37362. * Defines the gamepad rotation sensiblity.
  37363. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37364. */
  37365. gamepadAngularSensibility: number;
  37366. /**
  37367. * Defines the gamepad move sensiblity.
  37368. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37369. */
  37370. gamepadMoveSensibility: number;
  37371. private _onGamepadConnectedObserver;
  37372. private _onGamepadDisconnectedObserver;
  37373. private _cameraTransform;
  37374. private _deltaTransform;
  37375. private _vector3;
  37376. private _vector2;
  37377. /**
  37378. * Attach the input controls to a specific dom element to get the input from.
  37379. * @param element Defines the element the controls should be listened from
  37380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37381. */
  37382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37383. /**
  37384. * Detach the current controls from the specified dom element.
  37385. * @param element Defines the element to stop listening the inputs from
  37386. */
  37387. detachControl(element: Nullable<HTMLElement>): void;
  37388. /**
  37389. * Update the current camera state depending on the inputs that have been used this frame.
  37390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37391. */
  37392. checkInputs(): void;
  37393. /**
  37394. * Gets the class name of the current intput.
  37395. * @returns the class name
  37396. */
  37397. getClassName(): string;
  37398. /**
  37399. * Get the friendly name associated with the input class.
  37400. * @returns the input friendly name
  37401. */
  37402. getSimpleName(): string;
  37403. }
  37404. }
  37405. declare module "babylonjs/Misc/virtualJoystick" {
  37406. import { Nullable } from "babylonjs/types";
  37407. import { Vector3 } from "babylonjs/Maths/math";
  37408. /**
  37409. * Defines the potential axis of a Joystick
  37410. */
  37411. export enum JoystickAxis {
  37412. /** X axis */
  37413. X = 0,
  37414. /** Y axis */
  37415. Y = 1,
  37416. /** Z axis */
  37417. Z = 2
  37418. }
  37419. /**
  37420. * Class used to define virtual joystick (used in touch mode)
  37421. */
  37422. export class VirtualJoystick {
  37423. /**
  37424. * Gets or sets a boolean indicating that left and right values must be inverted
  37425. */
  37426. reverseLeftRight: boolean;
  37427. /**
  37428. * Gets or sets a boolean indicating that up and down values must be inverted
  37429. */
  37430. reverseUpDown: boolean;
  37431. /**
  37432. * Gets the offset value for the position (ie. the change of the position value)
  37433. */
  37434. deltaPosition: Vector3;
  37435. /**
  37436. * Gets a boolean indicating if the virtual joystick was pressed
  37437. */
  37438. pressed: boolean;
  37439. /**
  37440. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37441. */
  37442. static Canvas: Nullable<HTMLCanvasElement>;
  37443. private static _globalJoystickIndex;
  37444. private static vjCanvasContext;
  37445. private static vjCanvasWidth;
  37446. private static vjCanvasHeight;
  37447. private static halfWidth;
  37448. private _action;
  37449. private _axisTargetedByLeftAndRight;
  37450. private _axisTargetedByUpAndDown;
  37451. private _joystickSensibility;
  37452. private _inversedSensibility;
  37453. private _joystickPointerID;
  37454. private _joystickColor;
  37455. private _joystickPointerPos;
  37456. private _joystickPreviousPointerPos;
  37457. private _joystickPointerStartPos;
  37458. private _deltaJoystickVector;
  37459. private _leftJoystick;
  37460. private _touches;
  37461. private _onPointerDownHandlerRef;
  37462. private _onPointerMoveHandlerRef;
  37463. private _onPointerUpHandlerRef;
  37464. private _onResize;
  37465. /**
  37466. * Creates a new virtual joystick
  37467. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37468. */
  37469. constructor(leftJoystick?: boolean);
  37470. /**
  37471. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37472. * @param newJoystickSensibility defines the new sensibility
  37473. */
  37474. setJoystickSensibility(newJoystickSensibility: number): void;
  37475. private _onPointerDown;
  37476. private _onPointerMove;
  37477. private _onPointerUp;
  37478. /**
  37479. * Change the color of the virtual joystick
  37480. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37481. */
  37482. setJoystickColor(newColor: string): void;
  37483. /**
  37484. * Defines a callback to call when the joystick is touched
  37485. * @param action defines the callback
  37486. */
  37487. setActionOnTouch(action: () => any): void;
  37488. /**
  37489. * Defines which axis you'd like to control for left & right
  37490. * @param axis defines the axis to use
  37491. */
  37492. setAxisForLeftRight(axis: JoystickAxis): void;
  37493. /**
  37494. * Defines which axis you'd like to control for up & down
  37495. * @param axis defines the axis to use
  37496. */
  37497. setAxisForUpDown(axis: JoystickAxis): void;
  37498. private _drawVirtualJoystick;
  37499. /**
  37500. * Release internal HTML canvas
  37501. */
  37502. releaseCanvas(): void;
  37503. }
  37504. }
  37505. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37506. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37507. import { Nullable } from "babylonjs/types";
  37508. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37509. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37510. module "babylonjs/Cameras/freeCameraInputsManager" {
  37511. interface FreeCameraInputsManager {
  37512. /**
  37513. * Add virtual joystick input support to the input manager.
  37514. * @returns the current input manager
  37515. */
  37516. addVirtualJoystick(): FreeCameraInputsManager;
  37517. }
  37518. }
  37519. /**
  37520. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37522. */
  37523. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37524. /**
  37525. * Defines the camera the input is attached to.
  37526. */
  37527. camera: FreeCamera;
  37528. private _leftjoystick;
  37529. private _rightjoystick;
  37530. /**
  37531. * Gets the left stick of the virtual joystick.
  37532. * @returns The virtual Joystick
  37533. */
  37534. getLeftJoystick(): VirtualJoystick;
  37535. /**
  37536. * Gets the right stick of the virtual joystick.
  37537. * @returns The virtual Joystick
  37538. */
  37539. getRightJoystick(): VirtualJoystick;
  37540. /**
  37541. * Update the current camera state depending on the inputs that have been used this frame.
  37542. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37543. */
  37544. checkInputs(): void;
  37545. /**
  37546. * Attach the input controls to a specific dom element to get the input from.
  37547. * @param element Defines the element the controls should be listened from
  37548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37549. */
  37550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37551. /**
  37552. * Detach the current controls from the specified dom element.
  37553. * @param element Defines the element to stop listening the inputs from
  37554. */
  37555. detachControl(element: Nullable<HTMLElement>): void;
  37556. /**
  37557. * Gets the class name of the current intput.
  37558. * @returns the class name
  37559. */
  37560. getClassName(): string;
  37561. /**
  37562. * Get the friendly name associated with the input class.
  37563. * @returns the input friendly name
  37564. */
  37565. getSimpleName(): string;
  37566. }
  37567. }
  37568. declare module "babylonjs/Cameras/Inputs/index" {
  37569. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37570. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37571. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37572. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37573. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37574. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37575. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37576. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37577. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37578. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37579. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37580. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37581. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37582. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37583. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37584. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37585. }
  37586. declare module "babylonjs/Cameras/touchCamera" {
  37587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37588. import { Scene } from "babylonjs/scene";
  37589. import { Vector3 } from "babylonjs/Maths/math";
  37590. /**
  37591. * This represents a FPS type of camera controlled by touch.
  37592. * This is like a universal camera minus the Gamepad controls.
  37593. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37594. */
  37595. export class TouchCamera extends FreeCamera {
  37596. /**
  37597. * Defines the touch sensibility for rotation.
  37598. * The higher the faster.
  37599. */
  37600. touchAngularSensibility: number;
  37601. /**
  37602. * Defines the touch sensibility for move.
  37603. * The higher the faster.
  37604. */
  37605. touchMoveSensibility: number;
  37606. /**
  37607. * Instantiates a new touch camera.
  37608. * This represents a FPS type of camera controlled by touch.
  37609. * This is like a universal camera minus the Gamepad controls.
  37610. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37611. * @param name Define the name of the camera in the scene
  37612. * @param position Define the start position of the camera in the scene
  37613. * @param scene Define the scene the camera belongs to
  37614. */
  37615. constructor(name: string, position: Vector3, scene: Scene);
  37616. /**
  37617. * Gets the current object class name.
  37618. * @return the class name
  37619. */
  37620. getClassName(): string;
  37621. /** @hidden */
  37622. _setupInputs(): void;
  37623. }
  37624. }
  37625. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37626. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37627. import { Scene } from "babylonjs/scene";
  37628. import { Vector3, Axis } from "babylonjs/Maths/math";
  37629. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37630. /**
  37631. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37632. * being tilted forward or back and left or right.
  37633. */
  37634. export class DeviceOrientationCamera extends FreeCamera {
  37635. private _initialQuaternion;
  37636. private _quaternionCache;
  37637. /**
  37638. * Creates a new device orientation camera
  37639. * @param name The name of the camera
  37640. * @param position The start position camera
  37641. * @param scene The scene the camera belongs to
  37642. */
  37643. constructor(name: string, position: Vector3, scene: Scene);
  37644. /**
  37645. * Gets the current instance class name ("DeviceOrientationCamera").
  37646. * This helps avoiding instanceof at run time.
  37647. * @returns the class name
  37648. */
  37649. getClassName(): string;
  37650. /**
  37651. * @hidden
  37652. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37653. */
  37654. _checkInputs(): void;
  37655. /**
  37656. * Reset the camera to its default orientation on the specified axis only.
  37657. * @param axis The axis to reset
  37658. */
  37659. resetToCurrentRotation(axis?: Axis): void;
  37660. }
  37661. }
  37662. declare module "babylonjs/Cameras/universalCamera" {
  37663. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37664. import { Scene } from "babylonjs/scene";
  37665. import { Vector3 } from "babylonjs/Maths/math";
  37666. /**
  37667. * 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,
  37668. * which still works and will still be found in many Playgrounds.
  37669. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37670. */
  37671. export class UniversalCamera extends TouchCamera {
  37672. /**
  37673. * Defines the gamepad rotation sensiblity.
  37674. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37675. */
  37676. gamepadAngularSensibility: number;
  37677. /**
  37678. * Defines the gamepad move sensiblity.
  37679. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37680. */
  37681. gamepadMoveSensibility: number;
  37682. /**
  37683. * 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,
  37684. * which still works and will still be found in many Playgrounds.
  37685. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37686. * @param name Define the name of the camera in the scene
  37687. * @param position Define the start position of the camera in the scene
  37688. * @param scene Define the scene the camera belongs to
  37689. */
  37690. constructor(name: string, position: Vector3, scene: Scene);
  37691. /**
  37692. * Gets the current object class name.
  37693. * @return the class name
  37694. */
  37695. getClassName(): string;
  37696. }
  37697. }
  37698. declare module "babylonjs/Cameras/gamepadCamera" {
  37699. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37700. import { Scene } from "babylonjs/scene";
  37701. import { Vector3 } from "babylonjs/Maths/math";
  37702. /**
  37703. * This represents a FPS type of camera. This is only here for back compat purpose.
  37704. * Please use the UniversalCamera instead as both are identical.
  37705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37706. */
  37707. export class GamepadCamera extends UniversalCamera {
  37708. /**
  37709. * Instantiates a new Gamepad Camera
  37710. * This represents a FPS type of camera. This is only here for back compat purpose.
  37711. * Please use the UniversalCamera instead as both are identical.
  37712. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37713. * @param name Define the name of the camera in the scene
  37714. * @param position Define the start position of the camera in the scene
  37715. * @param scene Define the scene the camera belongs to
  37716. */
  37717. constructor(name: string, position: Vector3, scene: Scene);
  37718. /**
  37719. * Gets the current object class name.
  37720. * @return the class name
  37721. */
  37722. getClassName(): string;
  37723. }
  37724. }
  37725. declare module "babylonjs/Shaders/pass.fragment" {
  37726. /** @hidden */
  37727. export var passPixelShader: {
  37728. name: string;
  37729. shader: string;
  37730. };
  37731. }
  37732. declare module "babylonjs/Shaders/passCube.fragment" {
  37733. /** @hidden */
  37734. export var passCubePixelShader: {
  37735. name: string;
  37736. shader: string;
  37737. };
  37738. }
  37739. declare module "babylonjs/PostProcesses/passPostProcess" {
  37740. import { Nullable } from "babylonjs/types";
  37741. import { Camera } from "babylonjs/Cameras/camera";
  37742. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37743. import { Engine } from "babylonjs/Engines/engine";
  37744. import "babylonjs/Shaders/pass.fragment";
  37745. import "babylonjs/Shaders/passCube.fragment";
  37746. /**
  37747. * PassPostProcess which produces an output the same as it's input
  37748. */
  37749. export class PassPostProcess extends PostProcess {
  37750. /**
  37751. * Creates the PassPostProcess
  37752. * @param name The name of the effect.
  37753. * @param options The required width/height ratio to downsize to before computing the render pass.
  37754. * @param camera The camera to apply the render pass to.
  37755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37756. * @param engine The engine which the post process will be applied. (default: current engine)
  37757. * @param reusable If the post process can be reused on the same frame. (default: false)
  37758. * @param textureType The type of texture to be used when performing the post processing.
  37759. * @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)
  37760. */
  37761. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37762. }
  37763. /**
  37764. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37765. */
  37766. export class PassCubePostProcess extends PostProcess {
  37767. private _face;
  37768. /**
  37769. * Gets or sets the cube face to display.
  37770. * * 0 is +X
  37771. * * 1 is -X
  37772. * * 2 is +Y
  37773. * * 3 is -Y
  37774. * * 4 is +Z
  37775. * * 5 is -Z
  37776. */
  37777. face: number;
  37778. /**
  37779. * Creates the PassCubePostProcess
  37780. * @param name The name of the effect.
  37781. * @param options The required width/height ratio to downsize to before computing the render pass.
  37782. * @param camera The camera to apply the render pass to.
  37783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37784. * @param engine The engine which the post process will be applied. (default: current engine)
  37785. * @param reusable If the post process can be reused on the same frame. (default: false)
  37786. * @param textureType The type of texture to be used when performing the post processing.
  37787. * @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)
  37788. */
  37789. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37790. }
  37791. }
  37792. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37793. /** @hidden */
  37794. export var anaglyphPixelShader: {
  37795. name: string;
  37796. shader: string;
  37797. };
  37798. }
  37799. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37800. import { Engine } from "babylonjs/Engines/engine";
  37801. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37802. import { Camera } from "babylonjs/Cameras/camera";
  37803. import "babylonjs/Shaders/anaglyph.fragment";
  37804. /**
  37805. * Postprocess used to generate anaglyphic rendering
  37806. */
  37807. export class AnaglyphPostProcess extends PostProcess {
  37808. private _passedProcess;
  37809. /**
  37810. * Creates a new AnaglyphPostProcess
  37811. * @param name defines postprocess name
  37812. * @param options defines creation options or target ratio scale
  37813. * @param rigCameras defines cameras using this postprocess
  37814. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37815. * @param engine defines hosting engine
  37816. * @param reusable defines if the postprocess will be reused multiple times per frame
  37817. */
  37818. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37819. }
  37820. }
  37821. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37822. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37823. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37824. import { Scene } from "babylonjs/scene";
  37825. import { Vector3 } from "babylonjs/Maths/math";
  37826. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37827. /**
  37828. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37829. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37830. */
  37831. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37832. /**
  37833. * Creates a new AnaglyphArcRotateCamera
  37834. * @param name defines camera name
  37835. * @param alpha defines alpha angle (in radians)
  37836. * @param beta defines beta angle (in radians)
  37837. * @param radius defines radius
  37838. * @param target defines camera target
  37839. * @param interaxialDistance defines distance between each color axis
  37840. * @param scene defines the hosting scene
  37841. */
  37842. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37843. /**
  37844. * Gets camera class name
  37845. * @returns AnaglyphArcRotateCamera
  37846. */
  37847. getClassName(): string;
  37848. }
  37849. }
  37850. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37851. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37852. import { Scene } from "babylonjs/scene";
  37853. import { Vector3 } from "babylonjs/Maths/math";
  37854. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37855. /**
  37856. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37857. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37858. */
  37859. export class AnaglyphFreeCamera extends FreeCamera {
  37860. /**
  37861. * Creates a new AnaglyphFreeCamera
  37862. * @param name defines camera name
  37863. * @param position defines initial position
  37864. * @param interaxialDistance defines distance between each color axis
  37865. * @param scene defines the hosting scene
  37866. */
  37867. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37868. /**
  37869. * Gets camera class name
  37870. * @returns AnaglyphFreeCamera
  37871. */
  37872. getClassName(): string;
  37873. }
  37874. }
  37875. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37876. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37877. import { Scene } from "babylonjs/scene";
  37878. import { Vector3 } from "babylonjs/Maths/math";
  37879. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37880. /**
  37881. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37882. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37883. */
  37884. export class AnaglyphGamepadCamera extends GamepadCamera {
  37885. /**
  37886. * Creates a new AnaglyphGamepadCamera
  37887. * @param name defines camera name
  37888. * @param position defines initial position
  37889. * @param interaxialDistance defines distance between each color axis
  37890. * @param scene defines the hosting scene
  37891. */
  37892. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37893. /**
  37894. * Gets camera class name
  37895. * @returns AnaglyphGamepadCamera
  37896. */
  37897. getClassName(): string;
  37898. }
  37899. }
  37900. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37901. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37902. import { Scene } from "babylonjs/scene";
  37903. import { Vector3 } from "babylonjs/Maths/math";
  37904. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37905. /**
  37906. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37907. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37908. */
  37909. export class AnaglyphUniversalCamera extends UniversalCamera {
  37910. /**
  37911. * Creates a new AnaglyphUniversalCamera
  37912. * @param name defines camera name
  37913. * @param position defines initial position
  37914. * @param interaxialDistance defines distance between each color axis
  37915. * @param scene defines the hosting scene
  37916. */
  37917. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37918. /**
  37919. * Gets camera class name
  37920. * @returns AnaglyphUniversalCamera
  37921. */
  37922. getClassName(): string;
  37923. }
  37924. }
  37925. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37926. /** @hidden */
  37927. export var stereoscopicInterlacePixelShader: {
  37928. name: string;
  37929. shader: string;
  37930. };
  37931. }
  37932. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37933. import { Camera } from "babylonjs/Cameras/camera";
  37934. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37935. import { Engine } from "babylonjs/Engines/engine";
  37936. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37937. /**
  37938. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37939. */
  37940. export class StereoscopicInterlacePostProcess extends PostProcess {
  37941. private _stepSize;
  37942. private _passedProcess;
  37943. /**
  37944. * Initializes a StereoscopicInterlacePostProcess
  37945. * @param name The name of the effect.
  37946. * @param rigCameras The rig cameras to be appled to the post process
  37947. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37949. * @param engine The engine which the post process will be applied. (default: current engine)
  37950. * @param reusable If the post process can be reused on the same frame. (default: false)
  37951. */
  37952. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37953. }
  37954. }
  37955. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37956. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37957. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37958. import { Scene } from "babylonjs/scene";
  37959. import { Vector3 } from "babylonjs/Maths/math";
  37960. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37961. /**
  37962. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37963. * @see http://doc.babylonjs.com/features/cameras
  37964. */
  37965. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37966. /**
  37967. * Creates a new StereoscopicArcRotateCamera
  37968. * @param name defines camera name
  37969. * @param alpha defines alpha angle (in radians)
  37970. * @param beta defines beta angle (in radians)
  37971. * @param radius defines radius
  37972. * @param target defines camera target
  37973. * @param interaxialDistance defines distance between each color axis
  37974. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37975. * @param scene defines the hosting scene
  37976. */
  37977. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37978. /**
  37979. * Gets camera class name
  37980. * @returns StereoscopicArcRotateCamera
  37981. */
  37982. getClassName(): string;
  37983. }
  37984. }
  37985. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37986. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37987. import { Scene } from "babylonjs/scene";
  37988. import { Vector3 } from "babylonjs/Maths/math";
  37989. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37990. /**
  37991. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37992. * @see http://doc.babylonjs.com/features/cameras
  37993. */
  37994. export class StereoscopicFreeCamera extends FreeCamera {
  37995. /**
  37996. * Creates a new StereoscopicFreeCamera
  37997. * @param name defines camera name
  37998. * @param position defines initial position
  37999. * @param interaxialDistance defines distance between each color axis
  38000. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38001. * @param scene defines the hosting scene
  38002. */
  38003. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38004. /**
  38005. * Gets camera class name
  38006. * @returns StereoscopicFreeCamera
  38007. */
  38008. getClassName(): string;
  38009. }
  38010. }
  38011. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38012. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38013. import { Scene } from "babylonjs/scene";
  38014. import { Vector3 } from "babylonjs/Maths/math";
  38015. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38016. /**
  38017. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38018. * @see http://doc.babylonjs.com/features/cameras
  38019. */
  38020. export class StereoscopicGamepadCamera extends GamepadCamera {
  38021. /**
  38022. * Creates a new StereoscopicGamepadCamera
  38023. * @param name defines camera name
  38024. * @param position defines initial position
  38025. * @param interaxialDistance defines distance between each color axis
  38026. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38027. * @param scene defines the hosting scene
  38028. */
  38029. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38030. /**
  38031. * Gets camera class name
  38032. * @returns StereoscopicGamepadCamera
  38033. */
  38034. getClassName(): string;
  38035. }
  38036. }
  38037. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38038. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38039. import { Scene } from "babylonjs/scene";
  38040. import { Vector3 } from "babylonjs/Maths/math";
  38041. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38042. /**
  38043. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38044. * @see http://doc.babylonjs.com/features/cameras
  38045. */
  38046. export class StereoscopicUniversalCamera extends UniversalCamera {
  38047. /**
  38048. * Creates a new StereoscopicUniversalCamera
  38049. * @param name defines camera name
  38050. * @param position defines initial position
  38051. * @param interaxialDistance defines distance between each color axis
  38052. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38053. * @param scene defines the hosting scene
  38054. */
  38055. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38056. /**
  38057. * Gets camera class name
  38058. * @returns StereoscopicUniversalCamera
  38059. */
  38060. getClassName(): string;
  38061. }
  38062. }
  38063. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38064. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38065. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38066. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38067. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38068. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38069. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38070. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38071. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38072. }
  38073. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38074. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38075. import { Scene } from "babylonjs/scene";
  38076. import { Vector3 } from "babylonjs/Maths/math";
  38077. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38078. /**
  38079. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38080. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38081. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38082. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38083. */
  38084. export class VirtualJoysticksCamera extends FreeCamera {
  38085. /**
  38086. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38087. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38088. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38089. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38090. * @param name Define the name of the camera in the scene
  38091. * @param position Define the start position of the camera in the scene
  38092. * @param scene Define the scene the camera belongs to
  38093. */
  38094. constructor(name: string, position: Vector3, scene: Scene);
  38095. /**
  38096. * Gets the current object class name.
  38097. * @return the class name
  38098. */
  38099. getClassName(): string;
  38100. }
  38101. }
  38102. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38103. import { Matrix } from "babylonjs/Maths/math";
  38104. /**
  38105. * This represents all the required metrics to create a VR camera.
  38106. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38107. */
  38108. export class VRCameraMetrics {
  38109. /**
  38110. * Define the horizontal resolution off the screen.
  38111. */
  38112. hResolution: number;
  38113. /**
  38114. * Define the vertical resolution off the screen.
  38115. */
  38116. vResolution: number;
  38117. /**
  38118. * Define the horizontal screen size.
  38119. */
  38120. hScreenSize: number;
  38121. /**
  38122. * Define the vertical screen size.
  38123. */
  38124. vScreenSize: number;
  38125. /**
  38126. * Define the vertical screen center position.
  38127. */
  38128. vScreenCenter: number;
  38129. /**
  38130. * Define the distance of the eyes to the screen.
  38131. */
  38132. eyeToScreenDistance: number;
  38133. /**
  38134. * Define the distance between both lenses
  38135. */
  38136. lensSeparationDistance: number;
  38137. /**
  38138. * Define the distance between both viewer's eyes.
  38139. */
  38140. interpupillaryDistance: number;
  38141. /**
  38142. * Define the distortion factor of the VR postprocess.
  38143. * Please, touch with care.
  38144. */
  38145. distortionK: number[];
  38146. /**
  38147. * Define the chromatic aberration correction factors for the VR post process.
  38148. */
  38149. chromaAbCorrection: number[];
  38150. /**
  38151. * Define the scale factor of the post process.
  38152. * The smaller the better but the slower.
  38153. */
  38154. postProcessScaleFactor: number;
  38155. /**
  38156. * Define an offset for the lens center.
  38157. */
  38158. lensCenterOffset: number;
  38159. /**
  38160. * Define if the current vr camera should compensate the distortion of the lense or not.
  38161. */
  38162. compensateDistortion: boolean;
  38163. /**
  38164. * Gets the rendering aspect ratio based on the provided resolutions.
  38165. */
  38166. readonly aspectRatio: number;
  38167. /**
  38168. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38169. */
  38170. readonly aspectRatioFov: number;
  38171. /**
  38172. * @hidden
  38173. */
  38174. readonly leftHMatrix: Matrix;
  38175. /**
  38176. * @hidden
  38177. */
  38178. readonly rightHMatrix: Matrix;
  38179. /**
  38180. * @hidden
  38181. */
  38182. readonly leftPreViewMatrix: Matrix;
  38183. /**
  38184. * @hidden
  38185. */
  38186. readonly rightPreViewMatrix: Matrix;
  38187. /**
  38188. * Get the default VRMetrics based on the most generic setup.
  38189. * @returns the default vr metrics
  38190. */
  38191. static GetDefault(): VRCameraMetrics;
  38192. }
  38193. }
  38194. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38195. /** @hidden */
  38196. export var vrDistortionCorrectionPixelShader: {
  38197. name: string;
  38198. shader: string;
  38199. };
  38200. }
  38201. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38202. import { Camera } from "babylonjs/Cameras/camera";
  38203. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38204. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38205. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38206. /**
  38207. * VRDistortionCorrectionPostProcess used for mobile VR
  38208. */
  38209. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38210. private _isRightEye;
  38211. private _distortionFactors;
  38212. private _postProcessScaleFactor;
  38213. private _lensCenterOffset;
  38214. private _scaleIn;
  38215. private _scaleFactor;
  38216. private _lensCenter;
  38217. /**
  38218. * Initializes the VRDistortionCorrectionPostProcess
  38219. * @param name The name of the effect.
  38220. * @param camera The camera to apply the render pass to.
  38221. * @param isRightEye If this is for the right eye distortion
  38222. * @param vrMetrics All the required metrics for the VR camera
  38223. */
  38224. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38225. }
  38226. }
  38227. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38228. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38229. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38230. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38231. import { Scene } from "babylonjs/scene";
  38232. import { Vector3 } from "babylonjs/Maths/math";
  38233. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38234. import "babylonjs/Cameras/RigModes/vrRigMode";
  38235. /**
  38236. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38237. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38238. */
  38239. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38240. /**
  38241. * Creates a new VRDeviceOrientationArcRotateCamera
  38242. * @param name defines camera name
  38243. * @param alpha defines the camera rotation along the logitudinal axis
  38244. * @param beta defines the camera rotation along the latitudinal axis
  38245. * @param radius defines the camera distance from its target
  38246. * @param target defines the camera target
  38247. * @param scene defines the scene the camera belongs to
  38248. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38249. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38250. */
  38251. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38252. /**
  38253. * Gets camera class name
  38254. * @returns VRDeviceOrientationArcRotateCamera
  38255. */
  38256. getClassName(): string;
  38257. }
  38258. }
  38259. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38260. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38261. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38262. import { Scene } from "babylonjs/scene";
  38263. import { Vector3 } from "babylonjs/Maths/math";
  38264. import "babylonjs/Cameras/RigModes/vrRigMode";
  38265. /**
  38266. * Camera used to simulate VR rendering (based on FreeCamera)
  38267. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38268. */
  38269. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38270. /**
  38271. * Creates a new VRDeviceOrientationFreeCamera
  38272. * @param name defines camera name
  38273. * @param position defines the start position of the camera
  38274. * @param scene defines the scene the camera belongs to
  38275. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38276. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38277. */
  38278. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38279. /**
  38280. * Gets camera class name
  38281. * @returns VRDeviceOrientationFreeCamera
  38282. */
  38283. getClassName(): string;
  38284. }
  38285. }
  38286. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38287. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38288. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38289. import { Scene } from "babylonjs/scene";
  38290. import { Vector3 } from "babylonjs/Maths/math";
  38291. /**
  38292. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38293. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38294. */
  38295. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38296. /**
  38297. * Creates a new VRDeviceOrientationGamepadCamera
  38298. * @param name defines camera name
  38299. * @param position defines the start position of the camera
  38300. * @param scene defines the scene the camera belongs to
  38301. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38302. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38303. */
  38304. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38305. /**
  38306. * Gets camera class name
  38307. * @returns VRDeviceOrientationGamepadCamera
  38308. */
  38309. getClassName(): string;
  38310. }
  38311. }
  38312. declare module "babylonjs/Gamepads/xboxGamepad" {
  38313. import { Observable } from "babylonjs/Misc/observable";
  38314. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38315. /**
  38316. * Defines supported buttons for XBox360 compatible gamepads
  38317. */
  38318. export enum Xbox360Button {
  38319. /** A */
  38320. A = 0,
  38321. /** B */
  38322. B = 1,
  38323. /** X */
  38324. X = 2,
  38325. /** Y */
  38326. Y = 3,
  38327. /** Start */
  38328. Start = 4,
  38329. /** Back */
  38330. Back = 5,
  38331. /** Left button */
  38332. LB = 6,
  38333. /** Right button */
  38334. RB = 7,
  38335. /** Left stick */
  38336. LeftStick = 8,
  38337. /** Right stick */
  38338. RightStick = 9
  38339. }
  38340. /** Defines values for XBox360 DPad */
  38341. export enum Xbox360Dpad {
  38342. /** Up */
  38343. Up = 0,
  38344. /** Down */
  38345. Down = 1,
  38346. /** Left */
  38347. Left = 2,
  38348. /** Right */
  38349. Right = 3
  38350. }
  38351. /**
  38352. * Defines a XBox360 gamepad
  38353. */
  38354. export class Xbox360Pad extends Gamepad {
  38355. private _leftTrigger;
  38356. private _rightTrigger;
  38357. private _onlefttriggerchanged;
  38358. private _onrighttriggerchanged;
  38359. private _onbuttondown;
  38360. private _onbuttonup;
  38361. private _ondpaddown;
  38362. private _ondpadup;
  38363. /** Observable raised when a button is pressed */
  38364. onButtonDownObservable: Observable<Xbox360Button>;
  38365. /** Observable raised when a button is released */
  38366. onButtonUpObservable: Observable<Xbox360Button>;
  38367. /** Observable raised when a pad is pressed */
  38368. onPadDownObservable: Observable<Xbox360Dpad>;
  38369. /** Observable raised when a pad is released */
  38370. onPadUpObservable: Observable<Xbox360Dpad>;
  38371. private _buttonA;
  38372. private _buttonB;
  38373. private _buttonX;
  38374. private _buttonY;
  38375. private _buttonBack;
  38376. private _buttonStart;
  38377. private _buttonLB;
  38378. private _buttonRB;
  38379. private _buttonLeftStick;
  38380. private _buttonRightStick;
  38381. private _dPadUp;
  38382. private _dPadDown;
  38383. private _dPadLeft;
  38384. private _dPadRight;
  38385. private _isXboxOnePad;
  38386. /**
  38387. * Creates a new XBox360 gamepad object
  38388. * @param id defines the id of this gamepad
  38389. * @param index defines its index
  38390. * @param gamepad defines the internal HTML gamepad object
  38391. * @param xboxOne defines if it is a XBox One gamepad
  38392. */
  38393. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38394. /**
  38395. * Defines the callback to call when left trigger is pressed
  38396. * @param callback defines the callback to use
  38397. */
  38398. onlefttriggerchanged(callback: (value: number) => void): void;
  38399. /**
  38400. * Defines the callback to call when right trigger is pressed
  38401. * @param callback defines the callback to use
  38402. */
  38403. onrighttriggerchanged(callback: (value: number) => void): void;
  38404. /**
  38405. * Gets the left trigger value
  38406. */
  38407. /**
  38408. * Sets the left trigger value
  38409. */
  38410. leftTrigger: number;
  38411. /**
  38412. * Gets the right trigger value
  38413. */
  38414. /**
  38415. * Sets the right trigger value
  38416. */
  38417. rightTrigger: number;
  38418. /**
  38419. * Defines the callback to call when a button is pressed
  38420. * @param callback defines the callback to use
  38421. */
  38422. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38423. /**
  38424. * Defines the callback to call when a button is released
  38425. * @param callback defines the callback to use
  38426. */
  38427. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38428. /**
  38429. * Defines the callback to call when a pad is pressed
  38430. * @param callback defines the callback to use
  38431. */
  38432. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38433. /**
  38434. * Defines the callback to call when a pad is released
  38435. * @param callback defines the callback to use
  38436. */
  38437. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38438. private _setButtonValue;
  38439. private _setDPadValue;
  38440. /**
  38441. * Gets the value of the `A` button
  38442. */
  38443. /**
  38444. * Sets the value of the `A` button
  38445. */
  38446. buttonA: number;
  38447. /**
  38448. * Gets the value of the `B` button
  38449. */
  38450. /**
  38451. * Sets the value of the `B` button
  38452. */
  38453. buttonB: number;
  38454. /**
  38455. * Gets the value of the `X` button
  38456. */
  38457. /**
  38458. * Sets the value of the `X` button
  38459. */
  38460. buttonX: number;
  38461. /**
  38462. * Gets the value of the `Y` button
  38463. */
  38464. /**
  38465. * Sets the value of the `Y` button
  38466. */
  38467. buttonY: number;
  38468. /**
  38469. * Gets the value of the `Start` button
  38470. */
  38471. /**
  38472. * Sets the value of the `Start` button
  38473. */
  38474. buttonStart: number;
  38475. /**
  38476. * Gets the value of the `Back` button
  38477. */
  38478. /**
  38479. * Sets the value of the `Back` button
  38480. */
  38481. buttonBack: number;
  38482. /**
  38483. * Gets the value of the `Left` button
  38484. */
  38485. /**
  38486. * Sets the value of the `Left` button
  38487. */
  38488. buttonLB: number;
  38489. /**
  38490. * Gets the value of the `Right` button
  38491. */
  38492. /**
  38493. * Sets the value of the `Right` button
  38494. */
  38495. buttonRB: number;
  38496. /**
  38497. * Gets the value of the Left joystick
  38498. */
  38499. /**
  38500. * Sets the value of the Left joystick
  38501. */
  38502. buttonLeftStick: number;
  38503. /**
  38504. * Gets the value of the Right joystick
  38505. */
  38506. /**
  38507. * Sets the value of the Right joystick
  38508. */
  38509. buttonRightStick: number;
  38510. /**
  38511. * Gets the value of D-pad up
  38512. */
  38513. /**
  38514. * Sets the value of D-pad up
  38515. */
  38516. dPadUp: number;
  38517. /**
  38518. * Gets the value of D-pad down
  38519. */
  38520. /**
  38521. * Sets the value of D-pad down
  38522. */
  38523. dPadDown: number;
  38524. /**
  38525. * Gets the value of D-pad left
  38526. */
  38527. /**
  38528. * Sets the value of D-pad left
  38529. */
  38530. dPadLeft: number;
  38531. /**
  38532. * Gets the value of D-pad right
  38533. */
  38534. /**
  38535. * Sets the value of D-pad right
  38536. */
  38537. dPadRight: number;
  38538. /**
  38539. * Force the gamepad to synchronize with device values
  38540. */
  38541. update(): void;
  38542. /**
  38543. * Disposes the gamepad
  38544. */
  38545. dispose(): void;
  38546. }
  38547. }
  38548. declare module "babylonjs/Materials/pushMaterial" {
  38549. import { Nullable } from "babylonjs/types";
  38550. import { Scene } from "babylonjs/scene";
  38551. import { Matrix } from "babylonjs/Maths/math";
  38552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38553. import { Mesh } from "babylonjs/Meshes/mesh";
  38554. import { Material } from "babylonjs/Materials/material";
  38555. import { Effect } from "babylonjs/Materials/effect";
  38556. /**
  38557. * Base class of materials working in push mode in babylon JS
  38558. * @hidden
  38559. */
  38560. export class PushMaterial extends Material {
  38561. protected _activeEffect: Effect;
  38562. protected _normalMatrix: Matrix;
  38563. /**
  38564. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38565. * This means that the material can keep using a previous shader while a new one is being compiled.
  38566. * This is mostly used when shader parallel compilation is supported (true by default)
  38567. */
  38568. allowShaderHotSwapping: boolean;
  38569. constructor(name: string, scene: Scene);
  38570. getEffect(): Effect;
  38571. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38572. /**
  38573. * Binds the given world matrix to the active effect
  38574. *
  38575. * @param world the matrix to bind
  38576. */
  38577. bindOnlyWorldMatrix(world: Matrix): void;
  38578. /**
  38579. * Binds the given normal matrix to the active effect
  38580. *
  38581. * @param normalMatrix the matrix to bind
  38582. */
  38583. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38584. bind(world: Matrix, mesh?: Mesh): void;
  38585. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38586. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38587. }
  38588. }
  38589. declare module "babylonjs/Materials/materialFlags" {
  38590. /**
  38591. * This groups all the flags used to control the materials channel.
  38592. */
  38593. export class MaterialFlags {
  38594. private static _DiffuseTextureEnabled;
  38595. /**
  38596. * Are diffuse textures enabled in the application.
  38597. */
  38598. static DiffuseTextureEnabled: boolean;
  38599. private static _AmbientTextureEnabled;
  38600. /**
  38601. * Are ambient textures enabled in the application.
  38602. */
  38603. static AmbientTextureEnabled: boolean;
  38604. private static _OpacityTextureEnabled;
  38605. /**
  38606. * Are opacity textures enabled in the application.
  38607. */
  38608. static OpacityTextureEnabled: boolean;
  38609. private static _ReflectionTextureEnabled;
  38610. /**
  38611. * Are reflection textures enabled in the application.
  38612. */
  38613. static ReflectionTextureEnabled: boolean;
  38614. private static _EmissiveTextureEnabled;
  38615. /**
  38616. * Are emissive textures enabled in the application.
  38617. */
  38618. static EmissiveTextureEnabled: boolean;
  38619. private static _SpecularTextureEnabled;
  38620. /**
  38621. * Are specular textures enabled in the application.
  38622. */
  38623. static SpecularTextureEnabled: boolean;
  38624. private static _BumpTextureEnabled;
  38625. /**
  38626. * Are bump textures enabled in the application.
  38627. */
  38628. static BumpTextureEnabled: boolean;
  38629. private static _LightmapTextureEnabled;
  38630. /**
  38631. * Are lightmap textures enabled in the application.
  38632. */
  38633. static LightmapTextureEnabled: boolean;
  38634. private static _RefractionTextureEnabled;
  38635. /**
  38636. * Are refraction textures enabled in the application.
  38637. */
  38638. static RefractionTextureEnabled: boolean;
  38639. private static _ColorGradingTextureEnabled;
  38640. /**
  38641. * Are color grading textures enabled in the application.
  38642. */
  38643. static ColorGradingTextureEnabled: boolean;
  38644. private static _FresnelEnabled;
  38645. /**
  38646. * Are fresnels enabled in the application.
  38647. */
  38648. static FresnelEnabled: boolean;
  38649. private static _ClearCoatTextureEnabled;
  38650. /**
  38651. * Are clear coat textures enabled in the application.
  38652. */
  38653. static ClearCoatTextureEnabled: boolean;
  38654. private static _ClearCoatBumpTextureEnabled;
  38655. /**
  38656. * Are clear coat bump textures enabled in the application.
  38657. */
  38658. static ClearCoatBumpTextureEnabled: boolean;
  38659. private static _ClearCoatTintTextureEnabled;
  38660. /**
  38661. * Are clear coat tint textures enabled in the application.
  38662. */
  38663. static ClearCoatTintTextureEnabled: boolean;
  38664. private static _SheenTextureEnabled;
  38665. /**
  38666. * Are sheen textures enabled in the application.
  38667. */
  38668. static SheenTextureEnabled: boolean;
  38669. private static _AnisotropicTextureEnabled;
  38670. /**
  38671. * Are anisotropic textures enabled in the application.
  38672. */
  38673. static AnisotropicTextureEnabled: boolean;
  38674. }
  38675. }
  38676. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38677. /** @hidden */
  38678. export var defaultFragmentDeclaration: {
  38679. name: string;
  38680. shader: string;
  38681. };
  38682. }
  38683. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38684. /** @hidden */
  38685. export var defaultUboDeclaration: {
  38686. name: string;
  38687. shader: string;
  38688. };
  38689. }
  38690. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38691. /** @hidden */
  38692. export var lightFragmentDeclaration: {
  38693. name: string;
  38694. shader: string;
  38695. };
  38696. }
  38697. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38698. /** @hidden */
  38699. export var lightUboDeclaration: {
  38700. name: string;
  38701. shader: string;
  38702. };
  38703. }
  38704. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38705. /** @hidden */
  38706. export var lightsFragmentFunctions: {
  38707. name: string;
  38708. shader: string;
  38709. };
  38710. }
  38711. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38712. /** @hidden */
  38713. export var shadowsFragmentFunctions: {
  38714. name: string;
  38715. shader: string;
  38716. };
  38717. }
  38718. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38719. /** @hidden */
  38720. export var fresnelFunction: {
  38721. name: string;
  38722. shader: string;
  38723. };
  38724. }
  38725. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38726. /** @hidden */
  38727. export var reflectionFunction: {
  38728. name: string;
  38729. shader: string;
  38730. };
  38731. }
  38732. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38733. /** @hidden */
  38734. export var bumpFragmentFunctions: {
  38735. name: string;
  38736. shader: string;
  38737. };
  38738. }
  38739. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38740. /** @hidden */
  38741. export var logDepthDeclaration: {
  38742. name: string;
  38743. shader: string;
  38744. };
  38745. }
  38746. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38747. /** @hidden */
  38748. export var bumpFragment: {
  38749. name: string;
  38750. shader: string;
  38751. };
  38752. }
  38753. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38754. /** @hidden */
  38755. export var depthPrePass: {
  38756. name: string;
  38757. shader: string;
  38758. };
  38759. }
  38760. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38761. /** @hidden */
  38762. export var lightFragment: {
  38763. name: string;
  38764. shader: string;
  38765. };
  38766. }
  38767. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38768. /** @hidden */
  38769. export var logDepthFragment: {
  38770. name: string;
  38771. shader: string;
  38772. };
  38773. }
  38774. declare module "babylonjs/Shaders/default.fragment" {
  38775. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38776. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38777. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38778. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38779. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38780. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38781. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38782. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38783. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38784. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38785. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38786. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38787. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38788. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38789. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38790. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38791. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38792. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38793. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38794. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38795. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38796. /** @hidden */
  38797. export var defaultPixelShader: {
  38798. name: string;
  38799. shader: string;
  38800. };
  38801. }
  38802. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38803. /** @hidden */
  38804. export var defaultVertexDeclaration: {
  38805. name: string;
  38806. shader: string;
  38807. };
  38808. }
  38809. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38810. /** @hidden */
  38811. export var bumpVertexDeclaration: {
  38812. name: string;
  38813. shader: string;
  38814. };
  38815. }
  38816. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38817. /** @hidden */
  38818. export var bumpVertex: {
  38819. name: string;
  38820. shader: string;
  38821. };
  38822. }
  38823. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38824. /** @hidden */
  38825. export var fogVertex: {
  38826. name: string;
  38827. shader: string;
  38828. };
  38829. }
  38830. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38831. /** @hidden */
  38832. export var shadowsVertex: {
  38833. name: string;
  38834. shader: string;
  38835. };
  38836. }
  38837. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38838. /** @hidden */
  38839. export var pointCloudVertex: {
  38840. name: string;
  38841. shader: string;
  38842. };
  38843. }
  38844. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38845. /** @hidden */
  38846. export var logDepthVertex: {
  38847. name: string;
  38848. shader: string;
  38849. };
  38850. }
  38851. declare module "babylonjs/Shaders/default.vertex" {
  38852. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38853. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38854. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38856. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38857. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38858. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38859. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38860. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38861. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38862. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38863. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38864. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38866. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38867. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38868. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38869. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38870. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38871. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38872. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38873. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38874. /** @hidden */
  38875. export var defaultVertexShader: {
  38876. name: string;
  38877. shader: string;
  38878. };
  38879. }
  38880. declare module "babylonjs/Materials/standardMaterial" {
  38881. import { SmartArray } from "babylonjs/Misc/smartArray";
  38882. import { IAnimatable } from "babylonjs/Misc/tools";
  38883. import { Nullable } from "babylonjs/types";
  38884. import { Scene } from "babylonjs/scene";
  38885. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38886. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38888. import { Mesh } from "babylonjs/Meshes/mesh";
  38889. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38890. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38891. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38892. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38893. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38896. import "babylonjs/Shaders/default.fragment";
  38897. import "babylonjs/Shaders/default.vertex";
  38898. /** @hidden */
  38899. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38900. MAINUV1: boolean;
  38901. MAINUV2: boolean;
  38902. DIFFUSE: boolean;
  38903. DIFFUSEDIRECTUV: number;
  38904. AMBIENT: boolean;
  38905. AMBIENTDIRECTUV: number;
  38906. OPACITY: boolean;
  38907. OPACITYDIRECTUV: number;
  38908. OPACITYRGB: boolean;
  38909. REFLECTION: boolean;
  38910. EMISSIVE: boolean;
  38911. EMISSIVEDIRECTUV: number;
  38912. SPECULAR: boolean;
  38913. SPECULARDIRECTUV: number;
  38914. BUMP: boolean;
  38915. BUMPDIRECTUV: number;
  38916. PARALLAX: boolean;
  38917. PARALLAXOCCLUSION: boolean;
  38918. SPECULAROVERALPHA: boolean;
  38919. CLIPPLANE: boolean;
  38920. CLIPPLANE2: boolean;
  38921. CLIPPLANE3: boolean;
  38922. CLIPPLANE4: boolean;
  38923. ALPHATEST: boolean;
  38924. DEPTHPREPASS: boolean;
  38925. ALPHAFROMDIFFUSE: boolean;
  38926. POINTSIZE: boolean;
  38927. FOG: boolean;
  38928. SPECULARTERM: boolean;
  38929. DIFFUSEFRESNEL: boolean;
  38930. OPACITYFRESNEL: boolean;
  38931. REFLECTIONFRESNEL: boolean;
  38932. REFRACTIONFRESNEL: boolean;
  38933. EMISSIVEFRESNEL: boolean;
  38934. FRESNEL: boolean;
  38935. NORMAL: boolean;
  38936. UV1: boolean;
  38937. UV2: boolean;
  38938. VERTEXCOLOR: boolean;
  38939. VERTEXALPHA: boolean;
  38940. NUM_BONE_INFLUENCERS: number;
  38941. BonesPerMesh: number;
  38942. BONETEXTURE: boolean;
  38943. INSTANCES: boolean;
  38944. GLOSSINESS: boolean;
  38945. ROUGHNESS: boolean;
  38946. EMISSIVEASILLUMINATION: boolean;
  38947. LINKEMISSIVEWITHDIFFUSE: boolean;
  38948. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38949. LIGHTMAP: boolean;
  38950. LIGHTMAPDIRECTUV: number;
  38951. OBJECTSPACE_NORMALMAP: boolean;
  38952. USELIGHTMAPASSHADOWMAP: boolean;
  38953. REFLECTIONMAP_3D: boolean;
  38954. REFLECTIONMAP_SPHERICAL: boolean;
  38955. REFLECTIONMAP_PLANAR: boolean;
  38956. REFLECTIONMAP_CUBIC: boolean;
  38957. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38958. REFLECTIONMAP_PROJECTION: boolean;
  38959. REFLECTIONMAP_SKYBOX: boolean;
  38960. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38961. REFLECTIONMAP_EXPLICIT: boolean;
  38962. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38963. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38964. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38965. INVERTCUBICMAP: boolean;
  38966. LOGARITHMICDEPTH: boolean;
  38967. REFRACTION: boolean;
  38968. REFRACTIONMAP_3D: boolean;
  38969. REFLECTIONOVERALPHA: boolean;
  38970. TWOSIDEDLIGHTING: boolean;
  38971. SHADOWFLOAT: boolean;
  38972. MORPHTARGETS: boolean;
  38973. MORPHTARGETS_NORMAL: boolean;
  38974. MORPHTARGETS_TANGENT: boolean;
  38975. NUM_MORPH_INFLUENCERS: number;
  38976. NONUNIFORMSCALING: boolean;
  38977. PREMULTIPLYALPHA: boolean;
  38978. IMAGEPROCESSING: boolean;
  38979. VIGNETTE: boolean;
  38980. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38981. VIGNETTEBLENDMODEOPAQUE: boolean;
  38982. TONEMAPPING: boolean;
  38983. TONEMAPPING_ACES: boolean;
  38984. CONTRAST: boolean;
  38985. COLORCURVES: boolean;
  38986. COLORGRADING: boolean;
  38987. COLORGRADING3D: boolean;
  38988. SAMPLER3DGREENDEPTH: boolean;
  38989. SAMPLER3DBGRMAP: boolean;
  38990. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38991. /**
  38992. * If the reflection texture on this material is in linear color space
  38993. * @hidden
  38994. */
  38995. IS_REFLECTION_LINEAR: boolean;
  38996. /**
  38997. * If the refraction texture on this material is in linear color space
  38998. * @hidden
  38999. */
  39000. IS_REFRACTION_LINEAR: boolean;
  39001. EXPOSURE: boolean;
  39002. constructor();
  39003. setReflectionMode(modeToEnable: string): void;
  39004. }
  39005. /**
  39006. * This is the default material used in Babylon. It is the best trade off between quality
  39007. * and performances.
  39008. * @see http://doc.babylonjs.com/babylon101/materials
  39009. */
  39010. export class StandardMaterial extends PushMaterial {
  39011. private _diffuseTexture;
  39012. /**
  39013. * The basic texture of the material as viewed under a light.
  39014. */
  39015. diffuseTexture: Nullable<BaseTexture>;
  39016. private _ambientTexture;
  39017. /**
  39018. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39019. */
  39020. ambientTexture: Nullable<BaseTexture>;
  39021. private _opacityTexture;
  39022. /**
  39023. * Define the transparency of the material from a texture.
  39024. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39025. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39026. */
  39027. opacityTexture: Nullable<BaseTexture>;
  39028. private _reflectionTexture;
  39029. /**
  39030. * Define the texture used to display the reflection.
  39031. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39032. */
  39033. reflectionTexture: Nullable<BaseTexture>;
  39034. private _emissiveTexture;
  39035. /**
  39036. * Define texture of the material as if self lit.
  39037. * This will be mixed in the final result even in the absence of light.
  39038. */
  39039. emissiveTexture: Nullable<BaseTexture>;
  39040. private _specularTexture;
  39041. /**
  39042. * Define how the color and intensity of the highlight given by the light in the material.
  39043. */
  39044. specularTexture: Nullable<BaseTexture>;
  39045. private _bumpTexture;
  39046. /**
  39047. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39048. * 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.
  39049. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39050. */
  39051. bumpTexture: Nullable<BaseTexture>;
  39052. private _lightmapTexture;
  39053. /**
  39054. * Complex lighting can be computationally expensive to compute at runtime.
  39055. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39056. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39057. */
  39058. lightmapTexture: Nullable<BaseTexture>;
  39059. private _refractionTexture;
  39060. /**
  39061. * Define the texture used to display the refraction.
  39062. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39063. */
  39064. refractionTexture: Nullable<BaseTexture>;
  39065. /**
  39066. * The color of the material lit by the environmental background lighting.
  39067. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39068. */
  39069. ambientColor: Color3;
  39070. /**
  39071. * The basic color of the material as viewed under a light.
  39072. */
  39073. diffuseColor: Color3;
  39074. /**
  39075. * Define how the color and intensity of the highlight given by the light in the material.
  39076. */
  39077. specularColor: Color3;
  39078. /**
  39079. * Define the color of the material as if self lit.
  39080. * This will be mixed in the final result even in the absence of light.
  39081. */
  39082. emissiveColor: Color3;
  39083. /**
  39084. * Defines how sharp are the highlights in the material.
  39085. * The bigger the value the sharper giving a more glossy feeling to the result.
  39086. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39087. */
  39088. specularPower: number;
  39089. private _useAlphaFromDiffuseTexture;
  39090. /**
  39091. * Does the transparency come from the diffuse texture alpha channel.
  39092. */
  39093. useAlphaFromDiffuseTexture: boolean;
  39094. private _useEmissiveAsIllumination;
  39095. /**
  39096. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39097. */
  39098. useEmissiveAsIllumination: boolean;
  39099. private _linkEmissiveWithDiffuse;
  39100. /**
  39101. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39102. * the emissive level when the final color is close to one.
  39103. */
  39104. linkEmissiveWithDiffuse: boolean;
  39105. private _useSpecularOverAlpha;
  39106. /**
  39107. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39108. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39109. */
  39110. useSpecularOverAlpha: boolean;
  39111. private _useReflectionOverAlpha;
  39112. /**
  39113. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39114. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39115. */
  39116. useReflectionOverAlpha: boolean;
  39117. private _disableLighting;
  39118. /**
  39119. * Does lights from the scene impacts this material.
  39120. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39121. */
  39122. disableLighting: boolean;
  39123. private _useObjectSpaceNormalMap;
  39124. /**
  39125. * Allows using an object space normal map (instead of tangent space).
  39126. */
  39127. useObjectSpaceNormalMap: boolean;
  39128. private _useParallax;
  39129. /**
  39130. * Is parallax enabled or not.
  39131. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39132. */
  39133. useParallax: boolean;
  39134. private _useParallaxOcclusion;
  39135. /**
  39136. * Is parallax occlusion enabled or not.
  39137. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39138. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39139. */
  39140. useParallaxOcclusion: boolean;
  39141. /**
  39142. * 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.
  39143. */
  39144. parallaxScaleBias: number;
  39145. private _roughness;
  39146. /**
  39147. * Helps to define how blurry the reflections should appears in the material.
  39148. */
  39149. roughness: number;
  39150. /**
  39151. * In case of refraction, define the value of the indice of refraction.
  39152. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39153. */
  39154. indexOfRefraction: number;
  39155. /**
  39156. * Invert the refraction texture alongside the y axis.
  39157. * It can be useful with procedural textures or probe for instance.
  39158. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39159. */
  39160. invertRefractionY: boolean;
  39161. /**
  39162. * Defines the alpha limits in alpha test mode.
  39163. */
  39164. alphaCutOff: number;
  39165. private _useLightmapAsShadowmap;
  39166. /**
  39167. * In case of light mapping, define whether the map contains light or shadow informations.
  39168. */
  39169. useLightmapAsShadowmap: boolean;
  39170. private _diffuseFresnelParameters;
  39171. /**
  39172. * Define the diffuse fresnel parameters of the material.
  39173. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39174. */
  39175. diffuseFresnelParameters: FresnelParameters;
  39176. private _opacityFresnelParameters;
  39177. /**
  39178. * Define the opacity fresnel parameters of the material.
  39179. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39180. */
  39181. opacityFresnelParameters: FresnelParameters;
  39182. private _reflectionFresnelParameters;
  39183. /**
  39184. * Define the reflection fresnel parameters of the material.
  39185. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39186. */
  39187. reflectionFresnelParameters: FresnelParameters;
  39188. private _refractionFresnelParameters;
  39189. /**
  39190. * Define the refraction fresnel parameters of the material.
  39191. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39192. */
  39193. refractionFresnelParameters: FresnelParameters;
  39194. private _emissiveFresnelParameters;
  39195. /**
  39196. * Define the emissive fresnel parameters of the material.
  39197. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39198. */
  39199. emissiveFresnelParameters: FresnelParameters;
  39200. private _useReflectionFresnelFromSpecular;
  39201. /**
  39202. * If true automatically deducts the fresnels values from the material specularity.
  39203. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39204. */
  39205. useReflectionFresnelFromSpecular: boolean;
  39206. private _useGlossinessFromSpecularMapAlpha;
  39207. /**
  39208. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39209. */
  39210. useGlossinessFromSpecularMapAlpha: boolean;
  39211. private _maxSimultaneousLights;
  39212. /**
  39213. * Defines the maximum number of lights that can be used in the material
  39214. */
  39215. maxSimultaneousLights: number;
  39216. private _invertNormalMapX;
  39217. /**
  39218. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39219. */
  39220. invertNormalMapX: boolean;
  39221. private _invertNormalMapY;
  39222. /**
  39223. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39224. */
  39225. invertNormalMapY: boolean;
  39226. private _twoSidedLighting;
  39227. /**
  39228. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39229. */
  39230. twoSidedLighting: boolean;
  39231. /**
  39232. * Default configuration related to image processing available in the standard Material.
  39233. */
  39234. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39235. /**
  39236. * Gets the image processing configuration used either in this material.
  39237. */
  39238. /**
  39239. * Sets the Default image processing configuration used either in the this material.
  39240. *
  39241. * If sets to null, the scene one is in use.
  39242. */
  39243. imageProcessingConfiguration: ImageProcessingConfiguration;
  39244. /**
  39245. * Keep track of the image processing observer to allow dispose and replace.
  39246. */
  39247. private _imageProcessingObserver;
  39248. /**
  39249. * Attaches a new image processing configuration to the Standard Material.
  39250. * @param configuration
  39251. */
  39252. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39253. /**
  39254. * Gets wether the color curves effect is enabled.
  39255. */
  39256. /**
  39257. * Sets wether the color curves effect is enabled.
  39258. */
  39259. cameraColorCurvesEnabled: boolean;
  39260. /**
  39261. * Gets wether the color grading effect is enabled.
  39262. */
  39263. /**
  39264. * Gets wether the color grading effect is enabled.
  39265. */
  39266. cameraColorGradingEnabled: boolean;
  39267. /**
  39268. * Gets wether tonemapping is enabled or not.
  39269. */
  39270. /**
  39271. * Sets wether tonemapping is enabled or not
  39272. */
  39273. cameraToneMappingEnabled: boolean;
  39274. /**
  39275. * The camera exposure used on this material.
  39276. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39277. * This corresponds to a photographic exposure.
  39278. */
  39279. /**
  39280. * The camera exposure used on this material.
  39281. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39282. * This corresponds to a photographic exposure.
  39283. */
  39284. cameraExposure: number;
  39285. /**
  39286. * Gets The camera contrast used on this material.
  39287. */
  39288. /**
  39289. * Sets The camera contrast used on this material.
  39290. */
  39291. cameraContrast: number;
  39292. /**
  39293. * Gets the Color Grading 2D Lookup Texture.
  39294. */
  39295. /**
  39296. * Sets the Color Grading 2D Lookup Texture.
  39297. */
  39298. cameraColorGradingTexture: Nullable<BaseTexture>;
  39299. /**
  39300. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39301. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39302. * 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;
  39303. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39304. */
  39305. /**
  39306. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39307. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39308. * 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;
  39309. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39310. */
  39311. cameraColorCurves: Nullable<ColorCurves>;
  39312. /**
  39313. * Custom callback helping to override the default shader used in the material.
  39314. */
  39315. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39316. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39317. protected _worldViewProjectionMatrix: Matrix;
  39318. protected _globalAmbientColor: Color3;
  39319. protected _useLogarithmicDepth: boolean;
  39320. /**
  39321. * Instantiates a new standard material.
  39322. * This is the default material used in Babylon. It is the best trade off between quality
  39323. * and performances.
  39324. * @see http://doc.babylonjs.com/babylon101/materials
  39325. * @param name Define the name of the material in the scene
  39326. * @param scene Define the scene the material belong to
  39327. */
  39328. constructor(name: string, scene: Scene);
  39329. /**
  39330. * Gets a boolean indicating that current material needs to register RTT
  39331. */
  39332. readonly hasRenderTargetTextures: boolean;
  39333. /**
  39334. * Gets the current class name of the material e.g. "StandardMaterial"
  39335. * Mainly use in serialization.
  39336. * @returns the class name
  39337. */
  39338. getClassName(): string;
  39339. /**
  39340. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39341. * You can try switching to logarithmic depth.
  39342. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39343. */
  39344. useLogarithmicDepth: boolean;
  39345. /**
  39346. * Specifies if the material will require alpha blending
  39347. * @returns a boolean specifying if alpha blending is needed
  39348. */
  39349. needAlphaBlending(): boolean;
  39350. /**
  39351. * Specifies if this material should be rendered in alpha test mode
  39352. * @returns a boolean specifying if an alpha test is needed.
  39353. */
  39354. needAlphaTesting(): boolean;
  39355. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39356. /**
  39357. * Get the texture used for alpha test purpose.
  39358. * @returns the diffuse texture in case of the standard material.
  39359. */
  39360. getAlphaTestTexture(): Nullable<BaseTexture>;
  39361. /**
  39362. * Get if the submesh is ready to be used and all its information available.
  39363. * Child classes can use it to update shaders
  39364. * @param mesh defines the mesh to check
  39365. * @param subMesh defines which submesh to check
  39366. * @param useInstances specifies that instances should be used
  39367. * @returns a boolean indicating that the submesh is ready or not
  39368. */
  39369. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39370. /**
  39371. * Builds the material UBO layouts.
  39372. * Used internally during the effect preparation.
  39373. */
  39374. buildUniformLayout(): void;
  39375. /**
  39376. * Unbinds the material from the mesh
  39377. */
  39378. unbind(): void;
  39379. /**
  39380. * Binds the submesh to this material by preparing the effect and shader to draw
  39381. * @param world defines the world transformation matrix
  39382. * @param mesh defines the mesh containing the submesh
  39383. * @param subMesh defines the submesh to bind the material to
  39384. */
  39385. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39386. /**
  39387. * Get the list of animatables in the material.
  39388. * @returns the list of animatables object used in the material
  39389. */
  39390. getAnimatables(): IAnimatable[];
  39391. /**
  39392. * Gets the active textures from the material
  39393. * @returns an array of textures
  39394. */
  39395. getActiveTextures(): BaseTexture[];
  39396. /**
  39397. * Specifies if the material uses a texture
  39398. * @param texture defines the texture to check against the material
  39399. * @returns a boolean specifying if the material uses the texture
  39400. */
  39401. hasTexture(texture: BaseTexture): boolean;
  39402. /**
  39403. * Disposes the material
  39404. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39405. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39406. */
  39407. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39408. /**
  39409. * Makes a duplicate of the material, and gives it a new name
  39410. * @param name defines the new name for the duplicated material
  39411. * @returns the cloned material
  39412. */
  39413. clone(name: string): StandardMaterial;
  39414. /**
  39415. * Serializes this material in a JSON representation
  39416. * @returns the serialized material object
  39417. */
  39418. serialize(): any;
  39419. /**
  39420. * Creates a standard material from parsed material data
  39421. * @param source defines the JSON representation of the material
  39422. * @param scene defines the hosting scene
  39423. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39424. * @returns a new standard material
  39425. */
  39426. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39427. /**
  39428. * Are diffuse textures enabled in the application.
  39429. */
  39430. static DiffuseTextureEnabled: boolean;
  39431. /**
  39432. * Are ambient textures enabled in the application.
  39433. */
  39434. static AmbientTextureEnabled: boolean;
  39435. /**
  39436. * Are opacity textures enabled in the application.
  39437. */
  39438. static OpacityTextureEnabled: boolean;
  39439. /**
  39440. * Are reflection textures enabled in the application.
  39441. */
  39442. static ReflectionTextureEnabled: boolean;
  39443. /**
  39444. * Are emissive textures enabled in the application.
  39445. */
  39446. static EmissiveTextureEnabled: boolean;
  39447. /**
  39448. * Are specular textures enabled in the application.
  39449. */
  39450. static SpecularTextureEnabled: boolean;
  39451. /**
  39452. * Are bump textures enabled in the application.
  39453. */
  39454. static BumpTextureEnabled: boolean;
  39455. /**
  39456. * Are lightmap textures enabled in the application.
  39457. */
  39458. static LightmapTextureEnabled: boolean;
  39459. /**
  39460. * Are refraction textures enabled in the application.
  39461. */
  39462. static RefractionTextureEnabled: boolean;
  39463. /**
  39464. * Are color grading textures enabled in the application.
  39465. */
  39466. static ColorGradingTextureEnabled: boolean;
  39467. /**
  39468. * Are fresnels enabled in the application.
  39469. */
  39470. static FresnelEnabled: boolean;
  39471. }
  39472. }
  39473. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39474. import { Scene } from "babylonjs/scene";
  39475. import { Texture } from "babylonjs/Materials/Textures/texture";
  39476. /**
  39477. * A class extending Texture allowing drawing on a texture
  39478. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39479. */
  39480. export class DynamicTexture extends Texture {
  39481. private _generateMipMaps;
  39482. private _canvas;
  39483. private _context;
  39484. private _engine;
  39485. /**
  39486. * Creates a DynamicTexture
  39487. * @param name defines the name of the texture
  39488. * @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
  39489. * @param scene defines the scene where you want the texture
  39490. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39491. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39492. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39493. */
  39494. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39495. /**
  39496. * Get the current class name of the texture useful for serialization or dynamic coding.
  39497. * @returns "DynamicTexture"
  39498. */
  39499. getClassName(): string;
  39500. /**
  39501. * Gets the current state of canRescale
  39502. */
  39503. readonly canRescale: boolean;
  39504. private _recreate;
  39505. /**
  39506. * Scales the texture
  39507. * @param ratio the scale factor to apply to both width and height
  39508. */
  39509. scale(ratio: number): void;
  39510. /**
  39511. * Resizes the texture
  39512. * @param width the new width
  39513. * @param height the new height
  39514. */
  39515. scaleTo(width: number, height: number): void;
  39516. /**
  39517. * Gets the context of the canvas used by the texture
  39518. * @returns the canvas context of the dynamic texture
  39519. */
  39520. getContext(): CanvasRenderingContext2D;
  39521. /**
  39522. * Clears the texture
  39523. */
  39524. clear(): void;
  39525. /**
  39526. * Updates the texture
  39527. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39528. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39529. */
  39530. update(invertY?: boolean, premulAlpha?: boolean): void;
  39531. /**
  39532. * Draws text onto the texture
  39533. * @param text defines the text to be drawn
  39534. * @param x defines the placement of the text from the left
  39535. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39536. * @param font defines the font to be used with font-style, font-size, font-name
  39537. * @param color defines the color used for the text
  39538. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39539. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39540. * @param update defines whether texture is immediately update (default is true)
  39541. */
  39542. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39543. /**
  39544. * Clones the texture
  39545. * @returns the clone of the texture.
  39546. */
  39547. clone(): DynamicTexture;
  39548. /**
  39549. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39550. * @returns a serialized dynamic texture object
  39551. */
  39552. serialize(): any;
  39553. /** @hidden */
  39554. _rebuild(): void;
  39555. }
  39556. }
  39557. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39558. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39560. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39561. /** @hidden */
  39562. export var imageProcessingPixelShader: {
  39563. name: string;
  39564. shader: string;
  39565. };
  39566. }
  39567. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39568. import { Nullable } from "babylonjs/types";
  39569. import { Color4 } from "babylonjs/Maths/math";
  39570. import { Camera } from "babylonjs/Cameras/camera";
  39571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39572. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39573. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39574. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39575. import { Engine } from "babylonjs/Engines/engine";
  39576. import "babylonjs/Shaders/imageProcessing.fragment";
  39577. import "babylonjs/Shaders/postprocess.vertex";
  39578. /**
  39579. * ImageProcessingPostProcess
  39580. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39581. */
  39582. export class ImageProcessingPostProcess extends PostProcess {
  39583. /**
  39584. * Default configuration related to image processing available in the PBR Material.
  39585. */
  39586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39587. /**
  39588. * Gets the image processing configuration used either in this material.
  39589. */
  39590. /**
  39591. * Sets the Default image processing configuration used either in the this material.
  39592. *
  39593. * If sets to null, the scene one is in use.
  39594. */
  39595. imageProcessingConfiguration: ImageProcessingConfiguration;
  39596. /**
  39597. * Keep track of the image processing observer to allow dispose and replace.
  39598. */
  39599. private _imageProcessingObserver;
  39600. /**
  39601. * Attaches a new image processing configuration to the PBR Material.
  39602. * @param configuration
  39603. */
  39604. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39605. /**
  39606. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39607. */
  39608. /**
  39609. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39610. */
  39611. colorCurves: Nullable<ColorCurves>;
  39612. /**
  39613. * Gets wether the color curves effect is enabled.
  39614. */
  39615. /**
  39616. * Sets wether the color curves effect is enabled.
  39617. */
  39618. colorCurvesEnabled: boolean;
  39619. /**
  39620. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39621. */
  39622. /**
  39623. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39624. */
  39625. colorGradingTexture: Nullable<BaseTexture>;
  39626. /**
  39627. * Gets wether the color grading effect is enabled.
  39628. */
  39629. /**
  39630. * Gets wether the color grading effect is enabled.
  39631. */
  39632. colorGradingEnabled: boolean;
  39633. /**
  39634. * Gets exposure used in the effect.
  39635. */
  39636. /**
  39637. * Sets exposure used in the effect.
  39638. */
  39639. exposure: number;
  39640. /**
  39641. * Gets wether tonemapping is enabled or not.
  39642. */
  39643. /**
  39644. * Sets wether tonemapping is enabled or not
  39645. */
  39646. toneMappingEnabled: boolean;
  39647. /**
  39648. * Gets the type of tone mapping effect.
  39649. */
  39650. /**
  39651. * Sets the type of tone mapping effect.
  39652. */
  39653. toneMappingType: number;
  39654. /**
  39655. * Gets contrast used in the effect.
  39656. */
  39657. /**
  39658. * Sets contrast used in the effect.
  39659. */
  39660. contrast: number;
  39661. /**
  39662. * Gets Vignette stretch size.
  39663. */
  39664. /**
  39665. * Sets Vignette stretch size.
  39666. */
  39667. vignetteStretch: number;
  39668. /**
  39669. * Gets Vignette centre X Offset.
  39670. */
  39671. /**
  39672. * Sets Vignette centre X Offset.
  39673. */
  39674. vignetteCentreX: number;
  39675. /**
  39676. * Gets Vignette centre Y Offset.
  39677. */
  39678. /**
  39679. * Sets Vignette centre Y Offset.
  39680. */
  39681. vignetteCentreY: number;
  39682. /**
  39683. * Gets Vignette weight or intensity of the vignette effect.
  39684. */
  39685. /**
  39686. * Sets Vignette weight or intensity of the vignette effect.
  39687. */
  39688. vignetteWeight: number;
  39689. /**
  39690. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39691. * if vignetteEnabled is set to true.
  39692. */
  39693. /**
  39694. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39695. * if vignetteEnabled is set to true.
  39696. */
  39697. vignetteColor: Color4;
  39698. /**
  39699. * Gets Camera field of view used by the Vignette effect.
  39700. */
  39701. /**
  39702. * Sets Camera field of view used by the Vignette effect.
  39703. */
  39704. vignetteCameraFov: number;
  39705. /**
  39706. * Gets the vignette blend mode allowing different kind of effect.
  39707. */
  39708. /**
  39709. * Sets the vignette blend mode allowing different kind of effect.
  39710. */
  39711. vignetteBlendMode: number;
  39712. /**
  39713. * Gets wether the vignette effect is enabled.
  39714. */
  39715. /**
  39716. * Sets wether the vignette effect is enabled.
  39717. */
  39718. vignetteEnabled: boolean;
  39719. private _fromLinearSpace;
  39720. /**
  39721. * Gets wether the input of the processing is in Gamma or Linear Space.
  39722. */
  39723. /**
  39724. * Sets wether the input of the processing is in Gamma or Linear Space.
  39725. */
  39726. fromLinearSpace: boolean;
  39727. /**
  39728. * Defines cache preventing GC.
  39729. */
  39730. private _defines;
  39731. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39732. /**
  39733. * "ImageProcessingPostProcess"
  39734. * @returns "ImageProcessingPostProcess"
  39735. */
  39736. getClassName(): string;
  39737. protected _updateParameters(): void;
  39738. dispose(camera?: Camera): void;
  39739. }
  39740. }
  39741. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39742. import { Scene } from "babylonjs/scene";
  39743. import { Color3 } from "babylonjs/Maths/math";
  39744. import { Mesh } from "babylonjs/Meshes/mesh";
  39745. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39746. /**
  39747. * Class containing static functions to help procedurally build meshes
  39748. */
  39749. export class GroundBuilder {
  39750. /**
  39751. * Creates a ground mesh
  39752. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39753. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39755. * @param name defines the name of the mesh
  39756. * @param options defines the options used to create the mesh
  39757. * @param scene defines the hosting scene
  39758. * @returns the ground mesh
  39759. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39760. */
  39761. static CreateGround(name: string, options: {
  39762. width?: number;
  39763. height?: number;
  39764. subdivisions?: number;
  39765. subdivisionsX?: number;
  39766. subdivisionsY?: number;
  39767. updatable?: boolean;
  39768. }, scene: any): Mesh;
  39769. /**
  39770. * Creates a tiled ground mesh
  39771. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39772. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39773. * * 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
  39774. * * 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
  39775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39776. * @param name defines the name of the mesh
  39777. * @param options defines the options used to create the mesh
  39778. * @param scene defines the hosting scene
  39779. * @returns the tiled ground mesh
  39780. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39781. */
  39782. static CreateTiledGround(name: string, options: {
  39783. xmin: number;
  39784. zmin: number;
  39785. xmax: number;
  39786. zmax: number;
  39787. subdivisions?: {
  39788. w: number;
  39789. h: number;
  39790. };
  39791. precision?: {
  39792. w: number;
  39793. h: number;
  39794. };
  39795. updatable?: boolean;
  39796. }, scene: Scene): Mesh;
  39797. /**
  39798. * Creates a ground mesh from a height map
  39799. * * The parameter `url` sets the URL of the height map image resource.
  39800. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39801. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39802. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39803. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39804. * * 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.
  39805. * * 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).
  39806. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39808. * @param name defines the name of the mesh
  39809. * @param url defines the url to the height map
  39810. * @param options defines the options used to create the mesh
  39811. * @param scene defines the hosting scene
  39812. * @returns the ground mesh
  39813. * @see https://doc.babylonjs.com/babylon101/height_map
  39814. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39815. */
  39816. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39817. width?: number;
  39818. height?: number;
  39819. subdivisions?: number;
  39820. minHeight?: number;
  39821. maxHeight?: number;
  39822. colorFilter?: Color3;
  39823. alphaFilter?: number;
  39824. updatable?: boolean;
  39825. onReady?: (mesh: GroundMesh) => void;
  39826. }, scene: Scene): GroundMesh;
  39827. }
  39828. }
  39829. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39830. import { Vector4 } from "babylonjs/Maths/math";
  39831. import { Mesh } from "babylonjs/Meshes/mesh";
  39832. /**
  39833. * Class containing static functions to help procedurally build meshes
  39834. */
  39835. export class TorusBuilder {
  39836. /**
  39837. * Creates a torus mesh
  39838. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39839. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39840. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39844. * @param name defines the name of the mesh
  39845. * @param options defines the options used to create the mesh
  39846. * @param scene defines the hosting scene
  39847. * @returns the torus mesh
  39848. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39849. */
  39850. static CreateTorus(name: string, options: {
  39851. diameter?: number;
  39852. thickness?: number;
  39853. tessellation?: number;
  39854. updatable?: boolean;
  39855. sideOrientation?: number;
  39856. frontUVs?: Vector4;
  39857. backUVs?: Vector4;
  39858. }, scene: any): Mesh;
  39859. }
  39860. }
  39861. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39862. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39863. import { Mesh } from "babylonjs/Meshes/mesh";
  39864. /**
  39865. * Class containing static functions to help procedurally build meshes
  39866. */
  39867. export class CylinderBuilder {
  39868. /**
  39869. * Creates a cylinder or a cone mesh
  39870. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39871. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39872. * * 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.
  39873. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39874. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39875. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39876. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39877. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39878. * * 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).
  39879. * * 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
  39880. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39881. * * 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
  39882. * * 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.
  39883. * * If `enclose` is false, a ring surface is one element.
  39884. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39885. * * 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
  39886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39889. * @param name defines the name of the mesh
  39890. * @param options defines the options used to create the mesh
  39891. * @param scene defines the hosting scene
  39892. * @returns the cylinder mesh
  39893. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39894. */
  39895. static CreateCylinder(name: string, options: {
  39896. height?: number;
  39897. diameterTop?: number;
  39898. diameterBottom?: number;
  39899. diameter?: number;
  39900. tessellation?: number;
  39901. subdivisions?: number;
  39902. arc?: number;
  39903. faceColors?: Color4[];
  39904. faceUV?: Vector4[];
  39905. updatable?: boolean;
  39906. hasRings?: boolean;
  39907. enclose?: boolean;
  39908. sideOrientation?: number;
  39909. frontUVs?: Vector4;
  39910. backUVs?: Vector4;
  39911. }, scene: any): Mesh;
  39912. }
  39913. }
  39914. declare module "babylonjs/Gamepads/gamepadManager" {
  39915. import { Observable } from "babylonjs/Misc/observable";
  39916. import { Nullable } from "babylonjs/types";
  39917. import { Scene } from "babylonjs/scene";
  39918. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39919. /**
  39920. * Manager for handling gamepads
  39921. */
  39922. export class GamepadManager {
  39923. private _scene?;
  39924. private _babylonGamepads;
  39925. private _oneGamepadConnected;
  39926. /** @hidden */
  39927. _isMonitoring: boolean;
  39928. private _gamepadEventSupported;
  39929. private _gamepadSupport;
  39930. /**
  39931. * observable to be triggered when the gamepad controller has been connected
  39932. */
  39933. onGamepadConnectedObservable: Observable<Gamepad>;
  39934. /**
  39935. * observable to be triggered when the gamepad controller has been disconnected
  39936. */
  39937. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39938. private _onGamepadConnectedEvent;
  39939. private _onGamepadDisconnectedEvent;
  39940. /**
  39941. * Initializes the gamepad manager
  39942. * @param _scene BabylonJS scene
  39943. */
  39944. constructor(_scene?: Scene | undefined);
  39945. /**
  39946. * The gamepads in the game pad manager
  39947. */
  39948. readonly gamepads: Gamepad[];
  39949. /**
  39950. * Get the gamepad controllers based on type
  39951. * @param type The type of gamepad controller
  39952. * @returns Nullable gamepad
  39953. */
  39954. getGamepadByType(type?: number): Nullable<Gamepad>;
  39955. /**
  39956. * Disposes the gamepad manager
  39957. */
  39958. dispose(): void;
  39959. private _addNewGamepad;
  39960. private _startMonitoringGamepads;
  39961. private _stopMonitoringGamepads;
  39962. /** @hidden */
  39963. _checkGamepadsStatus(): void;
  39964. private _updateGamepadObjects;
  39965. }
  39966. }
  39967. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39968. import { Nullable } from "babylonjs/types";
  39969. import { Scene } from "babylonjs/scene";
  39970. import { ISceneComponent } from "babylonjs/sceneComponent";
  39971. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39972. module "babylonjs/scene" {
  39973. interface Scene {
  39974. /** @hidden */
  39975. _gamepadManager: Nullable<GamepadManager>;
  39976. /**
  39977. * Gets the gamepad manager associated with the scene
  39978. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39979. */
  39980. gamepadManager: GamepadManager;
  39981. }
  39982. }
  39983. module "babylonjs/Cameras/freeCameraInputsManager" {
  39984. /**
  39985. * Interface representing a free camera inputs manager
  39986. */
  39987. interface FreeCameraInputsManager {
  39988. /**
  39989. * Adds gamepad input support to the FreeCameraInputsManager.
  39990. * @returns the FreeCameraInputsManager
  39991. */
  39992. addGamepad(): FreeCameraInputsManager;
  39993. }
  39994. }
  39995. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39996. /**
  39997. * Interface representing an arc rotate camera inputs manager
  39998. */
  39999. interface ArcRotateCameraInputsManager {
  40000. /**
  40001. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40002. * @returns the camera inputs manager
  40003. */
  40004. addGamepad(): ArcRotateCameraInputsManager;
  40005. }
  40006. }
  40007. /**
  40008. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40009. */
  40010. export class GamepadSystemSceneComponent implements ISceneComponent {
  40011. /**
  40012. * The component name helpfull to identify the component in the list of scene components.
  40013. */
  40014. readonly name: string;
  40015. /**
  40016. * The scene the component belongs to.
  40017. */
  40018. scene: Scene;
  40019. /**
  40020. * Creates a new instance of the component for the given scene
  40021. * @param scene Defines the scene to register the component in
  40022. */
  40023. constructor(scene: Scene);
  40024. /**
  40025. * Registers the component in a given scene
  40026. */
  40027. register(): void;
  40028. /**
  40029. * Rebuilds the elements related to this component in case of
  40030. * context lost for instance.
  40031. */
  40032. rebuild(): void;
  40033. /**
  40034. * Disposes the component and the associated ressources
  40035. */
  40036. dispose(): void;
  40037. private _beforeCameraUpdate;
  40038. }
  40039. }
  40040. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40041. import { Observable } from "babylonjs/Misc/observable";
  40042. import { Nullable } from "babylonjs/types";
  40043. import { Camera } from "babylonjs/Cameras/camera";
  40044. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40045. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40046. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40047. import { Scene } from "babylonjs/scene";
  40048. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40049. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40051. import { Mesh } from "babylonjs/Meshes/mesh";
  40052. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40053. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40054. import "babylonjs/Meshes/Builders/groundBuilder";
  40055. import "babylonjs/Meshes/Builders/torusBuilder";
  40056. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40057. import "babylonjs/Gamepads/gamepadSceneComponent";
  40058. import "babylonjs/Animations/animatable";
  40059. /**
  40060. * Options to modify the vr teleportation behavior.
  40061. */
  40062. export interface VRTeleportationOptions {
  40063. /**
  40064. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40065. */
  40066. floorMeshName?: string;
  40067. /**
  40068. * A list of meshes to be used as the teleportation floor. (default: empty)
  40069. */
  40070. floorMeshes?: Mesh[];
  40071. }
  40072. /**
  40073. * Options to modify the vr experience helper's behavior.
  40074. */
  40075. export interface VRExperienceHelperOptions extends WebVROptions {
  40076. /**
  40077. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40078. */
  40079. createDeviceOrientationCamera?: boolean;
  40080. /**
  40081. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40082. */
  40083. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40084. /**
  40085. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40086. */
  40087. laserToggle?: boolean;
  40088. /**
  40089. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40090. */
  40091. floorMeshes?: Mesh[];
  40092. /**
  40093. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40094. */
  40095. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40096. }
  40097. /**
  40098. * Event containing information after VR has been entered
  40099. */
  40100. export class OnAfterEnteringVRObservableEvent {
  40101. /**
  40102. * If entering vr was successful
  40103. */
  40104. success: boolean;
  40105. }
  40106. /**
  40107. * Helps to quickly add VR support to an existing scene.
  40108. * See http://doc.babylonjs.com/how_to/webvr_helper
  40109. */
  40110. export class VRExperienceHelper {
  40111. /** Options to modify the vr experience helper's behavior. */
  40112. webVROptions: VRExperienceHelperOptions;
  40113. private _scene;
  40114. private _position;
  40115. private _btnVR;
  40116. private _btnVRDisplayed;
  40117. private _webVRsupported;
  40118. private _webVRready;
  40119. private _webVRrequesting;
  40120. private _webVRpresenting;
  40121. private _hasEnteredVR;
  40122. private _fullscreenVRpresenting;
  40123. private _canvas;
  40124. private _webVRCamera;
  40125. private _vrDeviceOrientationCamera;
  40126. private _deviceOrientationCamera;
  40127. private _existingCamera;
  40128. private _onKeyDown;
  40129. private _onVrDisplayPresentChange;
  40130. private _onVRDisplayChanged;
  40131. private _onVRRequestPresentStart;
  40132. private _onVRRequestPresentComplete;
  40133. /**
  40134. * Observable raised right before entering VR.
  40135. */
  40136. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40137. /**
  40138. * Observable raised when entering VR has completed.
  40139. */
  40140. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40141. /**
  40142. * Observable raised when exiting VR.
  40143. */
  40144. onExitingVRObservable: Observable<VRExperienceHelper>;
  40145. /**
  40146. * Observable raised when controller mesh is loaded.
  40147. */
  40148. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40149. /** Return this.onEnteringVRObservable
  40150. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40151. */
  40152. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40153. /** Return this.onExitingVRObservable
  40154. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40155. */
  40156. readonly onExitingVR: Observable<VRExperienceHelper>;
  40157. /** Return this.onControllerMeshLoadedObservable
  40158. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40159. */
  40160. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40161. private _rayLength;
  40162. private _useCustomVRButton;
  40163. private _teleportationRequested;
  40164. private _teleportActive;
  40165. private _floorMeshName;
  40166. private _floorMeshesCollection;
  40167. private _rotationAllowed;
  40168. private _teleportBackwardsVector;
  40169. private _teleportationTarget;
  40170. private _isDefaultTeleportationTarget;
  40171. private _postProcessMove;
  40172. private _teleportationFillColor;
  40173. private _teleportationBorderColor;
  40174. private _rotationAngle;
  40175. private _haloCenter;
  40176. private _cameraGazer;
  40177. private _padSensibilityUp;
  40178. private _padSensibilityDown;
  40179. private _leftController;
  40180. private _rightController;
  40181. /**
  40182. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40183. */
  40184. onNewMeshSelected: Observable<AbstractMesh>;
  40185. /**
  40186. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40187. */
  40188. onNewMeshPicked: Observable<PickingInfo>;
  40189. private _circleEase;
  40190. /**
  40191. * Observable raised before camera teleportation
  40192. */
  40193. onBeforeCameraTeleport: Observable<Vector3>;
  40194. /**
  40195. * Observable raised after camera teleportation
  40196. */
  40197. onAfterCameraTeleport: Observable<Vector3>;
  40198. /**
  40199. * Observable raised when current selected mesh gets unselected
  40200. */
  40201. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40202. private _raySelectionPredicate;
  40203. /**
  40204. * To be optionaly changed by user to define custom ray selection
  40205. */
  40206. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40207. /**
  40208. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40209. */
  40210. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40211. /**
  40212. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40213. */
  40214. teleportationEnabled: boolean;
  40215. private _defaultHeight;
  40216. private _teleportationInitialized;
  40217. private _interactionsEnabled;
  40218. private _interactionsRequested;
  40219. private _displayGaze;
  40220. private _displayLaserPointer;
  40221. /**
  40222. * The mesh used to display where the user is going to teleport.
  40223. */
  40224. /**
  40225. * Sets the mesh to be used to display where the user is going to teleport.
  40226. */
  40227. teleportationTarget: Mesh;
  40228. /**
  40229. * 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
  40230. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40231. * See http://doc.babylonjs.com/resources/baking_transformations
  40232. */
  40233. gazeTrackerMesh: Mesh;
  40234. /**
  40235. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40236. */
  40237. updateGazeTrackerScale: boolean;
  40238. /**
  40239. * If the gaze trackers color should be updated when selecting meshes
  40240. */
  40241. updateGazeTrackerColor: boolean;
  40242. /**
  40243. * The gaze tracking mesh corresponding to the left controller
  40244. */
  40245. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40246. /**
  40247. * The gaze tracking mesh corresponding to the right controller
  40248. */
  40249. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40250. /**
  40251. * If the ray of the gaze should be displayed.
  40252. */
  40253. /**
  40254. * Sets if the ray of the gaze should be displayed.
  40255. */
  40256. displayGaze: boolean;
  40257. /**
  40258. * If the ray of the LaserPointer should be displayed.
  40259. */
  40260. /**
  40261. * Sets if the ray of the LaserPointer should be displayed.
  40262. */
  40263. displayLaserPointer: boolean;
  40264. /**
  40265. * The deviceOrientationCamera used as the camera when not in VR.
  40266. */
  40267. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40268. /**
  40269. * Based on the current WebVR support, returns the current VR camera used.
  40270. */
  40271. readonly currentVRCamera: Nullable<Camera>;
  40272. /**
  40273. * The webVRCamera which is used when in VR.
  40274. */
  40275. readonly webVRCamera: WebVRFreeCamera;
  40276. /**
  40277. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40278. */
  40279. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40280. private readonly _teleportationRequestInitiated;
  40281. /**
  40282. * Defines wether or not Pointer lock should be requested when switching to
  40283. * full screen.
  40284. */
  40285. requestPointerLockOnFullScreen: boolean;
  40286. /**
  40287. * Instantiates a VRExperienceHelper.
  40288. * Helps to quickly add VR support to an existing scene.
  40289. * @param scene The scene the VRExperienceHelper belongs to.
  40290. * @param webVROptions Options to modify the vr experience helper's behavior.
  40291. */
  40292. constructor(scene: Scene,
  40293. /** Options to modify the vr experience helper's behavior. */
  40294. webVROptions?: VRExperienceHelperOptions);
  40295. private _onDefaultMeshLoaded;
  40296. private _onResize;
  40297. private _onFullscreenChange;
  40298. /**
  40299. * Gets a value indicating if we are currently in VR mode.
  40300. */
  40301. readonly isInVRMode: boolean;
  40302. private onVrDisplayPresentChange;
  40303. private onVRDisplayChanged;
  40304. private moveButtonToBottomRight;
  40305. private displayVRButton;
  40306. private updateButtonVisibility;
  40307. private _cachedAngularSensibility;
  40308. /**
  40309. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40310. * Otherwise, will use the fullscreen API.
  40311. */
  40312. enterVR(): void;
  40313. /**
  40314. * Attempt to exit VR, or fullscreen.
  40315. */
  40316. exitVR(): void;
  40317. /**
  40318. * The position of the vr experience helper.
  40319. */
  40320. /**
  40321. * Sets the position of the vr experience helper.
  40322. */
  40323. position: Vector3;
  40324. /**
  40325. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40326. */
  40327. enableInteractions(): void;
  40328. private readonly _noControllerIsActive;
  40329. private beforeRender;
  40330. private _isTeleportationFloor;
  40331. /**
  40332. * Adds a floor mesh to be used for teleportation.
  40333. * @param floorMesh the mesh to be used for teleportation.
  40334. */
  40335. addFloorMesh(floorMesh: Mesh): void;
  40336. /**
  40337. * Removes a floor mesh from being used for teleportation.
  40338. * @param floorMesh the mesh to be removed.
  40339. */
  40340. removeFloorMesh(floorMesh: Mesh): void;
  40341. /**
  40342. * Enables interactions and teleportation using the VR controllers and gaze.
  40343. * @param vrTeleportationOptions options to modify teleportation behavior.
  40344. */
  40345. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40346. private _onNewGamepadConnected;
  40347. private _tryEnableInteractionOnController;
  40348. private _onNewGamepadDisconnected;
  40349. private _enableInteractionOnController;
  40350. private _checkTeleportWithRay;
  40351. private _checkRotate;
  40352. private _checkTeleportBackwards;
  40353. private _enableTeleportationOnController;
  40354. private _createTeleportationCircles;
  40355. private _displayTeleportationTarget;
  40356. private _hideTeleportationTarget;
  40357. private _rotateCamera;
  40358. private _moveTeleportationSelectorTo;
  40359. private _workingVector;
  40360. private _workingQuaternion;
  40361. private _workingMatrix;
  40362. /**
  40363. * Teleports the users feet to the desired location
  40364. * @param location The location where the user's feet should be placed
  40365. */
  40366. teleportCamera(location: Vector3): void;
  40367. private _convertNormalToDirectionOfRay;
  40368. private _castRayAndSelectObject;
  40369. private _notifySelectedMeshUnselected;
  40370. /**
  40371. * Sets the color of the laser ray from the vr controllers.
  40372. * @param color new color for the ray.
  40373. */
  40374. changeLaserColor(color: Color3): void;
  40375. /**
  40376. * Sets the color of the ray from the vr headsets gaze.
  40377. * @param color new color for the ray.
  40378. */
  40379. changeGazeColor(color: Color3): void;
  40380. /**
  40381. * Exits VR and disposes of the vr experience helper
  40382. */
  40383. dispose(): void;
  40384. /**
  40385. * Gets the name of the VRExperienceHelper class
  40386. * @returns "VRExperienceHelper"
  40387. */
  40388. getClassName(): string;
  40389. }
  40390. }
  40391. declare module "babylonjs/Cameras/VR/index" {
  40392. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40393. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40394. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40395. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40396. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40397. export * from "babylonjs/Cameras/VR/webVRCamera";
  40398. }
  40399. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40400. import { Observable } from "babylonjs/Misc/observable";
  40401. import { Nullable } from "babylonjs/types";
  40402. import { IDisposable, Scene } from "babylonjs/scene";
  40403. import { Vector3 } from "babylonjs/Maths/math";
  40404. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40405. import { Ray } from "babylonjs/Culling/ray";
  40406. /**
  40407. * Manages an XRSession
  40408. * @see https://doc.babylonjs.com/how_to/webxr
  40409. */
  40410. export class WebXRSessionManager implements IDisposable {
  40411. private scene;
  40412. /**
  40413. * Fires every time a new xrFrame arrives which can be used to update the camera
  40414. */
  40415. onXRFrameObservable: Observable<any>;
  40416. /**
  40417. * Fires when the xr session is ended either by the device or manually done
  40418. */
  40419. onXRSessionEnded: Observable<any>;
  40420. /** @hidden */
  40421. _xrSession: XRSession;
  40422. /** @hidden */
  40423. _frameOfReference: XRFrameOfReference;
  40424. /** @hidden */
  40425. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40426. /** @hidden */
  40427. _currentXRFrame: Nullable<XRFrame>;
  40428. private _xrNavigator;
  40429. private _xrDevice;
  40430. private _tmpMatrix;
  40431. /**
  40432. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40433. * @param scene The scene which the session should be created for
  40434. */
  40435. constructor(scene: Scene);
  40436. /**
  40437. * Initializes the manager
  40438. * After initialization enterXR can be called to start an XR session
  40439. * @returns Promise which resolves after it is initialized
  40440. */
  40441. initializeAsync(): Promise<void>;
  40442. /**
  40443. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40444. * @param sessionCreationOptions xr options to create the session with
  40445. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40446. * @returns Promise which resolves after it enters XR
  40447. */
  40448. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40449. /**
  40450. * Stops the xrSession and restores the renderloop
  40451. * @returns Promise which resolves after it exits XR
  40452. */
  40453. exitXRAsync(): Promise<void>;
  40454. /**
  40455. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40456. * @param ray ray to cast into the environment
  40457. * @returns Promise which resolves with a collision point in the environment if it exists
  40458. */
  40459. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40460. /**
  40461. * Checks if a session would be supported for the creation options specified
  40462. * @param options creation options to check if they are supported
  40463. * @returns true if supported
  40464. */
  40465. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40466. /**
  40467. * @hidden
  40468. * Converts the render layer of xrSession to a render target
  40469. * @param session session to create render target for
  40470. * @param scene scene the new render target should be created for
  40471. */
  40472. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40473. /**
  40474. * Disposes of the session manager
  40475. */
  40476. dispose(): void;
  40477. }
  40478. }
  40479. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40480. import { Scene } from "babylonjs/scene";
  40481. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40482. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40483. /**
  40484. * WebXR Camera which holds the views for the xrSession
  40485. * @see https://doc.babylonjs.com/how_to/webxr
  40486. */
  40487. export class WebXRCamera extends FreeCamera {
  40488. private static _TmpMatrix;
  40489. /**
  40490. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40491. * @param name the name of the camera
  40492. * @param scene the scene to add the camera to
  40493. */
  40494. constructor(name: string, scene: Scene);
  40495. private _updateNumberOfRigCameras;
  40496. /** @hidden */
  40497. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40498. /**
  40499. * Updates the cameras position from the current pose information of the XR session
  40500. * @param xrSessionManager the session containing pose information
  40501. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40502. */
  40503. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40504. }
  40505. }
  40506. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40507. import { Nullable } from "babylonjs/types";
  40508. import { Observable } from "babylonjs/Misc/observable";
  40509. import { IDisposable, Scene } from "babylonjs/scene";
  40510. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40512. import { Ray } from "babylonjs/Culling/ray";
  40513. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40514. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40515. /**
  40516. * States of the webXR experience
  40517. */
  40518. export enum WebXRState {
  40519. /**
  40520. * Transitioning to being in XR mode
  40521. */
  40522. ENTERING_XR = 0,
  40523. /**
  40524. * Transitioning to non XR mode
  40525. */
  40526. EXITING_XR = 1,
  40527. /**
  40528. * In XR mode and presenting
  40529. */
  40530. IN_XR = 2,
  40531. /**
  40532. * Not entered XR mode
  40533. */
  40534. NOT_IN_XR = 3
  40535. }
  40536. /**
  40537. * Helper class used to enable XR
  40538. * @see https://doc.babylonjs.com/how_to/webxr
  40539. */
  40540. export class WebXRExperienceHelper implements IDisposable {
  40541. private scene;
  40542. /**
  40543. * 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
  40544. */
  40545. container: AbstractMesh;
  40546. /**
  40547. * Camera used to render xr content
  40548. */
  40549. camera: WebXRCamera;
  40550. /**
  40551. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40552. */
  40553. state: WebXRState;
  40554. private _setState;
  40555. private static _TmpVector;
  40556. /**
  40557. * Fires when the state of the experience helper has changed
  40558. */
  40559. onStateChangedObservable: Observable<WebXRState>;
  40560. /** @hidden */
  40561. _sessionManager: WebXRSessionManager;
  40562. private _nonVRCamera;
  40563. private _originalSceneAutoClear;
  40564. private _supported;
  40565. /**
  40566. * Creates the experience helper
  40567. * @param scene the scene to attach the experience helper to
  40568. * @returns a promise for the experience helper
  40569. */
  40570. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40571. /**
  40572. * Creates a WebXRExperienceHelper
  40573. * @param scene The scene the helper should be created in
  40574. */
  40575. private constructor();
  40576. /**
  40577. * Exits XR mode and returns the scene to its original state
  40578. * @returns promise that resolves after xr mode has exited
  40579. */
  40580. exitXRAsync(): Promise<void>;
  40581. /**
  40582. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40583. * @param sessionCreationOptions options for the XR session
  40584. * @param frameOfReference frame of reference of the XR session
  40585. * @returns promise that resolves after xr mode has entered
  40586. */
  40587. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40588. /**
  40589. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40590. * @param ray ray to cast into the environment
  40591. * @returns Promise which resolves with a collision point in the environment if it exists
  40592. */
  40593. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40594. /**
  40595. * Updates the global position of the camera by moving the camera's container
  40596. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40597. * @param position The desired global position of the camera
  40598. */
  40599. setPositionOfCameraUsingContainer(position: Vector3): void;
  40600. /**
  40601. * Rotates the xr camera by rotating the camera's container around the camera's position
  40602. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40603. * @param rotation the desired quaternion rotation to apply to the camera
  40604. */
  40605. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40606. /**
  40607. * Checks if the creation options are supported by the xr session
  40608. * @param options creation options
  40609. * @returns true if supported
  40610. */
  40611. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40612. /**
  40613. * Disposes of the experience helper
  40614. */
  40615. dispose(): void;
  40616. }
  40617. }
  40618. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40619. import { Nullable } from "babylonjs/types";
  40620. import { Observable } from "babylonjs/Misc/observable";
  40621. import { IDisposable, Scene } from "babylonjs/scene";
  40622. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40623. /**
  40624. * Button which can be used to enter a different mode of XR
  40625. */
  40626. export class WebXREnterExitUIButton {
  40627. /** button element */
  40628. element: HTMLElement;
  40629. /** XR initialization options for the button */
  40630. initializationOptions: XRSessionCreationOptions;
  40631. /**
  40632. * Creates a WebXREnterExitUIButton
  40633. * @param element button element
  40634. * @param initializationOptions XR initialization options for the button
  40635. */
  40636. constructor(
  40637. /** button element */
  40638. element: HTMLElement,
  40639. /** XR initialization options for the button */
  40640. initializationOptions: XRSessionCreationOptions);
  40641. /**
  40642. * Overwritable function which can be used to update the button's visuals when the state changes
  40643. * @param activeButton the current active button in the UI
  40644. */
  40645. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40646. }
  40647. /**
  40648. * Options to create the webXR UI
  40649. */
  40650. export class WebXREnterExitUIOptions {
  40651. /**
  40652. * Context to enter xr with
  40653. */
  40654. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40655. /**
  40656. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40657. */
  40658. customButtons?: Array<WebXREnterExitUIButton>;
  40659. }
  40660. /**
  40661. * UI to allow the user to enter/exit XR mode
  40662. */
  40663. export class WebXREnterExitUI implements IDisposable {
  40664. private scene;
  40665. private _overlay;
  40666. private _buttons;
  40667. private _activeButton;
  40668. /**
  40669. * Fired every time the active button is changed.
  40670. *
  40671. * When xr is entered via a button that launches xr that button will be the callback parameter
  40672. *
  40673. * When exiting xr the callback parameter will be null)
  40674. */
  40675. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40676. /**
  40677. * Creates UI to allow the user to enter/exit XR mode
  40678. * @param scene the scene to add the ui to
  40679. * @param helper the xr experience helper to enter/exit xr with
  40680. * @param options options to configure the UI
  40681. * @returns the created ui
  40682. */
  40683. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40684. private constructor();
  40685. private _updateButtons;
  40686. /**
  40687. * Disposes of the object
  40688. */
  40689. dispose(): void;
  40690. }
  40691. }
  40692. declare module "babylonjs/Cameras/XR/webXRInput" {
  40693. import { IDisposable, Scene } from "babylonjs/scene";
  40694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40695. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40696. /**
  40697. * Represents an XR input
  40698. */
  40699. export class WebXRController {
  40700. /**
  40701. * 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
  40702. */
  40703. grip?: AbstractMesh;
  40704. /**
  40705. * Pointer which can be used to select objects or attach a visible laser to
  40706. */
  40707. pointer: AbstractMesh;
  40708. /**
  40709. * Creates the controller
  40710. * @see https://doc.babylonjs.com/how_to/webxr
  40711. * @param scene the scene which the controller should be associated to
  40712. */
  40713. constructor(scene: Scene);
  40714. /**
  40715. * Disposes of the object
  40716. */
  40717. dispose(): void;
  40718. }
  40719. /**
  40720. * XR input used to track XR inputs such as controllers/rays
  40721. */
  40722. export class WebXRInput implements IDisposable {
  40723. private helper;
  40724. /**
  40725. * XR controllers being tracked
  40726. */
  40727. controllers: Array<WebXRController>;
  40728. private _tmpMatrix;
  40729. private _frameObserver;
  40730. /**
  40731. * Initializes the WebXRInput
  40732. * @param helper experience helper which the input should be created for
  40733. */
  40734. constructor(helper: WebXRExperienceHelper);
  40735. /**
  40736. * Disposes of the object
  40737. */
  40738. dispose(): void;
  40739. }
  40740. }
  40741. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40742. import { Nullable } from "babylonjs/types";
  40743. import { IDisposable } from "babylonjs/scene";
  40744. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40745. /**
  40746. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40747. */
  40748. export class WebXRManagedOutputCanvas implements IDisposable {
  40749. private _canvas;
  40750. /**
  40751. * xrpresent context of the canvas which can be used to display/mirror xr content
  40752. */
  40753. canvasContext: Nullable<WebGLRenderingContext>;
  40754. /**
  40755. * Initializes the canvas to be added/removed upon entering/exiting xr
  40756. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40757. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40758. */
  40759. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40760. /**
  40761. * Disposes of the object
  40762. */
  40763. dispose(): void;
  40764. private _setManagedOutputCanvas;
  40765. private _addCanvas;
  40766. private _removeCanvas;
  40767. }
  40768. }
  40769. declare module "babylonjs/Cameras/XR/index" {
  40770. export * from "babylonjs/Cameras/XR/webXRCamera";
  40771. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40772. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40773. export * from "babylonjs/Cameras/XR/webXRInput";
  40774. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40775. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40776. }
  40777. declare module "babylonjs/Cameras/RigModes/index" {
  40778. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40779. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40780. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40781. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40782. }
  40783. declare module "babylonjs/Cameras/index" {
  40784. export * from "babylonjs/Cameras/Inputs/index";
  40785. export * from "babylonjs/Cameras/cameraInputsManager";
  40786. export * from "babylonjs/Cameras/camera";
  40787. export * from "babylonjs/Cameras/targetCamera";
  40788. export * from "babylonjs/Cameras/freeCamera";
  40789. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40790. export * from "babylonjs/Cameras/touchCamera";
  40791. export * from "babylonjs/Cameras/arcRotateCamera";
  40792. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40793. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40794. export * from "babylonjs/Cameras/flyCamera";
  40795. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40796. export * from "babylonjs/Cameras/followCamera";
  40797. export * from "babylonjs/Cameras/gamepadCamera";
  40798. export * from "babylonjs/Cameras/Stereoscopic/index";
  40799. export * from "babylonjs/Cameras/universalCamera";
  40800. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40801. export * from "babylonjs/Cameras/VR/index";
  40802. export * from "babylonjs/Cameras/XR/index";
  40803. export * from "babylonjs/Cameras/RigModes/index";
  40804. }
  40805. declare module "babylonjs/Collisions/index" {
  40806. export * from "babylonjs/Collisions/collider";
  40807. export * from "babylonjs/Collisions/collisionCoordinator";
  40808. export * from "babylonjs/Collisions/pickingInfo";
  40809. export * from "babylonjs/Collisions/intersectionInfo";
  40810. }
  40811. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40812. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40813. import { Vector3, Plane } from "babylonjs/Maths/math";
  40814. import { Ray } from "babylonjs/Culling/ray";
  40815. /**
  40816. * Contains an array of blocks representing the octree
  40817. */
  40818. export interface IOctreeContainer<T> {
  40819. /**
  40820. * Blocks within the octree
  40821. */
  40822. blocks: Array<OctreeBlock<T>>;
  40823. }
  40824. /**
  40825. * Class used to store a cell in an octree
  40826. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40827. */
  40828. export class OctreeBlock<T> {
  40829. /**
  40830. * Gets the content of the current block
  40831. */
  40832. entries: T[];
  40833. /**
  40834. * Gets the list of block children
  40835. */
  40836. blocks: Array<OctreeBlock<T>>;
  40837. private _depth;
  40838. private _maxDepth;
  40839. private _capacity;
  40840. private _minPoint;
  40841. private _maxPoint;
  40842. private _boundingVectors;
  40843. private _creationFunc;
  40844. /**
  40845. * Creates a new block
  40846. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40847. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40848. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40849. * @param depth defines the current depth of this block in the octree
  40850. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40851. * @param creationFunc defines a callback to call when an element is added to the block
  40852. */
  40853. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40854. /**
  40855. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40856. */
  40857. readonly capacity: number;
  40858. /**
  40859. * Gets the minimum vector (in world space) of the block's bounding box
  40860. */
  40861. readonly minPoint: Vector3;
  40862. /**
  40863. * Gets the maximum vector (in world space) of the block's bounding box
  40864. */
  40865. readonly maxPoint: Vector3;
  40866. /**
  40867. * Add a new element to this block
  40868. * @param entry defines the element to add
  40869. */
  40870. addEntry(entry: T): void;
  40871. /**
  40872. * Remove an element from this block
  40873. * @param entry defines the element to remove
  40874. */
  40875. removeEntry(entry: T): void;
  40876. /**
  40877. * Add an array of elements to this block
  40878. * @param entries defines the array of elements to add
  40879. */
  40880. addEntries(entries: T[]): void;
  40881. /**
  40882. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40883. * @param frustumPlanes defines the frustum planes to test
  40884. * @param selection defines the array to store current content if selection is positive
  40885. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40886. */
  40887. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40888. /**
  40889. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40890. * @param sphereCenter defines the bounding sphere center
  40891. * @param sphereRadius defines the bounding sphere radius
  40892. * @param selection defines the array to store current content if selection is positive
  40893. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40894. */
  40895. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40896. /**
  40897. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40898. * @param ray defines the ray to test with
  40899. * @param selection defines the array to store current content if selection is positive
  40900. */
  40901. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40902. /**
  40903. * Subdivide the content into child blocks (this block will then be empty)
  40904. */
  40905. createInnerBlocks(): void;
  40906. /**
  40907. * @hidden
  40908. */
  40909. 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;
  40910. }
  40911. }
  40912. declare module "babylonjs/Culling/Octrees/octree" {
  40913. import { SmartArray } from "babylonjs/Misc/smartArray";
  40914. import { Vector3, Plane } from "babylonjs/Maths/math";
  40915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40917. import { Ray } from "babylonjs/Culling/ray";
  40918. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40919. /**
  40920. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40921. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40922. */
  40923. export class Octree<T> {
  40924. /** 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.) */
  40925. maxDepth: number;
  40926. /**
  40927. * Blocks within the octree containing objects
  40928. */
  40929. blocks: Array<OctreeBlock<T>>;
  40930. /**
  40931. * Content stored in the octree
  40932. */
  40933. dynamicContent: T[];
  40934. private _maxBlockCapacity;
  40935. private _selectionContent;
  40936. private _creationFunc;
  40937. /**
  40938. * Creates a octree
  40939. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40940. * @param creationFunc function to be used to instatiate the octree
  40941. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40942. * @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.)
  40943. */
  40944. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40945. /** 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.) */
  40946. maxDepth?: number);
  40947. /**
  40948. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40949. * @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);
  40950. * @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);
  40951. * @param entries meshes to be added to the octree blocks
  40952. */
  40953. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40954. /**
  40955. * Adds a mesh to the octree
  40956. * @param entry Mesh to add to the octree
  40957. */
  40958. addMesh(entry: T): void;
  40959. /**
  40960. * Remove an element from the octree
  40961. * @param entry defines the element to remove
  40962. */
  40963. removeMesh(entry: T): void;
  40964. /**
  40965. * Selects an array of meshes within the frustum
  40966. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40967. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40968. * @returns array of meshes within the frustum
  40969. */
  40970. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40971. /**
  40972. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40973. * @param sphereCenter defines the bounding sphere center
  40974. * @param sphereRadius defines the bounding sphere radius
  40975. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40976. * @returns an array of objects that intersect the sphere
  40977. */
  40978. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40979. /**
  40980. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40981. * @param ray defines the ray to test with
  40982. * @returns array of intersected objects
  40983. */
  40984. intersectsRay(ray: Ray): SmartArray<T>;
  40985. /**
  40986. * Adds a mesh into the octree block if it intersects the block
  40987. */
  40988. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40989. /**
  40990. * Adds a submesh into the octree block if it intersects the block
  40991. */
  40992. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40993. }
  40994. }
  40995. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40996. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40997. import { Scene } from "babylonjs/scene";
  40998. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41000. import { Ray } from "babylonjs/Culling/ray";
  41001. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41002. import { Collider } from "babylonjs/Collisions/collider";
  41003. module "babylonjs/scene" {
  41004. interface Scene {
  41005. /**
  41006. * @hidden
  41007. * Backing Filed
  41008. */
  41009. _selectionOctree: Octree<AbstractMesh>;
  41010. /**
  41011. * Gets the octree used to boost mesh selection (picking)
  41012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41013. */
  41014. selectionOctree: Octree<AbstractMesh>;
  41015. /**
  41016. * Creates or updates the octree used to boost selection (picking)
  41017. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41018. * @param maxCapacity defines the maximum capacity per leaf
  41019. * @param maxDepth defines the maximum depth of the octree
  41020. * @returns an octree of AbstractMesh
  41021. */
  41022. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41023. }
  41024. }
  41025. module "babylonjs/Meshes/abstractMesh" {
  41026. interface AbstractMesh {
  41027. /**
  41028. * @hidden
  41029. * Backing Field
  41030. */
  41031. _submeshesOctree: Octree<SubMesh>;
  41032. /**
  41033. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41034. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41035. * @param maxCapacity defines the maximum size of each block (64 by default)
  41036. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41037. * @returns the new octree
  41038. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41040. */
  41041. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41042. }
  41043. }
  41044. /**
  41045. * Defines the octree scene component responsible to manage any octrees
  41046. * in a given scene.
  41047. */
  41048. export class OctreeSceneComponent {
  41049. /**
  41050. * The component name helpfull to identify the component in the list of scene components.
  41051. */
  41052. readonly name: string;
  41053. /**
  41054. * The scene the component belongs to.
  41055. */
  41056. scene: Scene;
  41057. /**
  41058. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41059. */
  41060. readonly checksIsEnabled: boolean;
  41061. /**
  41062. * Creates a new instance of the component for the given scene
  41063. * @param scene Defines the scene to register the component in
  41064. */
  41065. constructor(scene: Scene);
  41066. /**
  41067. * Registers the component in a given scene
  41068. */
  41069. register(): void;
  41070. /**
  41071. * Return the list of active meshes
  41072. * @returns the list of active meshes
  41073. */
  41074. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41075. /**
  41076. * Return the list of active sub meshes
  41077. * @param mesh The mesh to get the candidates sub meshes from
  41078. * @returns the list of active sub meshes
  41079. */
  41080. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41081. private _tempRay;
  41082. /**
  41083. * Return the list of sub meshes intersecting with a given local ray
  41084. * @param mesh defines the mesh to find the submesh for
  41085. * @param localRay defines the ray in local space
  41086. * @returns the list of intersecting sub meshes
  41087. */
  41088. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41089. /**
  41090. * Return the list of sub meshes colliding with a collider
  41091. * @param mesh defines the mesh to find the submesh for
  41092. * @param collider defines the collider to evaluate the collision against
  41093. * @returns the list of colliding sub meshes
  41094. */
  41095. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41096. /**
  41097. * Rebuilds the elements related to this component in case of
  41098. * context lost for instance.
  41099. */
  41100. rebuild(): void;
  41101. /**
  41102. * Disposes the component and the associated ressources.
  41103. */
  41104. dispose(): void;
  41105. }
  41106. }
  41107. declare module "babylonjs/Culling/Octrees/index" {
  41108. export * from "babylonjs/Culling/Octrees/octree";
  41109. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41110. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41111. }
  41112. declare module "babylonjs/Culling/index" {
  41113. export * from "babylonjs/Culling/boundingBox";
  41114. export * from "babylonjs/Culling/boundingInfo";
  41115. export * from "babylonjs/Culling/boundingSphere";
  41116. export * from "babylonjs/Culling/Octrees/index";
  41117. export * from "babylonjs/Culling/ray";
  41118. }
  41119. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41120. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41121. import { Nullable } from "babylonjs/types";
  41122. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41123. import { Scene } from "babylonjs/scene";
  41124. /**
  41125. * Class containing static functions to help procedurally build meshes
  41126. */
  41127. export class LinesBuilder {
  41128. /**
  41129. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41130. * * 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
  41131. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41132. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41133. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41134. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41135. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41136. * * 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
  41137. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41140. * @param name defines the name of the new line system
  41141. * @param options defines the options used to create the line system
  41142. * @param scene defines the hosting scene
  41143. * @returns a new line system mesh
  41144. */
  41145. static CreateLineSystem(name: string, options: {
  41146. lines: Vector3[][];
  41147. updatable?: boolean;
  41148. instance?: Nullable<LinesMesh>;
  41149. colors?: Nullable<Color4[][]>;
  41150. useVertexAlpha?: boolean;
  41151. }, scene: Nullable<Scene>): LinesMesh;
  41152. /**
  41153. * Creates a line mesh
  41154. * 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
  41155. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41156. * * The parameter `points` is an array successive Vector3
  41157. * * 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
  41158. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41159. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41160. * * When updating an instance, remember that only point positions can change, not the number of points
  41161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41163. * @param name defines the name of the new line system
  41164. * @param options defines the options used to create the line system
  41165. * @param scene defines the hosting scene
  41166. * @returns a new line mesh
  41167. */
  41168. static CreateLines(name: string, options: {
  41169. points: Vector3[];
  41170. updatable?: boolean;
  41171. instance?: Nullable<LinesMesh>;
  41172. colors?: Color4[];
  41173. useVertexAlpha?: boolean;
  41174. }, scene?: Nullable<Scene>): LinesMesh;
  41175. /**
  41176. * Creates a dashed line mesh
  41177. * * 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
  41178. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41179. * * The parameter `points` is an array successive Vector3
  41180. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41181. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41182. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41183. * * 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
  41184. * * When updating an instance, remember that only point positions can change, not the number of points
  41185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41186. * @param name defines the name of the mesh
  41187. * @param options defines the options used to create the mesh
  41188. * @param scene defines the hosting scene
  41189. * @returns the dashed line mesh
  41190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41191. */
  41192. static CreateDashedLines(name: string, options: {
  41193. points: Vector3[];
  41194. dashSize?: number;
  41195. gapSize?: number;
  41196. dashNb?: number;
  41197. updatable?: boolean;
  41198. instance?: LinesMesh;
  41199. }, scene?: Nullable<Scene>): LinesMesh;
  41200. }
  41201. }
  41202. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41203. import { IDisposable, Scene } from "babylonjs/scene";
  41204. import { Nullable } from "babylonjs/types";
  41205. import { Observable } from "babylonjs/Misc/observable";
  41206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41207. /**
  41208. * Renders a layer on top of an existing scene
  41209. */
  41210. export class UtilityLayerRenderer implements IDisposable {
  41211. /** the original scene that will be rendered on top of */
  41212. originalScene: Scene;
  41213. private _pointerCaptures;
  41214. private _lastPointerEvents;
  41215. private static _DefaultUtilityLayer;
  41216. private static _DefaultKeepDepthUtilityLayer;
  41217. /**
  41218. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41219. */
  41220. pickUtilitySceneFirst: boolean;
  41221. /**
  41222. * 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)
  41223. */
  41224. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41225. /**
  41226. * 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)
  41227. */
  41228. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41229. /**
  41230. * The scene that is rendered on top of the original scene
  41231. */
  41232. utilityLayerScene: Scene;
  41233. /**
  41234. * If the utility layer should automatically be rendered on top of existing scene
  41235. */
  41236. shouldRender: boolean;
  41237. /**
  41238. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41239. */
  41240. onlyCheckPointerDownEvents: boolean;
  41241. /**
  41242. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41243. */
  41244. processAllEvents: boolean;
  41245. /**
  41246. * Observable raised when the pointer move from the utility layer scene to the main scene
  41247. */
  41248. onPointerOutObservable: Observable<number>;
  41249. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41250. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41251. private _afterRenderObserver;
  41252. private _sceneDisposeObserver;
  41253. private _originalPointerObserver;
  41254. /**
  41255. * Instantiates a UtilityLayerRenderer
  41256. * @param originalScene the original scene that will be rendered on top of
  41257. * @param handleEvents boolean indicating if the utility layer should handle events
  41258. */
  41259. constructor(
  41260. /** the original scene that will be rendered on top of */
  41261. originalScene: Scene, handleEvents?: boolean);
  41262. private _notifyObservers;
  41263. /**
  41264. * Renders the utility layers scene on top of the original scene
  41265. */
  41266. render(): void;
  41267. /**
  41268. * Disposes of the renderer
  41269. */
  41270. dispose(): void;
  41271. private _updateCamera;
  41272. }
  41273. }
  41274. declare module "babylonjs/Gizmos/gizmo" {
  41275. import { Nullable } from "babylonjs/types";
  41276. import { IDisposable } from "babylonjs/scene";
  41277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41278. import { Mesh } from "babylonjs/Meshes/mesh";
  41279. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41280. /**
  41281. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41282. */
  41283. export class Gizmo implements IDisposable {
  41284. /** The utility layer the gizmo will be added to */
  41285. gizmoLayer: UtilityLayerRenderer;
  41286. /**
  41287. * The root mesh of the gizmo
  41288. */
  41289. _rootMesh: Mesh;
  41290. private _attachedMesh;
  41291. /**
  41292. * Ratio for the scale of the gizmo (Default: 1)
  41293. */
  41294. scaleRatio: number;
  41295. private _tmpMatrix;
  41296. /**
  41297. * If a custom mesh has been set (Default: false)
  41298. */
  41299. protected _customMeshSet: boolean;
  41300. /**
  41301. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41302. * * When set, interactions will be enabled
  41303. */
  41304. attachedMesh: Nullable<AbstractMesh>;
  41305. /**
  41306. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41307. * @param mesh The mesh to replace the default mesh of the gizmo
  41308. */
  41309. setCustomMesh(mesh: Mesh): void;
  41310. /**
  41311. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41312. */
  41313. updateGizmoRotationToMatchAttachedMesh: boolean;
  41314. /**
  41315. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41316. */
  41317. updateGizmoPositionToMatchAttachedMesh: boolean;
  41318. /**
  41319. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41320. */
  41321. protected _updateScale: boolean;
  41322. protected _interactionsEnabled: boolean;
  41323. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41324. private _beforeRenderObserver;
  41325. /**
  41326. * Creates a gizmo
  41327. * @param gizmoLayer The utility layer the gizmo will be added to
  41328. */
  41329. constructor(
  41330. /** The utility layer the gizmo will be added to */
  41331. gizmoLayer?: UtilityLayerRenderer);
  41332. private _tempVector;
  41333. /**
  41334. * @hidden
  41335. * Updates the gizmo to match the attached mesh's position/rotation
  41336. */
  41337. protected _update(): void;
  41338. /**
  41339. * Disposes of the gizmo
  41340. */
  41341. dispose(): void;
  41342. }
  41343. }
  41344. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41345. import { Observable } from "babylonjs/Misc/observable";
  41346. import { Nullable } from "babylonjs/types";
  41347. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41348. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41350. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41351. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41352. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41353. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41354. import { Scene } from "babylonjs/scene";
  41355. /**
  41356. * Single axis drag gizmo
  41357. */
  41358. export class AxisDragGizmo extends Gizmo {
  41359. /**
  41360. * Drag behavior responsible for the gizmos dragging interactions
  41361. */
  41362. dragBehavior: PointerDragBehavior;
  41363. private _pointerObserver;
  41364. /**
  41365. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41366. */
  41367. snapDistance: number;
  41368. /**
  41369. * Event that fires each time the gizmo snaps to a new location.
  41370. * * snapDistance is the the change in distance
  41371. */
  41372. onSnapObservable: Observable<{
  41373. snapDistance: number;
  41374. }>;
  41375. /** @hidden */
  41376. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41377. /** @hidden */
  41378. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41379. /**
  41380. * Creates an AxisDragGizmo
  41381. * @param gizmoLayer The utility layer the gizmo will be added to
  41382. * @param dragAxis The axis which the gizmo will be able to drag on
  41383. * @param color The color of the gizmo
  41384. */
  41385. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41386. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41387. /**
  41388. * Disposes of the gizmo
  41389. */
  41390. dispose(): void;
  41391. }
  41392. }
  41393. declare module "babylonjs/Debug/axesViewer" {
  41394. import { Vector3 } from "babylonjs/Maths/math";
  41395. import { Nullable } from "babylonjs/types";
  41396. import { Scene } from "babylonjs/scene";
  41397. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41398. /**
  41399. * The Axes viewer will show 3 axes in a specific point in space
  41400. */
  41401. export class AxesViewer {
  41402. private _xAxis;
  41403. private _yAxis;
  41404. private _zAxis;
  41405. private _scaleLinesFactor;
  41406. private _instanced;
  41407. /**
  41408. * Gets the hosting scene
  41409. */
  41410. scene: Scene;
  41411. /**
  41412. * Gets or sets a number used to scale line length
  41413. */
  41414. scaleLines: number;
  41415. /** Gets the node hierarchy used to render x-axis */
  41416. readonly xAxis: TransformNode;
  41417. /** Gets the node hierarchy used to render y-axis */
  41418. readonly yAxis: TransformNode;
  41419. /** Gets the node hierarchy used to render z-axis */
  41420. readonly zAxis: TransformNode;
  41421. /**
  41422. * Creates a new AxesViewer
  41423. * @param scene defines the hosting scene
  41424. * @param scaleLines defines a number used to scale line length (1 by default)
  41425. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41426. * @param xAxis defines the node hierarchy used to render the x-axis
  41427. * @param yAxis defines the node hierarchy used to render the y-axis
  41428. * @param zAxis defines the node hierarchy used to render the z-axis
  41429. */
  41430. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41431. /**
  41432. * Force the viewer to update
  41433. * @param position defines the position of the viewer
  41434. * @param xaxis defines the x axis of the viewer
  41435. * @param yaxis defines the y axis of the viewer
  41436. * @param zaxis defines the z axis of the viewer
  41437. */
  41438. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41439. /**
  41440. * Creates an instance of this axes viewer.
  41441. * @returns a new axes viewer with instanced meshes
  41442. */
  41443. createInstance(): AxesViewer;
  41444. /** Releases resources */
  41445. dispose(): void;
  41446. private static _SetRenderingGroupId;
  41447. }
  41448. }
  41449. declare module "babylonjs/Debug/boneAxesViewer" {
  41450. import { Nullable } from "babylonjs/types";
  41451. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41452. import { Vector3 } from "babylonjs/Maths/math";
  41453. import { Mesh } from "babylonjs/Meshes/mesh";
  41454. import { Bone } from "babylonjs/Bones/bone";
  41455. import { Scene } from "babylonjs/scene";
  41456. /**
  41457. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41458. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41459. */
  41460. export class BoneAxesViewer extends AxesViewer {
  41461. /**
  41462. * Gets or sets the target mesh where to display the axes viewer
  41463. */
  41464. mesh: Nullable<Mesh>;
  41465. /**
  41466. * Gets or sets the target bone where to display the axes viewer
  41467. */
  41468. bone: Nullable<Bone>;
  41469. /** Gets current position */
  41470. pos: Vector3;
  41471. /** Gets direction of X axis */
  41472. xaxis: Vector3;
  41473. /** Gets direction of Y axis */
  41474. yaxis: Vector3;
  41475. /** Gets direction of Z axis */
  41476. zaxis: Vector3;
  41477. /**
  41478. * Creates a new BoneAxesViewer
  41479. * @param scene defines the hosting scene
  41480. * @param bone defines the target bone
  41481. * @param mesh defines the target mesh
  41482. * @param scaleLines defines a scaling factor for line length (1 by default)
  41483. */
  41484. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41485. /**
  41486. * Force the viewer to update
  41487. */
  41488. update(): void;
  41489. /** Releases resources */
  41490. dispose(): void;
  41491. }
  41492. }
  41493. declare module "babylonjs/Debug/debugLayer" {
  41494. import { Observable } from "babylonjs/Misc/observable";
  41495. import { Scene } from "babylonjs/scene";
  41496. /**
  41497. * Interface used to define scene explorer extensibility option
  41498. */
  41499. export interface IExplorerExtensibilityOption {
  41500. /**
  41501. * Define the option label
  41502. */
  41503. label: string;
  41504. /**
  41505. * Defines the action to execute on click
  41506. */
  41507. action: (entity: any) => void;
  41508. }
  41509. /**
  41510. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41511. */
  41512. export interface IExplorerExtensibilityGroup {
  41513. /**
  41514. * Defines a predicate to test if a given type mut be extended
  41515. */
  41516. predicate: (entity: any) => boolean;
  41517. /**
  41518. * Gets the list of options added to a type
  41519. */
  41520. entries: IExplorerExtensibilityOption[];
  41521. }
  41522. /**
  41523. * Interface used to define the options to use to create the Inspector
  41524. */
  41525. export interface IInspectorOptions {
  41526. /**
  41527. * Display in overlay mode (default: false)
  41528. */
  41529. overlay?: boolean;
  41530. /**
  41531. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41532. */
  41533. globalRoot?: HTMLElement;
  41534. /**
  41535. * Display the Scene explorer
  41536. */
  41537. showExplorer?: boolean;
  41538. /**
  41539. * Display the property inspector
  41540. */
  41541. showInspector?: boolean;
  41542. /**
  41543. * Display in embed mode (both panes on the right)
  41544. */
  41545. embedMode?: boolean;
  41546. /**
  41547. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41548. */
  41549. handleResize?: boolean;
  41550. /**
  41551. * Allow the panes to popup (default: true)
  41552. */
  41553. enablePopup?: boolean;
  41554. /**
  41555. * Allow the panes to be closed by users (default: true)
  41556. */
  41557. enableClose?: boolean;
  41558. /**
  41559. * Optional list of extensibility entries
  41560. */
  41561. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41562. /**
  41563. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41564. */
  41565. inspectorURL?: string;
  41566. }
  41567. module "babylonjs/scene" {
  41568. interface Scene {
  41569. /**
  41570. * @hidden
  41571. * Backing field
  41572. */
  41573. _debugLayer: DebugLayer;
  41574. /**
  41575. * Gets the debug layer (aka Inspector) associated with the scene
  41576. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41577. */
  41578. debugLayer: DebugLayer;
  41579. }
  41580. }
  41581. /**
  41582. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41583. * what is happening in your scene
  41584. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41585. */
  41586. export class DebugLayer {
  41587. /**
  41588. * Define the url to get the inspector script from.
  41589. * By default it uses the babylonjs CDN.
  41590. * @ignoreNaming
  41591. */
  41592. static InspectorURL: string;
  41593. private _scene;
  41594. private BJSINSPECTOR;
  41595. /**
  41596. * Observable triggered when a property is changed through the inspector.
  41597. */
  41598. onPropertyChangedObservable: Observable<{
  41599. object: any;
  41600. property: string;
  41601. value: any;
  41602. initialValue: any;
  41603. }>;
  41604. /**
  41605. * Instantiates a new debug layer.
  41606. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41607. * what is happening in your scene
  41608. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41609. * @param scene Defines the scene to inspect
  41610. */
  41611. constructor(scene: Scene);
  41612. /** Creates the inspector window. */
  41613. private _createInspector;
  41614. /**
  41615. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41616. * @param entity defines the entity to select
  41617. * @param lineContainerTitle defines the specific block to highlight
  41618. */
  41619. select(entity: any, lineContainerTitle?: string): void;
  41620. /** Get the inspector from bundle or global */
  41621. private _getGlobalInspector;
  41622. /**
  41623. * Get if the inspector is visible or not.
  41624. * @returns true if visible otherwise, false
  41625. */
  41626. isVisible(): boolean;
  41627. /**
  41628. * Hide the inspector and close its window.
  41629. */
  41630. hide(): void;
  41631. /**
  41632. * Launch the debugLayer.
  41633. * @param config Define the configuration of the inspector
  41634. * @return a promise fulfilled when the debug layer is visible
  41635. */
  41636. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41637. }
  41638. }
  41639. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41640. import { Nullable } from "babylonjs/types";
  41641. import { Scene } from "babylonjs/scene";
  41642. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41643. import { Mesh } from "babylonjs/Meshes/mesh";
  41644. /**
  41645. * Class containing static functions to help procedurally build meshes
  41646. */
  41647. export class BoxBuilder {
  41648. /**
  41649. * Creates a box mesh
  41650. * * The parameter `size` sets the size (float) of each box side (default 1)
  41651. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41652. * * 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)
  41653. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41657. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41658. * @param name defines the name of the mesh
  41659. * @param options defines the options used to create the mesh
  41660. * @param scene defines the hosting scene
  41661. * @returns the box mesh
  41662. */
  41663. static CreateBox(name: string, options: {
  41664. size?: number;
  41665. width?: number;
  41666. height?: number;
  41667. depth?: number;
  41668. faceUV?: Vector4[];
  41669. faceColors?: Color4[];
  41670. sideOrientation?: number;
  41671. frontUVs?: Vector4;
  41672. backUVs?: Vector4;
  41673. updatable?: boolean;
  41674. }, scene?: Nullable<Scene>): Mesh;
  41675. }
  41676. }
  41677. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41678. import { Vector4 } from "babylonjs/Maths/math";
  41679. import { Mesh } from "babylonjs/Meshes/mesh";
  41680. /**
  41681. * Class containing static functions to help procedurally build meshes
  41682. */
  41683. export class SphereBuilder {
  41684. /**
  41685. * Creates a sphere mesh
  41686. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41687. * * 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`)
  41688. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41689. * * 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
  41690. * * 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)
  41691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41694. * @param name defines the name of the mesh
  41695. * @param options defines the options used to create the mesh
  41696. * @param scene defines the hosting scene
  41697. * @returns the sphere mesh
  41698. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41699. */
  41700. static CreateSphere(name: string, options: {
  41701. segments?: number;
  41702. diameter?: number;
  41703. diameterX?: number;
  41704. diameterY?: number;
  41705. diameterZ?: number;
  41706. arc?: number;
  41707. slice?: number;
  41708. sideOrientation?: number;
  41709. frontUVs?: Vector4;
  41710. backUVs?: Vector4;
  41711. updatable?: boolean;
  41712. }, scene: any): Mesh;
  41713. }
  41714. }
  41715. declare module "babylonjs/Debug/physicsViewer" {
  41716. import { Nullable } from "babylonjs/types";
  41717. import { Scene } from "babylonjs/scene";
  41718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41719. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41720. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41721. /**
  41722. * Used to show the physics impostor around the specific mesh
  41723. */
  41724. export class PhysicsViewer {
  41725. /** @hidden */
  41726. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41727. /** @hidden */
  41728. protected _meshes: Array<Nullable<AbstractMesh>>;
  41729. /** @hidden */
  41730. protected _scene: Nullable<Scene>;
  41731. /** @hidden */
  41732. protected _numMeshes: number;
  41733. /** @hidden */
  41734. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41735. private _renderFunction;
  41736. private _utilityLayer;
  41737. private _debugBoxMesh;
  41738. private _debugSphereMesh;
  41739. private _debugMaterial;
  41740. /**
  41741. * Creates a new PhysicsViewer
  41742. * @param scene defines the hosting scene
  41743. */
  41744. constructor(scene: Scene);
  41745. /** @hidden */
  41746. protected _updateDebugMeshes(): void;
  41747. /**
  41748. * Renders a specified physic impostor
  41749. * @param impostor defines the impostor to render
  41750. * @returns the new debug mesh used to render the impostor
  41751. */
  41752. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41753. /**
  41754. * Hides a specified physic impostor
  41755. * @param impostor defines the impostor to hide
  41756. */
  41757. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41758. private _getDebugMaterial;
  41759. private _getDebugBoxMesh;
  41760. private _getDebugSphereMesh;
  41761. private _getDebugMesh;
  41762. /** Releases all resources */
  41763. dispose(): void;
  41764. }
  41765. }
  41766. declare module "babylonjs/Debug/rayHelper" {
  41767. import { Nullable } from "babylonjs/types";
  41768. import { Ray } from "babylonjs/Culling/ray";
  41769. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41770. import { Scene } from "babylonjs/scene";
  41771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41772. import "babylonjs/Meshes/Builders/linesBuilder";
  41773. /**
  41774. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41775. * in order to better appreciate the issue one might have.
  41776. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41777. */
  41778. export class RayHelper {
  41779. /**
  41780. * Defines the ray we are currently tryin to visualize.
  41781. */
  41782. ray: Nullable<Ray>;
  41783. private _renderPoints;
  41784. private _renderLine;
  41785. private _renderFunction;
  41786. private _scene;
  41787. private _updateToMeshFunction;
  41788. private _attachedToMesh;
  41789. private _meshSpaceDirection;
  41790. private _meshSpaceOrigin;
  41791. /**
  41792. * Helper function to create a colored helper in a scene in one line.
  41793. * @param ray Defines the ray we are currently tryin to visualize
  41794. * @param scene Defines the scene the ray is used in
  41795. * @param color Defines the color we want to see the ray in
  41796. * @returns The newly created ray helper.
  41797. */
  41798. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41799. /**
  41800. * Instantiate a new ray helper.
  41801. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41802. * in order to better appreciate the issue one might have.
  41803. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41804. * @param ray Defines the ray we are currently tryin to visualize
  41805. */
  41806. constructor(ray: Ray);
  41807. /**
  41808. * Shows the ray we are willing to debug.
  41809. * @param scene Defines the scene the ray needs to be rendered in
  41810. * @param color Defines the color the ray needs to be rendered in
  41811. */
  41812. show(scene: Scene, color?: Color3): void;
  41813. /**
  41814. * Hides the ray we are debugging.
  41815. */
  41816. hide(): void;
  41817. private _render;
  41818. /**
  41819. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41820. * @param mesh Defines the mesh we want the helper attached to
  41821. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41822. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41823. * @param length Defines the length of the ray
  41824. */
  41825. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41826. /**
  41827. * Detach the ray helper from the mesh it has previously been attached to.
  41828. */
  41829. detachFromMesh(): void;
  41830. private _updateToMesh;
  41831. /**
  41832. * Dispose the helper and release its associated resources.
  41833. */
  41834. dispose(): void;
  41835. }
  41836. }
  41837. declare module "babylonjs/Debug/skeletonViewer" {
  41838. import { Color3 } from "babylonjs/Maths/math";
  41839. import { Scene } from "babylonjs/scene";
  41840. import { Nullable } from "babylonjs/types";
  41841. import { Skeleton } from "babylonjs/Bones/skeleton";
  41842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41843. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41844. /**
  41845. * Class used to render a debug view of a given skeleton
  41846. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41847. */
  41848. export class SkeletonViewer {
  41849. /** defines the skeleton to render */
  41850. skeleton: Skeleton;
  41851. /** defines the mesh attached to the skeleton */
  41852. mesh: AbstractMesh;
  41853. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41854. autoUpdateBonesMatrices: boolean;
  41855. /** defines the rendering group id to use with the viewer */
  41856. renderingGroupId: number;
  41857. /** Gets or sets the color used to render the skeleton */
  41858. color: Color3;
  41859. private _scene;
  41860. private _debugLines;
  41861. private _debugMesh;
  41862. private _isEnabled;
  41863. private _renderFunction;
  41864. private _utilityLayer;
  41865. /**
  41866. * Returns the mesh used to render the bones
  41867. */
  41868. readonly debugMesh: Nullable<LinesMesh>;
  41869. /**
  41870. * Creates a new SkeletonViewer
  41871. * @param skeleton defines the skeleton to render
  41872. * @param mesh defines the mesh attached to the skeleton
  41873. * @param scene defines the hosting scene
  41874. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41875. * @param renderingGroupId defines the rendering group id to use with the viewer
  41876. */
  41877. constructor(
  41878. /** defines the skeleton to render */
  41879. skeleton: Skeleton,
  41880. /** defines the mesh attached to the skeleton */
  41881. mesh: AbstractMesh, scene: Scene,
  41882. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41883. autoUpdateBonesMatrices?: boolean,
  41884. /** defines the rendering group id to use with the viewer */
  41885. renderingGroupId?: number);
  41886. /** Gets or sets a boolean indicating if the viewer is enabled */
  41887. isEnabled: boolean;
  41888. private _getBonePosition;
  41889. private _getLinesForBonesWithLength;
  41890. private _getLinesForBonesNoLength;
  41891. /** Update the viewer to sync with current skeleton state */
  41892. update(): void;
  41893. /** Release associated resources */
  41894. dispose(): void;
  41895. }
  41896. }
  41897. declare module "babylonjs/Debug/index" {
  41898. export * from "babylonjs/Debug/axesViewer";
  41899. export * from "babylonjs/Debug/boneAxesViewer";
  41900. export * from "babylonjs/Debug/debugLayer";
  41901. export * from "babylonjs/Debug/physicsViewer";
  41902. export * from "babylonjs/Debug/rayHelper";
  41903. export * from "babylonjs/Debug/skeletonViewer";
  41904. }
  41905. declare module "babylonjs/Engines/nullEngine" {
  41906. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41907. import { Scene } from "babylonjs/scene";
  41908. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41909. import { Engine } from "babylonjs/Engines/engine";
  41910. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41911. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41912. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41913. import { Effect } from "babylonjs/Materials/effect";
  41914. /**
  41915. * Options to create the null engine
  41916. */
  41917. export class NullEngineOptions {
  41918. /**
  41919. * Render width (Default: 512)
  41920. */
  41921. renderWidth: number;
  41922. /**
  41923. * Render height (Default: 256)
  41924. */
  41925. renderHeight: number;
  41926. /**
  41927. * Texture size (Default: 512)
  41928. */
  41929. textureSize: number;
  41930. /**
  41931. * If delta time between frames should be constant
  41932. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41933. */
  41934. deterministicLockstep: boolean;
  41935. /**
  41936. * Maximum about of steps between frames (Default: 4)
  41937. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41938. */
  41939. lockstepMaxSteps: number;
  41940. }
  41941. /**
  41942. * The null engine class provides support for headless version of babylon.js.
  41943. * This can be used in server side scenario or for testing purposes
  41944. */
  41945. export class NullEngine extends Engine {
  41946. private _options;
  41947. /**
  41948. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41949. */
  41950. isDeterministicLockStep(): boolean;
  41951. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41952. getLockstepMaxSteps(): number;
  41953. /**
  41954. * Sets hardware scaling, used to save performance if needed
  41955. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41956. */
  41957. getHardwareScalingLevel(): number;
  41958. constructor(options?: NullEngineOptions);
  41959. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41960. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41961. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41962. getRenderWidth(useScreen?: boolean): number;
  41963. getRenderHeight(useScreen?: boolean): number;
  41964. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41965. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41966. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41967. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41968. bindSamplers(effect: Effect): void;
  41969. enableEffect(effect: Effect): void;
  41970. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41971. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41972. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41973. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41974. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41975. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41976. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41977. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41978. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41979. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41980. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41981. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41982. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41983. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41984. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41985. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41986. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41987. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41988. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41989. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41990. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41991. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41992. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41993. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41994. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41995. bindBuffers(vertexBuffers: {
  41996. [key: string]: VertexBuffer;
  41997. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41998. wipeCaches(bruteForce?: boolean): void;
  41999. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42000. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42001. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42002. /** @hidden */
  42003. _createTexture(): WebGLTexture;
  42004. /** @hidden */
  42005. _releaseTexture(texture: InternalTexture): void;
  42006. 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;
  42007. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42008. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42009. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42010. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42011. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42012. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42013. areAllEffectsReady(): boolean;
  42014. /**
  42015. * @hidden
  42016. * Get the current error code of the webGL context
  42017. * @returns the error code
  42018. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42019. */
  42020. getError(): number;
  42021. /** @hidden */
  42022. _getUnpackAlignement(): number;
  42023. /** @hidden */
  42024. _unpackFlipY(value: boolean): void;
  42025. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42026. /**
  42027. * Updates a dynamic vertex buffer.
  42028. * @param vertexBuffer the vertex buffer to update
  42029. * @param data the data used to update the vertex buffer
  42030. * @param byteOffset the byte offset of the data (optional)
  42031. * @param byteLength the byte length of the data (optional)
  42032. */
  42033. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42034. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42035. /** @hidden */
  42036. _bindTexture(channel: number, texture: InternalTexture): void;
  42037. /** @hidden */
  42038. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42039. releaseEffects(): void;
  42040. displayLoadingUI(): void;
  42041. hideLoadingUI(): void;
  42042. /** @hidden */
  42043. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42044. /** @hidden */
  42045. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42046. /** @hidden */
  42047. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42048. /** @hidden */
  42049. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42050. }
  42051. }
  42052. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42053. import { Nullable, int } from "babylonjs/types";
  42054. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42055. /** @hidden */
  42056. export class _OcclusionDataStorage {
  42057. /** @hidden */
  42058. occlusionInternalRetryCounter: number;
  42059. /** @hidden */
  42060. isOcclusionQueryInProgress: boolean;
  42061. /** @hidden */
  42062. isOccluded: boolean;
  42063. /** @hidden */
  42064. occlusionRetryCount: number;
  42065. /** @hidden */
  42066. occlusionType: number;
  42067. /** @hidden */
  42068. occlusionQueryAlgorithmType: number;
  42069. }
  42070. module "babylonjs/Engines/engine" {
  42071. interface Engine {
  42072. /**
  42073. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42074. * @return the new query
  42075. */
  42076. createQuery(): WebGLQuery;
  42077. /**
  42078. * Delete and release a webGL query
  42079. * @param query defines the query to delete
  42080. * @return the current engine
  42081. */
  42082. deleteQuery(query: WebGLQuery): Engine;
  42083. /**
  42084. * Check if a given query has resolved and got its value
  42085. * @param query defines the query to check
  42086. * @returns true if the query got its value
  42087. */
  42088. isQueryResultAvailable(query: WebGLQuery): boolean;
  42089. /**
  42090. * Gets the value of a given query
  42091. * @param query defines the query to check
  42092. * @returns the value of the query
  42093. */
  42094. getQueryResult(query: WebGLQuery): number;
  42095. /**
  42096. * Initiates an occlusion query
  42097. * @param algorithmType defines the algorithm to use
  42098. * @param query defines the query to use
  42099. * @returns the current engine
  42100. * @see http://doc.babylonjs.com/features/occlusionquery
  42101. */
  42102. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42103. /**
  42104. * Ends an occlusion query
  42105. * @see http://doc.babylonjs.com/features/occlusionquery
  42106. * @param algorithmType defines the algorithm to use
  42107. * @returns the current engine
  42108. */
  42109. endOcclusionQuery(algorithmType: number): Engine;
  42110. /**
  42111. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42112. * Please note that only one query can be issued at a time
  42113. * @returns a time token used to track the time span
  42114. */
  42115. startTimeQuery(): Nullable<_TimeToken>;
  42116. /**
  42117. * Ends a time query
  42118. * @param token defines the token used to measure the time span
  42119. * @returns the time spent (in ns)
  42120. */
  42121. endTimeQuery(token: _TimeToken): int;
  42122. /** @hidden */
  42123. _currentNonTimestampToken: Nullable<_TimeToken>;
  42124. /** @hidden */
  42125. _createTimeQuery(): WebGLQuery;
  42126. /** @hidden */
  42127. _deleteTimeQuery(query: WebGLQuery): void;
  42128. /** @hidden */
  42129. _getGlAlgorithmType(algorithmType: number): number;
  42130. /** @hidden */
  42131. _getTimeQueryResult(query: WebGLQuery): any;
  42132. /** @hidden */
  42133. _getTimeQueryAvailability(query: WebGLQuery): any;
  42134. }
  42135. }
  42136. module "babylonjs/Meshes/abstractMesh" {
  42137. interface AbstractMesh {
  42138. /**
  42139. * Backing filed
  42140. * @hidden
  42141. */
  42142. __occlusionDataStorage: _OcclusionDataStorage;
  42143. /**
  42144. * Access property
  42145. * @hidden
  42146. */
  42147. _occlusionDataStorage: _OcclusionDataStorage;
  42148. /**
  42149. * 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.
  42150. * The default value is -1 which means don't break the query and wait till the result
  42151. * @see http://doc.babylonjs.com/features/occlusionquery
  42152. */
  42153. occlusionRetryCount: number;
  42154. /**
  42155. * 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:
  42156. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42157. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42158. * * 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.
  42159. * @see http://doc.babylonjs.com/features/occlusionquery
  42160. */
  42161. occlusionType: number;
  42162. /**
  42163. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42164. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42165. * * 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.
  42166. * @see http://doc.babylonjs.com/features/occlusionquery
  42167. */
  42168. occlusionQueryAlgorithmType: number;
  42169. /**
  42170. * 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
  42171. * @see http://doc.babylonjs.com/features/occlusionquery
  42172. */
  42173. isOccluded: boolean;
  42174. /**
  42175. * Flag to check the progress status of the query
  42176. * @see http://doc.babylonjs.com/features/occlusionquery
  42177. */
  42178. isOcclusionQueryInProgress: boolean;
  42179. }
  42180. }
  42181. }
  42182. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42183. import { Nullable } from "babylonjs/types";
  42184. /** @hidden */
  42185. export var _forceTransformFeedbackToBundle: boolean;
  42186. module "babylonjs/Engines/engine" {
  42187. interface Engine {
  42188. /**
  42189. * Creates a webGL transform feedback object
  42190. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42191. * @returns the webGL transform feedback object
  42192. */
  42193. createTransformFeedback(): WebGLTransformFeedback;
  42194. /**
  42195. * Delete a webGL transform feedback object
  42196. * @param value defines the webGL transform feedback object to delete
  42197. */
  42198. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42199. /**
  42200. * Bind a webGL transform feedback object to the webgl context
  42201. * @param value defines the webGL transform feedback object to bind
  42202. */
  42203. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42204. /**
  42205. * Begins a transform feedback operation
  42206. * @param usePoints defines if points or triangles must be used
  42207. */
  42208. beginTransformFeedback(usePoints: boolean): void;
  42209. /**
  42210. * Ends a transform feedback operation
  42211. */
  42212. endTransformFeedback(): void;
  42213. /**
  42214. * Specify the varyings to use with transform feedback
  42215. * @param program defines the associated webGL program
  42216. * @param value defines the list of strings representing the varying names
  42217. */
  42218. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42219. /**
  42220. * Bind a webGL buffer for a transform feedback operation
  42221. * @param value defines the webGL buffer to bind
  42222. */
  42223. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42224. }
  42225. }
  42226. }
  42227. declare module "babylonjs/Engines/Extensions/index" {
  42228. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42229. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42230. }
  42231. declare module "babylonjs/Engines/index" {
  42232. export * from "babylonjs/Engines/constants";
  42233. export * from "babylonjs/Engines/engine";
  42234. export * from "babylonjs/Engines/engineStore";
  42235. export * from "babylonjs/Engines/nullEngine";
  42236. export * from "babylonjs/Engines/Extensions/index";
  42237. }
  42238. declare module "babylonjs/Events/clipboardEvents" {
  42239. /**
  42240. * Gather the list of clipboard event types as constants.
  42241. */
  42242. export class ClipboardEventTypes {
  42243. /**
  42244. * The clipboard event is fired when a copy command is active (pressed).
  42245. */
  42246. static readonly COPY: number;
  42247. /**
  42248. * The clipboard event is fired when a cut command is active (pressed).
  42249. */
  42250. static readonly CUT: number;
  42251. /**
  42252. * The clipboard event is fired when a paste command is active (pressed).
  42253. */
  42254. static readonly PASTE: number;
  42255. }
  42256. /**
  42257. * This class is used to store clipboard related info for the onClipboardObservable event.
  42258. */
  42259. export class ClipboardInfo {
  42260. /**
  42261. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42262. */
  42263. type: number;
  42264. /**
  42265. * Defines the related dom event
  42266. */
  42267. event: ClipboardEvent;
  42268. /**
  42269. *Creates an instance of ClipboardInfo.
  42270. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42271. * @param event Defines the related dom event
  42272. */
  42273. constructor(
  42274. /**
  42275. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42276. */
  42277. type: number,
  42278. /**
  42279. * Defines the related dom event
  42280. */
  42281. event: ClipboardEvent);
  42282. /**
  42283. * Get the clipboard event's type from the keycode.
  42284. * @param keyCode Defines the keyCode for the current keyboard event.
  42285. * @return {number}
  42286. */
  42287. static GetTypeFromCharacter(keyCode: number): number;
  42288. }
  42289. }
  42290. declare module "babylonjs/Events/index" {
  42291. export * from "babylonjs/Events/keyboardEvents";
  42292. export * from "babylonjs/Events/pointerEvents";
  42293. export * from "babylonjs/Events/clipboardEvents";
  42294. }
  42295. declare module "babylonjs/Loading/sceneLoader" {
  42296. import { Observable } from "babylonjs/Misc/observable";
  42297. import { Nullable } from "babylonjs/types";
  42298. import { Scene } from "babylonjs/scene";
  42299. import { Engine } from "babylonjs/Engines/engine";
  42300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42301. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42302. import { AssetContainer } from "babylonjs/assetContainer";
  42303. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42304. import { Skeleton } from "babylonjs/Bones/skeleton";
  42305. /**
  42306. * Class used to represent data loading progression
  42307. */
  42308. export class SceneLoaderProgressEvent {
  42309. /** defines if data length to load can be evaluated */
  42310. readonly lengthComputable: boolean;
  42311. /** defines the loaded data length */
  42312. readonly loaded: number;
  42313. /** defines the data length to load */
  42314. readonly total: number;
  42315. /**
  42316. * Create a new progress event
  42317. * @param lengthComputable defines if data length to load can be evaluated
  42318. * @param loaded defines the loaded data length
  42319. * @param total defines the data length to load
  42320. */
  42321. constructor(
  42322. /** defines if data length to load can be evaluated */
  42323. lengthComputable: boolean,
  42324. /** defines the loaded data length */
  42325. loaded: number,
  42326. /** defines the data length to load */
  42327. total: number);
  42328. /**
  42329. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42330. * @param event defines the source event
  42331. * @returns a new SceneLoaderProgressEvent
  42332. */
  42333. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42334. }
  42335. /**
  42336. * Interface used by SceneLoader plugins to define supported file extensions
  42337. */
  42338. export interface ISceneLoaderPluginExtensions {
  42339. /**
  42340. * Defines the list of supported extensions
  42341. */
  42342. [extension: string]: {
  42343. isBinary: boolean;
  42344. };
  42345. }
  42346. /**
  42347. * Interface used by SceneLoader plugin factory
  42348. */
  42349. export interface ISceneLoaderPluginFactory {
  42350. /**
  42351. * Defines the name of the factory
  42352. */
  42353. name: string;
  42354. /**
  42355. * Function called to create a new plugin
  42356. * @return the new plugin
  42357. */
  42358. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42359. /**
  42360. * Boolean indicating if the plugin can direct load specific data
  42361. */
  42362. canDirectLoad?: (data: string) => boolean;
  42363. }
  42364. /**
  42365. * Interface used to define a SceneLoader plugin
  42366. */
  42367. export interface ISceneLoaderPlugin {
  42368. /**
  42369. * The friendly name of this plugin.
  42370. */
  42371. name: string;
  42372. /**
  42373. * The file extensions supported by this plugin.
  42374. */
  42375. extensions: string | ISceneLoaderPluginExtensions;
  42376. /**
  42377. * Import meshes into a scene.
  42378. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42379. * @param scene The scene to import into
  42380. * @param data The data to import
  42381. * @param rootUrl The root url for scene and resources
  42382. * @param meshes The meshes array to import into
  42383. * @param particleSystems The particle systems array to import into
  42384. * @param skeletons The skeletons array to import into
  42385. * @param onError The callback when import fails
  42386. * @returns True if successful or false otherwise
  42387. */
  42388. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42389. /**
  42390. * Load into a scene.
  42391. * @param scene The scene to load into
  42392. * @param data The data to import
  42393. * @param rootUrl The root url for scene and resources
  42394. * @param onError The callback when import fails
  42395. * @returns true if successful or false otherwise
  42396. */
  42397. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42398. /**
  42399. * The callback that returns true if the data can be directly loaded.
  42400. */
  42401. canDirectLoad?: (data: string) => boolean;
  42402. /**
  42403. * The callback that allows custom handling of the root url based on the response url.
  42404. */
  42405. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42406. /**
  42407. * Load into an asset container.
  42408. * @param scene The scene to load into
  42409. * @param data The data to import
  42410. * @param rootUrl The root url for scene and resources
  42411. * @param onError The callback when import fails
  42412. * @returns The loaded asset container
  42413. */
  42414. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42415. }
  42416. /**
  42417. * Interface used to define an async SceneLoader plugin
  42418. */
  42419. export interface ISceneLoaderPluginAsync {
  42420. /**
  42421. * The friendly name of this plugin.
  42422. */
  42423. name: string;
  42424. /**
  42425. * The file extensions supported by this plugin.
  42426. */
  42427. extensions: string | ISceneLoaderPluginExtensions;
  42428. /**
  42429. * Import meshes into a scene.
  42430. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42431. * @param scene The scene to import into
  42432. * @param data The data to import
  42433. * @param rootUrl The root url for scene and resources
  42434. * @param onProgress The callback when the load progresses
  42435. * @param fileName Defines the name of the file to load
  42436. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42437. */
  42438. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42439. meshes: AbstractMesh[];
  42440. particleSystems: IParticleSystem[];
  42441. skeletons: Skeleton[];
  42442. animationGroups: AnimationGroup[];
  42443. }>;
  42444. /**
  42445. * Load into a scene.
  42446. * @param scene The scene to load into
  42447. * @param data The data to import
  42448. * @param rootUrl The root url for scene and resources
  42449. * @param onProgress The callback when the load progresses
  42450. * @param fileName Defines the name of the file to load
  42451. * @returns Nothing
  42452. */
  42453. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42454. /**
  42455. * The callback that returns true if the data can be directly loaded.
  42456. */
  42457. canDirectLoad?: (data: string) => boolean;
  42458. /**
  42459. * The callback that allows custom handling of the root url based on the response url.
  42460. */
  42461. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42462. /**
  42463. * Load into an asset container.
  42464. * @param scene The scene to load into
  42465. * @param data The data to import
  42466. * @param rootUrl The root url for scene and resources
  42467. * @param onProgress The callback when the load progresses
  42468. * @param fileName Defines the name of the file to load
  42469. * @returns The loaded asset container
  42470. */
  42471. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42472. }
  42473. /**
  42474. * Class used to load scene from various file formats using registered plugins
  42475. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42476. */
  42477. export class SceneLoader {
  42478. /**
  42479. * No logging while loading
  42480. */
  42481. static readonly NO_LOGGING: number;
  42482. /**
  42483. * Minimal logging while loading
  42484. */
  42485. static readonly MINIMAL_LOGGING: number;
  42486. /**
  42487. * Summary logging while loading
  42488. */
  42489. static readonly SUMMARY_LOGGING: number;
  42490. /**
  42491. * Detailled logging while loading
  42492. */
  42493. static readonly DETAILED_LOGGING: number;
  42494. /**
  42495. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42496. */
  42497. static ForceFullSceneLoadingForIncremental: boolean;
  42498. /**
  42499. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42500. */
  42501. static ShowLoadingScreen: boolean;
  42502. /**
  42503. * Defines the current logging level (while loading the scene)
  42504. * @ignorenaming
  42505. */
  42506. static loggingLevel: number;
  42507. /**
  42508. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42509. */
  42510. static CleanBoneMatrixWeights: boolean;
  42511. /**
  42512. * Event raised when a plugin is used to load a scene
  42513. */
  42514. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42515. private static _registeredPlugins;
  42516. private static _getDefaultPlugin;
  42517. private static _getPluginForExtension;
  42518. private static _getPluginForDirectLoad;
  42519. private static _getPluginForFilename;
  42520. private static _getDirectLoad;
  42521. private static _loadData;
  42522. private static _getFileInfo;
  42523. /**
  42524. * Gets a plugin that can load the given extension
  42525. * @param extension defines the extension to load
  42526. * @returns a plugin or null if none works
  42527. */
  42528. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42529. /**
  42530. * Gets a boolean indicating that the given extension can be loaded
  42531. * @param extension defines the extension to load
  42532. * @returns true if the extension is supported
  42533. */
  42534. static IsPluginForExtensionAvailable(extension: string): boolean;
  42535. /**
  42536. * Adds a new plugin to the list of registered plugins
  42537. * @param plugin defines the plugin to add
  42538. */
  42539. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42540. /**
  42541. * Import meshes into a scene
  42542. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42543. * @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)
  42544. * @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)
  42545. * @param scene the instance of BABYLON.Scene to append to
  42546. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42547. * @param onProgress a callback with a progress event for each file being loaded
  42548. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42549. * @param pluginExtension the extension used to determine the plugin
  42550. * @returns The loaded plugin
  42551. */
  42552. 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>;
  42553. /**
  42554. * Import meshes into a scene
  42555. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42556. * @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)
  42557. * @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)
  42558. * @param scene the instance of BABYLON.Scene to append to
  42559. * @param onProgress a callback with a progress event for each file being loaded
  42560. * @param pluginExtension the extension used to determine the plugin
  42561. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42562. */
  42563. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42564. meshes: AbstractMesh[];
  42565. particleSystems: IParticleSystem[];
  42566. skeletons: Skeleton[];
  42567. animationGroups: AnimationGroup[];
  42568. }>;
  42569. /**
  42570. * Load a scene
  42571. * @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)
  42572. * @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)
  42573. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42574. * @param onSuccess a callback with the scene when import succeeds
  42575. * @param onProgress a callback with a progress event for each file being loaded
  42576. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42577. * @param pluginExtension the extension used to determine the plugin
  42578. * @returns The loaded plugin
  42579. */
  42580. 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>;
  42581. /**
  42582. * Load a scene
  42583. * @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)
  42584. * @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)
  42585. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42586. * @param onProgress a callback with a progress event for each file being loaded
  42587. * @param pluginExtension the extension used to determine the plugin
  42588. * @returns The loaded scene
  42589. */
  42590. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42591. /**
  42592. * Append a scene
  42593. * @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)
  42594. * @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)
  42595. * @param scene is the instance of BABYLON.Scene to append to
  42596. * @param onSuccess a callback with the scene when import succeeds
  42597. * @param onProgress a callback with a progress event for each file being loaded
  42598. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42599. * @param pluginExtension the extension used to determine the plugin
  42600. * @returns The loaded plugin
  42601. */
  42602. 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>;
  42603. /**
  42604. * Append a scene
  42605. * @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)
  42606. * @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)
  42607. * @param scene is the instance of BABYLON.Scene to append to
  42608. * @param onProgress a callback with a progress event for each file being loaded
  42609. * @param pluginExtension the extension used to determine the plugin
  42610. * @returns The given scene
  42611. */
  42612. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42613. /**
  42614. * Load a scene into an asset container
  42615. * @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)
  42616. * @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)
  42617. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42618. * @param onSuccess a callback with the scene when import succeeds
  42619. * @param onProgress a callback with a progress event for each file being loaded
  42620. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42621. * @param pluginExtension the extension used to determine the plugin
  42622. * @returns The loaded plugin
  42623. */
  42624. 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>;
  42625. /**
  42626. * Load a scene into an asset container
  42627. * @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)
  42628. * @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)
  42629. * @param scene is the instance of Scene to append to
  42630. * @param onProgress a callback with a progress event for each file being loaded
  42631. * @param pluginExtension the extension used to determine the plugin
  42632. * @returns The loaded asset container
  42633. */
  42634. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42635. }
  42636. }
  42637. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42638. import { Scene } from "babylonjs/scene";
  42639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42640. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42641. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42642. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42643. /**
  42644. * Google Daydream controller
  42645. */
  42646. export class DaydreamController extends WebVRController {
  42647. /**
  42648. * Base Url for the controller model.
  42649. */
  42650. static MODEL_BASE_URL: string;
  42651. /**
  42652. * File name for the controller model.
  42653. */
  42654. static MODEL_FILENAME: string;
  42655. /**
  42656. * Gamepad Id prefix used to identify Daydream Controller.
  42657. */
  42658. static readonly GAMEPAD_ID_PREFIX: string;
  42659. /**
  42660. * Creates a new DaydreamController from a gamepad
  42661. * @param vrGamepad the gamepad that the controller should be created from
  42662. */
  42663. constructor(vrGamepad: any);
  42664. /**
  42665. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42666. * @param scene scene in which to add meshes
  42667. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42668. */
  42669. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42670. /**
  42671. * Called once for each button that changed state since the last frame
  42672. * @param buttonIdx Which button index changed
  42673. * @param state New state of the button
  42674. * @param changes Which properties on the state changed since last frame
  42675. */
  42676. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42677. }
  42678. }
  42679. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42680. import { Scene } from "babylonjs/scene";
  42681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42682. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42683. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42684. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42685. /**
  42686. * Gear VR Controller
  42687. */
  42688. export class GearVRController extends WebVRController {
  42689. /**
  42690. * Base Url for the controller model.
  42691. */
  42692. static MODEL_BASE_URL: string;
  42693. /**
  42694. * File name for the controller model.
  42695. */
  42696. static MODEL_FILENAME: string;
  42697. /**
  42698. * Gamepad Id prefix used to identify this controller.
  42699. */
  42700. static readonly GAMEPAD_ID_PREFIX: string;
  42701. private readonly _buttonIndexToObservableNameMap;
  42702. /**
  42703. * Creates a new GearVRController from a gamepad
  42704. * @param vrGamepad the gamepad that the controller should be created from
  42705. */
  42706. constructor(vrGamepad: any);
  42707. /**
  42708. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42709. * @param scene scene in which to add meshes
  42710. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42711. */
  42712. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42713. /**
  42714. * Called once for each button that changed state since the last frame
  42715. * @param buttonIdx Which button index changed
  42716. * @param state New state of the button
  42717. * @param changes Which properties on the state changed since last frame
  42718. */
  42719. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42720. }
  42721. }
  42722. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42723. import { Scene } from "babylonjs/scene";
  42724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42725. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42726. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42727. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42728. /**
  42729. * Generic Controller
  42730. */
  42731. export class GenericController extends WebVRController {
  42732. /**
  42733. * Base Url for the controller model.
  42734. */
  42735. static readonly MODEL_BASE_URL: string;
  42736. /**
  42737. * File name for the controller model.
  42738. */
  42739. static readonly MODEL_FILENAME: string;
  42740. /**
  42741. * Creates a new GenericController from a gamepad
  42742. * @param vrGamepad the gamepad that the controller should be created from
  42743. */
  42744. constructor(vrGamepad: any);
  42745. /**
  42746. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42747. * @param scene scene in which to add meshes
  42748. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42749. */
  42750. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42751. /**
  42752. * Called once for each button that changed state since the last frame
  42753. * @param buttonIdx Which button index changed
  42754. * @param state New state of the button
  42755. * @param changes Which properties on the state changed since last frame
  42756. */
  42757. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42758. }
  42759. }
  42760. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42761. import { Observable } from "babylonjs/Misc/observable";
  42762. import { Scene } from "babylonjs/scene";
  42763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42764. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42765. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42766. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42767. /**
  42768. * Oculus Touch Controller
  42769. */
  42770. export class OculusTouchController extends WebVRController {
  42771. /**
  42772. * Base Url for the controller model.
  42773. */
  42774. static MODEL_BASE_URL: string;
  42775. /**
  42776. * File name for the left controller model.
  42777. */
  42778. static MODEL_LEFT_FILENAME: string;
  42779. /**
  42780. * File name for the right controller model.
  42781. */
  42782. static MODEL_RIGHT_FILENAME: string;
  42783. /**
  42784. * Fired when the secondary trigger on this controller is modified
  42785. */
  42786. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42787. /**
  42788. * Fired when the thumb rest on this controller is modified
  42789. */
  42790. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42791. /**
  42792. * Creates a new OculusTouchController from a gamepad
  42793. * @param vrGamepad the gamepad that the controller should be created from
  42794. */
  42795. constructor(vrGamepad: any);
  42796. /**
  42797. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42798. * @param scene scene in which to add meshes
  42799. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42800. */
  42801. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42802. /**
  42803. * Fired when the A button on this controller is modified
  42804. */
  42805. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42806. /**
  42807. * Fired when the B button on this controller is modified
  42808. */
  42809. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42810. /**
  42811. * Fired when the X button on this controller is modified
  42812. */
  42813. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42814. /**
  42815. * Fired when the Y button on this controller is modified
  42816. */
  42817. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42818. /**
  42819. * Called once for each button that changed state since the last frame
  42820. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42821. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42822. * 2) secondary trigger (same)
  42823. * 3) A (right) X (left), touch, pressed = value
  42824. * 4) B / Y
  42825. * 5) thumb rest
  42826. * @param buttonIdx Which button index changed
  42827. * @param state New state of the button
  42828. * @param changes Which properties on the state changed since last frame
  42829. */
  42830. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42831. }
  42832. }
  42833. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42834. import { Scene } from "babylonjs/scene";
  42835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42836. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42837. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42838. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42839. import { Observable } from "babylonjs/Misc/observable";
  42840. /**
  42841. * Vive Controller
  42842. */
  42843. export class ViveController extends WebVRController {
  42844. /**
  42845. * Base Url for the controller model.
  42846. */
  42847. static MODEL_BASE_URL: string;
  42848. /**
  42849. * File name for the controller model.
  42850. */
  42851. static MODEL_FILENAME: string;
  42852. /**
  42853. * Creates a new ViveController from a gamepad
  42854. * @param vrGamepad the gamepad that the controller should be created from
  42855. */
  42856. constructor(vrGamepad: any);
  42857. /**
  42858. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42859. * @param scene scene in which to add meshes
  42860. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42861. */
  42862. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42863. /**
  42864. * Fired when the left button on this controller is modified
  42865. */
  42866. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42867. /**
  42868. * Fired when the right button on this controller is modified
  42869. */
  42870. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42871. /**
  42872. * Fired when the menu button on this controller is modified
  42873. */
  42874. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42875. /**
  42876. * Called once for each button that changed state since the last frame
  42877. * Vive mapping:
  42878. * 0: touchpad
  42879. * 1: trigger
  42880. * 2: left AND right buttons
  42881. * 3: menu button
  42882. * @param buttonIdx Which button index changed
  42883. * @param state New state of the button
  42884. * @param changes Which properties on the state changed since last frame
  42885. */
  42886. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42887. }
  42888. }
  42889. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42890. import { Observable } from "babylonjs/Misc/observable";
  42891. import { Scene } from "babylonjs/scene";
  42892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42893. import { Ray } from "babylonjs/Culling/ray";
  42894. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42895. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42896. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42897. /**
  42898. * Defines the WindowsMotionController object that the state of the windows motion controller
  42899. */
  42900. export class WindowsMotionController extends WebVRController {
  42901. /**
  42902. * The base url used to load the left and right controller models
  42903. */
  42904. static MODEL_BASE_URL: string;
  42905. /**
  42906. * The name of the left controller model file
  42907. */
  42908. static MODEL_LEFT_FILENAME: string;
  42909. /**
  42910. * The name of the right controller model file
  42911. */
  42912. static MODEL_RIGHT_FILENAME: string;
  42913. /**
  42914. * The controller name prefix for this controller type
  42915. */
  42916. static readonly GAMEPAD_ID_PREFIX: string;
  42917. /**
  42918. * The controller id pattern for this controller type
  42919. */
  42920. private static readonly GAMEPAD_ID_PATTERN;
  42921. private _loadedMeshInfo;
  42922. private readonly _mapping;
  42923. /**
  42924. * Fired when the trackpad on this controller is clicked
  42925. */
  42926. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42927. /**
  42928. * Fired when the trackpad on this controller is modified
  42929. */
  42930. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42931. /**
  42932. * The current x and y values of this controller's trackpad
  42933. */
  42934. trackpad: StickValues;
  42935. /**
  42936. * Creates a new WindowsMotionController from a gamepad
  42937. * @param vrGamepad the gamepad that the controller should be created from
  42938. */
  42939. constructor(vrGamepad: any);
  42940. /**
  42941. * Fired when the trigger on this controller is modified
  42942. */
  42943. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42944. /**
  42945. * Fired when the menu button on this controller is modified
  42946. */
  42947. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42948. /**
  42949. * Fired when the grip button on this controller is modified
  42950. */
  42951. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42952. /**
  42953. * Fired when the thumbstick button on this controller is modified
  42954. */
  42955. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42956. /**
  42957. * Fired when the touchpad button on this controller is modified
  42958. */
  42959. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42960. /**
  42961. * Fired when the touchpad values on this controller are modified
  42962. */
  42963. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42964. private _updateTrackpad;
  42965. /**
  42966. * Called once per frame by the engine.
  42967. */
  42968. update(): void;
  42969. /**
  42970. * Called once for each button that changed state since the last frame
  42971. * @param buttonIdx Which button index changed
  42972. * @param state New state of the button
  42973. * @param changes Which properties on the state changed since last frame
  42974. */
  42975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42976. /**
  42977. * Moves the buttons on the controller mesh based on their current state
  42978. * @param buttonName the name of the button to move
  42979. * @param buttonValue the value of the button which determines the buttons new position
  42980. */
  42981. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42982. /**
  42983. * Moves the axis on the controller mesh based on its current state
  42984. * @param axis the index of the axis
  42985. * @param axisValue the value of the axis which determines the meshes new position
  42986. * @hidden
  42987. */
  42988. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42989. /**
  42990. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42991. * @param scene scene in which to add meshes
  42992. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42993. */
  42994. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42995. /**
  42996. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42997. * can be transformed by button presses and axes values, based on this._mapping.
  42998. *
  42999. * @param scene scene in which the meshes exist
  43000. * @param meshes list of meshes that make up the controller model to process
  43001. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43002. */
  43003. private processModel;
  43004. private createMeshInfo;
  43005. /**
  43006. * Gets the ray of the controller in the direction the controller is pointing
  43007. * @param length the length the resulting ray should be
  43008. * @returns a ray in the direction the controller is pointing
  43009. */
  43010. getForwardRay(length?: number): Ray;
  43011. /**
  43012. * Disposes of the controller
  43013. */
  43014. dispose(): void;
  43015. }
  43016. }
  43017. declare module "babylonjs/Gamepads/Controllers/index" {
  43018. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43019. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43020. export * from "babylonjs/Gamepads/Controllers/genericController";
  43021. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43022. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43023. export * from "babylonjs/Gamepads/Controllers/viveController";
  43024. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43025. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43026. }
  43027. declare module "babylonjs/Gamepads/index" {
  43028. export * from "babylonjs/Gamepads/Controllers/index";
  43029. export * from "babylonjs/Gamepads/gamepad";
  43030. export * from "babylonjs/Gamepads/gamepadManager";
  43031. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43032. export * from "babylonjs/Gamepads/xboxGamepad";
  43033. }
  43034. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43035. import { Observable } from "babylonjs/Misc/observable";
  43036. import { Nullable } from "babylonjs/types";
  43037. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43039. import { Mesh } from "babylonjs/Meshes/mesh";
  43040. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43041. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43042. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43043. /**
  43044. * Single axis scale gizmo
  43045. */
  43046. export class AxisScaleGizmo extends Gizmo {
  43047. private _coloredMaterial;
  43048. /**
  43049. * Drag behavior responsible for the gizmos dragging interactions
  43050. */
  43051. dragBehavior: PointerDragBehavior;
  43052. private _pointerObserver;
  43053. /**
  43054. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43055. */
  43056. snapDistance: number;
  43057. /**
  43058. * Event that fires each time the gizmo snaps to a new location.
  43059. * * snapDistance is the the change in distance
  43060. */
  43061. onSnapObservable: Observable<{
  43062. snapDistance: number;
  43063. }>;
  43064. /**
  43065. * If the scaling operation should be done on all axis (default: false)
  43066. */
  43067. uniformScaling: boolean;
  43068. /**
  43069. * Creates an AxisScaleGizmo
  43070. * @param gizmoLayer The utility layer the gizmo will be added to
  43071. * @param dragAxis The axis which the gizmo will be able to scale on
  43072. * @param color The color of the gizmo
  43073. */
  43074. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43075. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43076. /**
  43077. * Disposes of the gizmo
  43078. */
  43079. dispose(): void;
  43080. /**
  43081. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43082. * @param mesh The mesh to replace the default mesh of the gizmo
  43083. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43084. */
  43085. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43086. }
  43087. }
  43088. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43089. import { Observable } from "babylonjs/Misc/observable";
  43090. import { Nullable } from "babylonjs/types";
  43091. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43093. import { Mesh } from "babylonjs/Meshes/mesh";
  43094. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43095. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43096. import "babylonjs/Meshes/Builders/boxBuilder";
  43097. /**
  43098. * Bounding box gizmo
  43099. */
  43100. export class BoundingBoxGizmo extends Gizmo {
  43101. private _lineBoundingBox;
  43102. private _rotateSpheresParent;
  43103. private _scaleBoxesParent;
  43104. private _boundingDimensions;
  43105. private _renderObserver;
  43106. private _pointerObserver;
  43107. private _scaleDragSpeed;
  43108. private _tmpQuaternion;
  43109. private _tmpVector;
  43110. private _tmpRotationMatrix;
  43111. /**
  43112. * 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)
  43113. */
  43114. ignoreChildren: boolean;
  43115. /**
  43116. * 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)
  43117. */
  43118. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43119. /**
  43120. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43121. */
  43122. rotationSphereSize: number;
  43123. /**
  43124. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43125. */
  43126. scaleBoxSize: number;
  43127. /**
  43128. * 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)
  43129. */
  43130. fixedDragMeshScreenSize: boolean;
  43131. /**
  43132. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43133. */
  43134. fixedDragMeshScreenSizeDistanceFactor: number;
  43135. /**
  43136. * Fired when a rotation sphere or scale box is dragged
  43137. */
  43138. onDragStartObservable: Observable<{}>;
  43139. /**
  43140. * Fired when a scale box is dragged
  43141. */
  43142. onScaleBoxDragObservable: Observable<{}>;
  43143. /**
  43144. * Fired when a scale box drag is ended
  43145. */
  43146. onScaleBoxDragEndObservable: Observable<{}>;
  43147. /**
  43148. * Fired when a rotation sphere is dragged
  43149. */
  43150. onRotationSphereDragObservable: Observable<{}>;
  43151. /**
  43152. * Fired when a rotation sphere drag is ended
  43153. */
  43154. onRotationSphereDragEndObservable: Observable<{}>;
  43155. /**
  43156. * 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)
  43157. */
  43158. scalePivot: Nullable<Vector3>;
  43159. private _anchorMesh;
  43160. private _existingMeshScale;
  43161. private _dragMesh;
  43162. private pointerDragBehavior;
  43163. private coloredMaterial;
  43164. private hoverColoredMaterial;
  43165. /**
  43166. * Sets the color of the bounding box gizmo
  43167. * @param color the color to set
  43168. */
  43169. setColor(color: Color3): void;
  43170. /**
  43171. * Creates an BoundingBoxGizmo
  43172. * @param gizmoLayer The utility layer the gizmo will be added to
  43173. * @param color The color of the gizmo
  43174. */
  43175. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43176. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43177. private _selectNode;
  43178. /**
  43179. * Updates the bounding box information for the Gizmo
  43180. */
  43181. updateBoundingBox(): void;
  43182. private _updateRotationSpheres;
  43183. private _updateScaleBoxes;
  43184. /**
  43185. * Enables rotation on the specified axis and disables rotation on the others
  43186. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43187. */
  43188. setEnabledRotationAxis(axis: string): void;
  43189. /**
  43190. * Enables/disables scaling
  43191. * @param enable if scaling should be enabled
  43192. */
  43193. setEnabledScaling(enable: boolean): void;
  43194. private _updateDummy;
  43195. /**
  43196. * Enables a pointer drag behavior on the bounding box of the gizmo
  43197. */
  43198. enableDragBehavior(): void;
  43199. /**
  43200. * Disposes of the gizmo
  43201. */
  43202. dispose(): void;
  43203. /**
  43204. * 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)
  43205. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43206. * @returns the bounding box mesh with the passed in mesh as a child
  43207. */
  43208. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43209. /**
  43210. * CustomMeshes are not supported by this gizmo
  43211. * @param mesh The mesh to replace the default mesh of the gizmo
  43212. */
  43213. setCustomMesh(mesh: Mesh): void;
  43214. }
  43215. }
  43216. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43217. import { Observable } from "babylonjs/Misc/observable";
  43218. import { Nullable } from "babylonjs/types";
  43219. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43221. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43222. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43223. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43224. import "babylonjs/Meshes/Builders/linesBuilder";
  43225. /**
  43226. * Single plane rotation gizmo
  43227. */
  43228. export class PlaneRotationGizmo extends Gizmo {
  43229. /**
  43230. * Drag behavior responsible for the gizmos dragging interactions
  43231. */
  43232. dragBehavior: PointerDragBehavior;
  43233. private _pointerObserver;
  43234. /**
  43235. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43236. */
  43237. snapDistance: number;
  43238. /**
  43239. * Event that fires each time the gizmo snaps to a new location.
  43240. * * snapDistance is the the change in distance
  43241. */
  43242. onSnapObservable: Observable<{
  43243. snapDistance: number;
  43244. }>;
  43245. /**
  43246. * Creates a PlaneRotationGizmo
  43247. * @param gizmoLayer The utility layer the gizmo will be added to
  43248. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43249. * @param color The color of the gizmo
  43250. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43251. */
  43252. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43254. /**
  43255. * Disposes of the gizmo
  43256. */
  43257. dispose(): void;
  43258. }
  43259. }
  43260. declare module "babylonjs/Gizmos/rotationGizmo" {
  43261. import { Observable } from "babylonjs/Misc/observable";
  43262. import { Nullable } from "babylonjs/types";
  43263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43264. import { Mesh } from "babylonjs/Meshes/mesh";
  43265. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43266. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43267. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43268. /**
  43269. * Gizmo that enables rotating a mesh along 3 axis
  43270. */
  43271. export class RotationGizmo extends Gizmo {
  43272. /**
  43273. * Internal gizmo used for interactions on the x axis
  43274. */
  43275. xGizmo: PlaneRotationGizmo;
  43276. /**
  43277. * Internal gizmo used for interactions on the y axis
  43278. */
  43279. yGizmo: PlaneRotationGizmo;
  43280. /**
  43281. * Internal gizmo used for interactions on the z axis
  43282. */
  43283. zGizmo: PlaneRotationGizmo;
  43284. /** Fires an event when any of it's sub gizmos are dragged */
  43285. onDragStartObservable: Observable<{}>;
  43286. /** Fires an event when any of it's sub gizmos are released from dragging */
  43287. onDragEndObservable: Observable<{}>;
  43288. attachedMesh: Nullable<AbstractMesh>;
  43289. /**
  43290. * Creates a RotationGizmo
  43291. * @param gizmoLayer The utility layer the gizmo will be added to
  43292. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43293. */
  43294. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43295. updateGizmoRotationToMatchAttachedMesh: boolean;
  43296. /**
  43297. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43298. */
  43299. snapDistance: number;
  43300. /**
  43301. * Ratio for the scale of the gizmo (Default: 1)
  43302. */
  43303. scaleRatio: number;
  43304. /**
  43305. * Disposes of the gizmo
  43306. */
  43307. dispose(): void;
  43308. /**
  43309. * CustomMeshes are not supported by this gizmo
  43310. * @param mesh The mesh to replace the default mesh of the gizmo
  43311. */
  43312. setCustomMesh(mesh: Mesh): void;
  43313. }
  43314. }
  43315. declare module "babylonjs/Gizmos/positionGizmo" {
  43316. import { Observable } from "babylonjs/Misc/observable";
  43317. import { Nullable } from "babylonjs/types";
  43318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43319. import { Mesh } from "babylonjs/Meshes/mesh";
  43320. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43321. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43322. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43323. /**
  43324. * Gizmo that enables dragging a mesh along 3 axis
  43325. */
  43326. export class PositionGizmo extends Gizmo {
  43327. /**
  43328. * Internal gizmo used for interactions on the x axis
  43329. */
  43330. xGizmo: AxisDragGizmo;
  43331. /**
  43332. * Internal gizmo used for interactions on the y axis
  43333. */
  43334. yGizmo: AxisDragGizmo;
  43335. /**
  43336. * Internal gizmo used for interactions on the z axis
  43337. */
  43338. zGizmo: AxisDragGizmo;
  43339. /** Fires an event when any of it's sub gizmos are dragged */
  43340. onDragStartObservable: Observable<{}>;
  43341. /** Fires an event when any of it's sub gizmos are released from dragging */
  43342. onDragEndObservable: Observable<{}>;
  43343. attachedMesh: Nullable<AbstractMesh>;
  43344. /**
  43345. * Creates a PositionGizmo
  43346. * @param gizmoLayer The utility layer the gizmo will be added to
  43347. */
  43348. constructor(gizmoLayer?: UtilityLayerRenderer);
  43349. updateGizmoRotationToMatchAttachedMesh: boolean;
  43350. /**
  43351. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43352. */
  43353. snapDistance: number;
  43354. /**
  43355. * Ratio for the scale of the gizmo (Default: 1)
  43356. */
  43357. scaleRatio: number;
  43358. /**
  43359. * Disposes of the gizmo
  43360. */
  43361. dispose(): void;
  43362. /**
  43363. * CustomMeshes are not supported by this gizmo
  43364. * @param mesh The mesh to replace the default mesh of the gizmo
  43365. */
  43366. setCustomMesh(mesh: Mesh): void;
  43367. }
  43368. }
  43369. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43370. import { Scene } from "babylonjs/scene";
  43371. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43372. import { Mesh } from "babylonjs/Meshes/mesh";
  43373. /**
  43374. * Class containing static functions to help procedurally build meshes
  43375. */
  43376. export class PolyhedronBuilder {
  43377. /**
  43378. * Creates a polyhedron mesh
  43379. * * 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
  43380. * * The parameter `size` (positive float, default 1) sets the polygon size
  43381. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43382. * * 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`
  43383. * * 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
  43384. * * 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)`)
  43385. * * 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
  43386. * * 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
  43387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43390. * @param name defines the name of the mesh
  43391. * @param options defines the options used to create the mesh
  43392. * @param scene defines the hosting scene
  43393. * @returns the polyhedron mesh
  43394. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43395. */
  43396. static CreatePolyhedron(name: string, options: {
  43397. type?: number;
  43398. size?: number;
  43399. sizeX?: number;
  43400. sizeY?: number;
  43401. sizeZ?: number;
  43402. custom?: any;
  43403. faceUV?: Vector4[];
  43404. faceColors?: Color4[];
  43405. flat?: boolean;
  43406. updatable?: boolean;
  43407. sideOrientation?: number;
  43408. frontUVs?: Vector4;
  43409. backUVs?: Vector4;
  43410. }, scene: Scene): Mesh;
  43411. }
  43412. }
  43413. declare module "babylonjs/Gizmos/scaleGizmo" {
  43414. import { Observable } from "babylonjs/Misc/observable";
  43415. import { Nullable } from "babylonjs/types";
  43416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43417. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43418. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43419. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43420. /**
  43421. * Gizmo that enables scaling a mesh along 3 axis
  43422. */
  43423. export class ScaleGizmo extends Gizmo {
  43424. /**
  43425. * Internal gizmo used for interactions on the x axis
  43426. */
  43427. xGizmo: AxisScaleGizmo;
  43428. /**
  43429. * Internal gizmo used for interactions on the y axis
  43430. */
  43431. yGizmo: AxisScaleGizmo;
  43432. /**
  43433. * Internal gizmo used for interactions on the z axis
  43434. */
  43435. zGizmo: AxisScaleGizmo;
  43436. /**
  43437. * Internal gizmo used to scale all axis equally
  43438. */
  43439. uniformScaleGizmo: AxisScaleGizmo;
  43440. /** Fires an event when any of it's sub gizmos are dragged */
  43441. onDragStartObservable: Observable<{}>;
  43442. /** Fires an event when any of it's sub gizmos are released from dragging */
  43443. onDragEndObservable: Observable<{}>;
  43444. attachedMesh: Nullable<AbstractMesh>;
  43445. /**
  43446. * Creates a ScaleGizmo
  43447. * @param gizmoLayer The utility layer the gizmo will be added to
  43448. */
  43449. constructor(gizmoLayer?: UtilityLayerRenderer);
  43450. updateGizmoRotationToMatchAttachedMesh: boolean;
  43451. /**
  43452. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43453. */
  43454. snapDistance: number;
  43455. /**
  43456. * Ratio for the scale of the gizmo (Default: 1)
  43457. */
  43458. scaleRatio: number;
  43459. /**
  43460. * Disposes of the gizmo
  43461. */
  43462. dispose(): void;
  43463. }
  43464. }
  43465. declare module "babylonjs/Gizmos/gizmoManager" {
  43466. import { Observable } from "babylonjs/Misc/observable";
  43467. import { Nullable } from "babylonjs/types";
  43468. import { Scene, IDisposable } from "babylonjs/scene";
  43469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43470. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43471. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43472. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43473. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43474. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43475. /**
  43476. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43477. */
  43478. export class GizmoManager implements IDisposable {
  43479. private scene;
  43480. /**
  43481. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43482. */
  43483. gizmos: {
  43484. positionGizmo: Nullable<PositionGizmo>;
  43485. rotationGizmo: Nullable<RotationGizmo>;
  43486. scaleGizmo: Nullable<ScaleGizmo>;
  43487. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43488. };
  43489. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43490. clearGizmoOnEmptyPointerEvent: boolean;
  43491. /** Fires an event when the manager is attached to a mesh */
  43492. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43493. private _gizmosEnabled;
  43494. private _pointerObserver;
  43495. private _attachedMesh;
  43496. private _boundingBoxColor;
  43497. private _defaultUtilityLayer;
  43498. private _defaultKeepDepthUtilityLayer;
  43499. /**
  43500. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43501. */
  43502. boundingBoxDragBehavior: SixDofDragBehavior;
  43503. /**
  43504. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43505. */
  43506. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43507. /**
  43508. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43509. */
  43510. usePointerToAttachGizmos: boolean;
  43511. /**
  43512. * Instatiates a gizmo manager
  43513. * @param scene the scene to overlay the gizmos on top of
  43514. */
  43515. constructor(scene: Scene);
  43516. /**
  43517. * Attaches a set of gizmos to the specified mesh
  43518. * @param mesh The mesh the gizmo's should be attached to
  43519. */
  43520. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43521. /**
  43522. * If the position gizmo is enabled
  43523. */
  43524. positionGizmoEnabled: boolean;
  43525. /**
  43526. * If the rotation gizmo is enabled
  43527. */
  43528. rotationGizmoEnabled: boolean;
  43529. /**
  43530. * If the scale gizmo is enabled
  43531. */
  43532. scaleGizmoEnabled: boolean;
  43533. /**
  43534. * If the boundingBox gizmo is enabled
  43535. */
  43536. boundingBoxGizmoEnabled: boolean;
  43537. /**
  43538. * Disposes of the gizmo manager
  43539. */
  43540. dispose(): void;
  43541. }
  43542. }
  43543. declare module "babylonjs/Gizmos/lightGizmo" {
  43544. import { Nullable } from "babylonjs/types";
  43545. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43546. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43547. import { Light } from "babylonjs/Lights/light";
  43548. /**
  43549. * Gizmo that enables viewing a light
  43550. */
  43551. export class LightGizmo extends Gizmo {
  43552. private _box;
  43553. /**
  43554. * Creates a LightGizmo
  43555. * @param gizmoLayer The utility layer the gizmo will be added to
  43556. */
  43557. constructor(gizmoLayer?: UtilityLayerRenderer);
  43558. private _light;
  43559. /**
  43560. * The light that the gizmo is attached to
  43561. */
  43562. light: Nullable<Light>;
  43563. /**
  43564. * @hidden
  43565. * Updates the gizmo to match the attached mesh's position/rotation
  43566. */
  43567. protected _update(): void;
  43568. }
  43569. }
  43570. declare module "babylonjs/Gizmos/index" {
  43571. export * from "babylonjs/Gizmos/axisDragGizmo";
  43572. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43573. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43574. export * from "babylonjs/Gizmos/gizmo";
  43575. export * from "babylonjs/Gizmos/gizmoManager";
  43576. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43577. export * from "babylonjs/Gizmos/positionGizmo";
  43578. export * from "babylonjs/Gizmos/rotationGizmo";
  43579. export * from "babylonjs/Gizmos/scaleGizmo";
  43580. export * from "babylonjs/Gizmos/lightGizmo";
  43581. }
  43582. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43583. /** @hidden */
  43584. export var backgroundFragmentDeclaration: {
  43585. name: string;
  43586. shader: string;
  43587. };
  43588. }
  43589. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43590. /** @hidden */
  43591. export var backgroundUboDeclaration: {
  43592. name: string;
  43593. shader: string;
  43594. };
  43595. }
  43596. declare module "babylonjs/Shaders/background.fragment" {
  43597. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43598. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43599. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43600. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43601. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43602. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43603. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43604. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43605. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43606. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43607. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43608. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43609. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43610. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43611. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43612. /** @hidden */
  43613. export var backgroundPixelShader: {
  43614. name: string;
  43615. shader: string;
  43616. };
  43617. }
  43618. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43619. /** @hidden */
  43620. export var backgroundVertexDeclaration: {
  43621. name: string;
  43622. shader: string;
  43623. };
  43624. }
  43625. declare module "babylonjs/Shaders/background.vertex" {
  43626. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43627. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43628. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43629. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43630. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43631. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43632. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43633. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43634. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43635. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43636. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43638. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43639. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43640. /** @hidden */
  43641. export var backgroundVertexShader: {
  43642. name: string;
  43643. shader: string;
  43644. };
  43645. }
  43646. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43647. import { Nullable, int, float } from "babylonjs/types";
  43648. import { Scene } from "babylonjs/scene";
  43649. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43650. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43652. import { Mesh } from "babylonjs/Meshes/mesh";
  43653. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43654. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43655. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43657. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43658. import "babylonjs/Shaders/background.fragment";
  43659. import "babylonjs/Shaders/background.vertex";
  43660. /**
  43661. * Background material used to create an efficient environement around your scene.
  43662. */
  43663. export class BackgroundMaterial extends PushMaterial {
  43664. /**
  43665. * Standard reflectance value at parallel view angle.
  43666. */
  43667. static StandardReflectance0: number;
  43668. /**
  43669. * Standard reflectance value at grazing angle.
  43670. */
  43671. static StandardReflectance90: number;
  43672. protected _primaryColor: Color3;
  43673. /**
  43674. * Key light Color (multiply against the environement texture)
  43675. */
  43676. primaryColor: Color3;
  43677. protected __perceptualColor: Nullable<Color3>;
  43678. /**
  43679. * Experimental Internal Use Only.
  43680. *
  43681. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43682. * This acts as a helper to set the primary color to a more "human friendly" value.
  43683. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43684. * output color as close as possible from the chosen value.
  43685. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43686. * part of lighting setup.)
  43687. */
  43688. _perceptualColor: Nullable<Color3>;
  43689. protected _primaryColorShadowLevel: float;
  43690. /**
  43691. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43692. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43693. */
  43694. primaryColorShadowLevel: float;
  43695. protected _primaryColorHighlightLevel: float;
  43696. /**
  43697. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43698. * The primary color is used at the level chosen to define what the white area would look.
  43699. */
  43700. primaryColorHighlightLevel: float;
  43701. protected _reflectionTexture: Nullable<BaseTexture>;
  43702. /**
  43703. * Reflection Texture used in the material.
  43704. * Should be author in a specific way for the best result (refer to the documentation).
  43705. */
  43706. reflectionTexture: Nullable<BaseTexture>;
  43707. protected _reflectionBlur: float;
  43708. /**
  43709. * Reflection Texture level of blur.
  43710. *
  43711. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43712. * texture twice.
  43713. */
  43714. reflectionBlur: float;
  43715. protected _diffuseTexture: Nullable<BaseTexture>;
  43716. /**
  43717. * Diffuse Texture used in the material.
  43718. * Should be author in a specific way for the best result (refer to the documentation).
  43719. */
  43720. diffuseTexture: Nullable<BaseTexture>;
  43721. protected _shadowLights: Nullable<IShadowLight[]>;
  43722. /**
  43723. * Specify the list of lights casting shadow on the material.
  43724. * All scene shadow lights will be included if null.
  43725. */
  43726. shadowLights: Nullable<IShadowLight[]>;
  43727. protected _shadowLevel: float;
  43728. /**
  43729. * Helps adjusting the shadow to a softer level if required.
  43730. * 0 means black shadows and 1 means no shadows.
  43731. */
  43732. shadowLevel: float;
  43733. protected _sceneCenter: Vector3;
  43734. /**
  43735. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43736. * It is usually zero but might be interesting to modify according to your setup.
  43737. */
  43738. sceneCenter: Vector3;
  43739. protected _opacityFresnel: boolean;
  43740. /**
  43741. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43742. * This helps ensuring a nice transition when the camera goes under the ground.
  43743. */
  43744. opacityFresnel: boolean;
  43745. protected _reflectionFresnel: boolean;
  43746. /**
  43747. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43748. * This helps adding a mirror texture on the ground.
  43749. */
  43750. reflectionFresnel: boolean;
  43751. protected _reflectionFalloffDistance: number;
  43752. /**
  43753. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43754. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43755. */
  43756. reflectionFalloffDistance: number;
  43757. protected _reflectionAmount: number;
  43758. /**
  43759. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43760. */
  43761. reflectionAmount: number;
  43762. protected _reflectionReflectance0: number;
  43763. /**
  43764. * This specifies the weight of the reflection at grazing angle.
  43765. */
  43766. reflectionReflectance0: number;
  43767. protected _reflectionReflectance90: number;
  43768. /**
  43769. * This specifies the weight of the reflection at a perpendicular point of view.
  43770. */
  43771. reflectionReflectance90: number;
  43772. /**
  43773. * Sets the reflection reflectance fresnel values according to the default standard
  43774. * empirically know to work well :-)
  43775. */
  43776. reflectionStandardFresnelWeight: number;
  43777. protected _useRGBColor: boolean;
  43778. /**
  43779. * Helps to directly use the maps channels instead of their level.
  43780. */
  43781. useRGBColor: boolean;
  43782. protected _enableNoise: boolean;
  43783. /**
  43784. * This helps reducing the banding effect that could occur on the background.
  43785. */
  43786. enableNoise: boolean;
  43787. /**
  43788. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43789. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43790. * Recommended to be keep at 1.0 except for special cases.
  43791. */
  43792. fovMultiplier: number;
  43793. private _fovMultiplier;
  43794. /**
  43795. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43796. */
  43797. useEquirectangularFOV: boolean;
  43798. private _maxSimultaneousLights;
  43799. /**
  43800. * Number of Simultaneous lights allowed on the material.
  43801. */
  43802. maxSimultaneousLights: int;
  43803. /**
  43804. * Default configuration related to image processing available in the Background Material.
  43805. */
  43806. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43807. /**
  43808. * Keep track of the image processing observer to allow dispose and replace.
  43809. */
  43810. private _imageProcessingObserver;
  43811. /**
  43812. * Attaches a new image processing configuration to the PBR Material.
  43813. * @param configuration (if null the scene configuration will be use)
  43814. */
  43815. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43816. /**
  43817. * Gets the image processing configuration used either in this material.
  43818. */
  43819. /**
  43820. * Sets the Default image processing configuration used either in the this material.
  43821. *
  43822. * If sets to null, the scene one is in use.
  43823. */
  43824. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43825. /**
  43826. * Gets wether the color curves effect is enabled.
  43827. */
  43828. /**
  43829. * Sets wether the color curves effect is enabled.
  43830. */
  43831. cameraColorCurvesEnabled: boolean;
  43832. /**
  43833. * Gets wether the color grading effect is enabled.
  43834. */
  43835. /**
  43836. * Gets wether the color grading effect is enabled.
  43837. */
  43838. cameraColorGradingEnabled: boolean;
  43839. /**
  43840. * Gets wether tonemapping is enabled or not.
  43841. */
  43842. /**
  43843. * Sets wether tonemapping is enabled or not
  43844. */
  43845. cameraToneMappingEnabled: boolean;
  43846. /**
  43847. * The camera exposure used on this material.
  43848. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43849. * This corresponds to a photographic exposure.
  43850. */
  43851. /**
  43852. * The camera exposure used on this material.
  43853. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43854. * This corresponds to a photographic exposure.
  43855. */
  43856. cameraExposure: float;
  43857. /**
  43858. * Gets The camera contrast used on this material.
  43859. */
  43860. /**
  43861. * Sets The camera contrast used on this material.
  43862. */
  43863. cameraContrast: float;
  43864. /**
  43865. * Gets the Color Grading 2D Lookup Texture.
  43866. */
  43867. /**
  43868. * Sets the Color Grading 2D Lookup Texture.
  43869. */
  43870. cameraColorGradingTexture: Nullable<BaseTexture>;
  43871. /**
  43872. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43873. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43874. * 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;
  43875. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43876. */
  43877. /**
  43878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43880. * 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;
  43881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43882. */
  43883. cameraColorCurves: Nullable<ColorCurves>;
  43884. /**
  43885. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43886. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43887. */
  43888. switchToBGR: boolean;
  43889. private _renderTargets;
  43890. private _reflectionControls;
  43891. private _white;
  43892. private _primaryShadowColor;
  43893. private _primaryHighlightColor;
  43894. /**
  43895. * Instantiates a Background Material in the given scene
  43896. * @param name The friendly name of the material
  43897. * @param scene The scene to add the material to
  43898. */
  43899. constructor(name: string, scene: Scene);
  43900. /**
  43901. * Gets a boolean indicating that current material needs to register RTT
  43902. */
  43903. readonly hasRenderTargetTextures: boolean;
  43904. /**
  43905. * The entire material has been created in order to prevent overdraw.
  43906. * @returns false
  43907. */
  43908. needAlphaTesting(): boolean;
  43909. /**
  43910. * The entire material has been created in order to prevent overdraw.
  43911. * @returns true if blending is enable
  43912. */
  43913. needAlphaBlending(): boolean;
  43914. /**
  43915. * Checks wether the material is ready to be rendered for a given mesh.
  43916. * @param mesh The mesh to render
  43917. * @param subMesh The submesh to check against
  43918. * @param useInstances Specify wether or not the material is used with instances
  43919. * @returns true if all the dependencies are ready (Textures, Effects...)
  43920. */
  43921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43922. /**
  43923. * Compute the primary color according to the chosen perceptual color.
  43924. */
  43925. private _computePrimaryColorFromPerceptualColor;
  43926. /**
  43927. * Compute the highlights and shadow colors according to their chosen levels.
  43928. */
  43929. private _computePrimaryColors;
  43930. /**
  43931. * Build the uniform buffer used in the material.
  43932. */
  43933. buildUniformLayout(): void;
  43934. /**
  43935. * Unbind the material.
  43936. */
  43937. unbind(): void;
  43938. /**
  43939. * Bind only the world matrix to the material.
  43940. * @param world The world matrix to bind.
  43941. */
  43942. bindOnlyWorldMatrix(world: Matrix): void;
  43943. /**
  43944. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43945. * @param world The world matrix to bind.
  43946. * @param subMesh The submesh to bind for.
  43947. */
  43948. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43949. /**
  43950. * Dispose the material.
  43951. * @param forceDisposeEffect Force disposal of the associated effect.
  43952. * @param forceDisposeTextures Force disposal of the associated textures.
  43953. */
  43954. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43955. /**
  43956. * Clones the material.
  43957. * @param name The cloned name.
  43958. * @returns The cloned material.
  43959. */
  43960. clone(name: string): BackgroundMaterial;
  43961. /**
  43962. * Serializes the current material to its JSON representation.
  43963. * @returns The JSON representation.
  43964. */
  43965. serialize(): any;
  43966. /**
  43967. * Gets the class name of the material
  43968. * @returns "BackgroundMaterial"
  43969. */
  43970. getClassName(): string;
  43971. /**
  43972. * Parse a JSON input to create back a background material.
  43973. * @param source The JSON data to parse
  43974. * @param scene The scene to create the parsed material in
  43975. * @param rootUrl The root url of the assets the material depends upon
  43976. * @returns the instantiated BackgroundMaterial.
  43977. */
  43978. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43979. }
  43980. }
  43981. declare module "babylonjs/Helpers/environmentHelper" {
  43982. import { Observable } from "babylonjs/Misc/observable";
  43983. import { Nullable } from "babylonjs/types";
  43984. import { Scene } from "babylonjs/scene";
  43985. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43987. import { Mesh } from "babylonjs/Meshes/mesh";
  43988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43989. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43990. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43991. import "babylonjs/Meshes/Builders/planeBuilder";
  43992. import "babylonjs/Meshes/Builders/boxBuilder";
  43993. /**
  43994. * Represents the different options available during the creation of
  43995. * a Environment helper.
  43996. *
  43997. * This can control the default ground, skybox and image processing setup of your scene.
  43998. */
  43999. export interface IEnvironmentHelperOptions {
  44000. /**
  44001. * Specifies wether or not to create a ground.
  44002. * True by default.
  44003. */
  44004. createGround: boolean;
  44005. /**
  44006. * Specifies the ground size.
  44007. * 15 by default.
  44008. */
  44009. groundSize: number;
  44010. /**
  44011. * The texture used on the ground for the main color.
  44012. * Comes from the BabylonJS CDN by default.
  44013. *
  44014. * Remarks: Can be either a texture or a url.
  44015. */
  44016. groundTexture: string | BaseTexture;
  44017. /**
  44018. * The color mixed in the ground texture by default.
  44019. * BabylonJS clearColor by default.
  44020. */
  44021. groundColor: Color3;
  44022. /**
  44023. * Specifies the ground opacity.
  44024. * 1 by default.
  44025. */
  44026. groundOpacity: number;
  44027. /**
  44028. * Enables the ground to receive shadows.
  44029. * True by default.
  44030. */
  44031. enableGroundShadow: boolean;
  44032. /**
  44033. * Helps preventing the shadow to be fully black on the ground.
  44034. * 0.5 by default.
  44035. */
  44036. groundShadowLevel: number;
  44037. /**
  44038. * Creates a mirror texture attach to the ground.
  44039. * false by default.
  44040. */
  44041. enableGroundMirror: boolean;
  44042. /**
  44043. * Specifies the ground mirror size ratio.
  44044. * 0.3 by default as the default kernel is 64.
  44045. */
  44046. groundMirrorSizeRatio: number;
  44047. /**
  44048. * Specifies the ground mirror blur kernel size.
  44049. * 64 by default.
  44050. */
  44051. groundMirrorBlurKernel: number;
  44052. /**
  44053. * Specifies the ground mirror visibility amount.
  44054. * 1 by default
  44055. */
  44056. groundMirrorAmount: number;
  44057. /**
  44058. * Specifies the ground mirror reflectance weight.
  44059. * This uses the standard weight of the background material to setup the fresnel effect
  44060. * of the mirror.
  44061. * 1 by default.
  44062. */
  44063. groundMirrorFresnelWeight: number;
  44064. /**
  44065. * Specifies the ground mirror Falloff distance.
  44066. * This can helps reducing the size of the reflection.
  44067. * 0 by Default.
  44068. */
  44069. groundMirrorFallOffDistance: number;
  44070. /**
  44071. * Specifies the ground mirror texture type.
  44072. * Unsigned Int by Default.
  44073. */
  44074. groundMirrorTextureType: number;
  44075. /**
  44076. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44077. * the shown objects.
  44078. */
  44079. groundYBias: number;
  44080. /**
  44081. * Specifies wether or not to create a skybox.
  44082. * True by default.
  44083. */
  44084. createSkybox: boolean;
  44085. /**
  44086. * Specifies the skybox size.
  44087. * 20 by default.
  44088. */
  44089. skyboxSize: number;
  44090. /**
  44091. * The texture used on the skybox for the main color.
  44092. * Comes from the BabylonJS CDN by default.
  44093. *
  44094. * Remarks: Can be either a texture or a url.
  44095. */
  44096. skyboxTexture: string | BaseTexture;
  44097. /**
  44098. * The color mixed in the skybox texture by default.
  44099. * BabylonJS clearColor by default.
  44100. */
  44101. skyboxColor: Color3;
  44102. /**
  44103. * The background rotation around the Y axis of the scene.
  44104. * This helps aligning the key lights of your scene with the background.
  44105. * 0 by default.
  44106. */
  44107. backgroundYRotation: number;
  44108. /**
  44109. * Compute automatically the size of the elements to best fit with the scene.
  44110. */
  44111. sizeAuto: boolean;
  44112. /**
  44113. * Default position of the rootMesh if autoSize is not true.
  44114. */
  44115. rootPosition: Vector3;
  44116. /**
  44117. * Sets up the image processing in the scene.
  44118. * true by default.
  44119. */
  44120. setupImageProcessing: boolean;
  44121. /**
  44122. * The texture used as your environment texture in the scene.
  44123. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44124. *
  44125. * Remarks: Can be either a texture or a url.
  44126. */
  44127. environmentTexture: string | BaseTexture;
  44128. /**
  44129. * The value of the exposure to apply to the scene.
  44130. * 0.6 by default if setupImageProcessing is true.
  44131. */
  44132. cameraExposure: number;
  44133. /**
  44134. * The value of the contrast to apply to the scene.
  44135. * 1.6 by default if setupImageProcessing is true.
  44136. */
  44137. cameraContrast: number;
  44138. /**
  44139. * Specifies wether or not tonemapping should be enabled in the scene.
  44140. * true by default if setupImageProcessing is true.
  44141. */
  44142. toneMappingEnabled: boolean;
  44143. }
  44144. /**
  44145. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44146. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44147. * It also helps with the default setup of your imageProcessing configuration.
  44148. */
  44149. export class EnvironmentHelper {
  44150. /**
  44151. * Default ground texture URL.
  44152. */
  44153. private static _groundTextureCDNUrl;
  44154. /**
  44155. * Default skybox texture URL.
  44156. */
  44157. private static _skyboxTextureCDNUrl;
  44158. /**
  44159. * Default environment texture URL.
  44160. */
  44161. private static _environmentTextureCDNUrl;
  44162. /**
  44163. * Creates the default options for the helper.
  44164. */
  44165. private static _getDefaultOptions;
  44166. private _rootMesh;
  44167. /**
  44168. * Gets the root mesh created by the helper.
  44169. */
  44170. readonly rootMesh: Mesh;
  44171. private _skybox;
  44172. /**
  44173. * Gets the skybox created by the helper.
  44174. */
  44175. readonly skybox: Nullable<Mesh>;
  44176. private _skyboxTexture;
  44177. /**
  44178. * Gets the skybox texture created by the helper.
  44179. */
  44180. readonly skyboxTexture: Nullable<BaseTexture>;
  44181. private _skyboxMaterial;
  44182. /**
  44183. * Gets the skybox material created by the helper.
  44184. */
  44185. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44186. private _ground;
  44187. /**
  44188. * Gets the ground mesh created by the helper.
  44189. */
  44190. readonly ground: Nullable<Mesh>;
  44191. private _groundTexture;
  44192. /**
  44193. * Gets the ground texture created by the helper.
  44194. */
  44195. readonly groundTexture: Nullable<BaseTexture>;
  44196. private _groundMirror;
  44197. /**
  44198. * Gets the ground mirror created by the helper.
  44199. */
  44200. readonly groundMirror: Nullable<MirrorTexture>;
  44201. /**
  44202. * Gets the ground mirror render list to helps pushing the meshes
  44203. * you wish in the ground reflection.
  44204. */
  44205. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44206. private _groundMaterial;
  44207. /**
  44208. * Gets the ground material created by the helper.
  44209. */
  44210. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44211. /**
  44212. * Stores the creation options.
  44213. */
  44214. private readonly _scene;
  44215. private _options;
  44216. /**
  44217. * This observable will be notified with any error during the creation of the environment,
  44218. * mainly texture creation errors.
  44219. */
  44220. onErrorObservable: Observable<{
  44221. message?: string;
  44222. exception?: any;
  44223. }>;
  44224. /**
  44225. * constructor
  44226. * @param options Defines the options we want to customize the helper
  44227. * @param scene The scene to add the material to
  44228. */
  44229. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44230. /**
  44231. * Updates the background according to the new options
  44232. * @param options
  44233. */
  44234. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44235. /**
  44236. * Sets the primary color of all the available elements.
  44237. * @param color the main color to affect to the ground and the background
  44238. */
  44239. setMainColor(color: Color3): void;
  44240. /**
  44241. * Setup the image processing according to the specified options.
  44242. */
  44243. private _setupImageProcessing;
  44244. /**
  44245. * Setup the environment texture according to the specified options.
  44246. */
  44247. private _setupEnvironmentTexture;
  44248. /**
  44249. * Setup the background according to the specified options.
  44250. */
  44251. private _setupBackground;
  44252. /**
  44253. * Get the scene sizes according to the setup.
  44254. */
  44255. private _getSceneSize;
  44256. /**
  44257. * Setup the ground according to the specified options.
  44258. */
  44259. private _setupGround;
  44260. /**
  44261. * Setup the ground material according to the specified options.
  44262. */
  44263. private _setupGroundMaterial;
  44264. /**
  44265. * Setup the ground diffuse texture according to the specified options.
  44266. */
  44267. private _setupGroundDiffuseTexture;
  44268. /**
  44269. * Setup the ground mirror texture according to the specified options.
  44270. */
  44271. private _setupGroundMirrorTexture;
  44272. /**
  44273. * Setup the ground to receive the mirror texture.
  44274. */
  44275. private _setupMirrorInGroundMaterial;
  44276. /**
  44277. * Setup the skybox according to the specified options.
  44278. */
  44279. private _setupSkybox;
  44280. /**
  44281. * Setup the skybox material according to the specified options.
  44282. */
  44283. private _setupSkyboxMaterial;
  44284. /**
  44285. * Setup the skybox reflection texture according to the specified options.
  44286. */
  44287. private _setupSkyboxReflectionTexture;
  44288. private _errorHandler;
  44289. /**
  44290. * Dispose all the elements created by the Helper.
  44291. */
  44292. dispose(): void;
  44293. }
  44294. }
  44295. declare module "babylonjs/Helpers/photoDome" {
  44296. import { Observable } from "babylonjs/Misc/observable";
  44297. import { Nullable } from "babylonjs/types";
  44298. import { Scene } from "babylonjs/scene";
  44299. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44300. import { Mesh } from "babylonjs/Meshes/mesh";
  44301. import { Texture } from "babylonjs/Materials/Textures/texture";
  44302. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44303. import "babylonjs/Meshes/Builders/sphereBuilder";
  44304. /**
  44305. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44306. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44307. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44308. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44309. */
  44310. export class PhotoDome extends TransformNode {
  44311. private _useDirectMapping;
  44312. /**
  44313. * The texture being displayed on the sphere
  44314. */
  44315. protected _photoTexture: Texture;
  44316. /**
  44317. * Gets or sets the texture being displayed on the sphere
  44318. */
  44319. photoTexture: Texture;
  44320. /**
  44321. * Observable raised when an error occured while loading the 360 image
  44322. */
  44323. onLoadErrorObservable: Observable<string>;
  44324. /**
  44325. * The skybox material
  44326. */
  44327. protected _material: BackgroundMaterial;
  44328. /**
  44329. * The surface used for the skybox
  44330. */
  44331. protected _mesh: Mesh;
  44332. /**
  44333. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44334. * Also see the options.resolution property.
  44335. */
  44336. fovMultiplier: number;
  44337. /**
  44338. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44339. * @param name Element's name, child elements will append suffixes for their own names.
  44340. * @param urlsOfPhoto defines the url of the photo to display
  44341. * @param options defines an object containing optional or exposed sub element properties
  44342. * @param onError defines a callback called when an error occured while loading the texture
  44343. */
  44344. constructor(name: string, urlOfPhoto: string, options: {
  44345. resolution?: number;
  44346. size?: number;
  44347. useDirectMapping?: boolean;
  44348. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44349. /**
  44350. * Releases resources associated with this node.
  44351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44353. */
  44354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44355. }
  44356. }
  44357. declare module "babylonjs/Misc/textureTools" {
  44358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44359. import { Texture } from "babylonjs/Materials/Textures/texture";
  44360. import { Scene } from "babylonjs/scene";
  44361. /**
  44362. * Class used to host texture specific utilities
  44363. */
  44364. export class TextureTools {
  44365. /**
  44366. * Uses the GPU to create a copy texture rescaled at a given size
  44367. * @param texture Texture to copy from
  44368. * @param width defines the desired width
  44369. * @param height defines the desired height
  44370. * @param useBilinearMode defines if bilinear mode has to be used
  44371. * @return the generated texture
  44372. */
  44373. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44374. /**
  44375. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44376. * @param scene defines the hosting scene
  44377. * @returns the environment BRDF texture
  44378. */
  44379. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44380. private static _environmentBRDFBase64Texture;
  44381. }
  44382. }
  44383. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44384. import { Nullable } from "babylonjs/types";
  44385. import { IAnimatable } from "babylonjs/Misc/tools";
  44386. import { Color3 } from "babylonjs/Maths/math";
  44387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44388. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44389. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44390. import { Engine } from "babylonjs/Engines/engine";
  44391. import { Scene } from "babylonjs/scene";
  44392. /**
  44393. * @hidden
  44394. */
  44395. export interface IMaterialClearCoatDefines {
  44396. CLEARCOAT: boolean;
  44397. CLEARCOAT_DEFAULTIOR: boolean;
  44398. CLEARCOAT_TEXTURE: boolean;
  44399. CLEARCOAT_TEXTUREDIRECTUV: number;
  44400. CLEARCOAT_BUMP: boolean;
  44401. CLEARCOAT_BUMPDIRECTUV: number;
  44402. CLEARCOAT_TINT: boolean;
  44403. CLEARCOAT_TINT_TEXTURE: boolean;
  44404. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44405. /** @hidden */
  44406. _areTexturesDirty: boolean;
  44407. }
  44408. /**
  44409. * Define the code related to the clear coat parameters of the pbr material.
  44410. */
  44411. export class PBRClearCoatConfiguration {
  44412. /**
  44413. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44414. * The default fits with a polyurethane material.
  44415. */
  44416. private static readonly _DefaultIndiceOfRefraction;
  44417. private _isEnabled;
  44418. /**
  44419. * Defines if the clear coat is enabled in the material.
  44420. */
  44421. isEnabled: boolean;
  44422. /**
  44423. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44424. */
  44425. intensity: number;
  44426. /**
  44427. * Defines the clear coat layer roughness.
  44428. */
  44429. roughness: number;
  44430. private _indiceOfRefraction;
  44431. /**
  44432. * Defines the indice of refraction of the clear coat.
  44433. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44434. * The default fits with a polyurethane material.
  44435. * Changing the default value is more performance intensive.
  44436. */
  44437. indiceOfRefraction: number;
  44438. private _texture;
  44439. /**
  44440. * Stores the clear coat values in a texture.
  44441. */
  44442. texture: Nullable<BaseTexture>;
  44443. private _bumpTexture;
  44444. /**
  44445. * Define the clear coat specific bump texture.
  44446. */
  44447. bumpTexture: Nullable<BaseTexture>;
  44448. private _isTintEnabled;
  44449. /**
  44450. * Defines if the clear coat tint is enabled in the material.
  44451. */
  44452. isTintEnabled: boolean;
  44453. /**
  44454. * Defines if the clear coat tint is enabled in the material.
  44455. * This is only use if tint is enabled
  44456. */
  44457. tintColor: Color3;
  44458. /**
  44459. * Defines if the distance at which the tint color should be found in the
  44460. * clear coat media.
  44461. * This is only use if tint is enabled
  44462. */
  44463. tintColorAtDistance: number;
  44464. /**
  44465. * Defines the clear coat layer thickness.
  44466. * This is only use if tint is enabled
  44467. */
  44468. tintThickness: number;
  44469. private _tintTexture;
  44470. /**
  44471. * Stores the clear tint values in a texture.
  44472. * rgb is tint
  44473. * a is a thickness factor
  44474. */
  44475. tintTexture: Nullable<BaseTexture>;
  44476. /** @hidden */
  44477. private _internalMarkAllSubMeshesAsTexturesDirty;
  44478. /** @hidden */
  44479. _markAllSubMeshesAsTexturesDirty(): void;
  44480. /**
  44481. * Instantiate a new istance of clear coat configuration.
  44482. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44483. */
  44484. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44485. /**
  44486. * Specifies that the submesh is ready to be used.
  44487. * @param defines the list of "defines" to update.
  44488. * @param scene defines the scene the material belongs to.
  44489. * @param engine defines the engine the material belongs to.
  44490. * @param disableBumpMap defines wether the material disables bump or not.
  44491. * @returns - boolean indicating that the submesh is ready or not.
  44492. */
  44493. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44494. /**
  44495. * Checks to see if a texture is used in the material.
  44496. * @param defines the list of "defines" to update.
  44497. * @param scene defines the scene to the material belongs to.
  44498. */
  44499. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44500. /**
  44501. * Binds the material data.
  44502. * @param uniformBuffer defines the Uniform buffer to fill in.
  44503. * @param scene defines the scene the material belongs to.
  44504. * @param engine defines the engine the material belongs to.
  44505. * @param disableBumpMap defines wether the material disables bump or not.
  44506. * @param isFrozen defines wether the material is frozen or not.
  44507. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44508. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44509. */
  44510. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44511. /**
  44512. * Checks to see if a texture is used in the material.
  44513. * @param texture - Base texture to use.
  44514. * @returns - Boolean specifying if a texture is used in the material.
  44515. */
  44516. hasTexture(texture: BaseTexture): boolean;
  44517. /**
  44518. * Returns an array of the actively used textures.
  44519. * @param activeTextures Array of BaseTextures
  44520. */
  44521. getActiveTextures(activeTextures: BaseTexture[]): void;
  44522. /**
  44523. * Returns the animatable textures.
  44524. * @param animatables Array of animatable textures.
  44525. */
  44526. getAnimatables(animatables: IAnimatable[]): void;
  44527. /**
  44528. * Disposes the resources of the material.
  44529. * @param forceDisposeTextures - Forces the disposal of all textures.
  44530. */
  44531. dispose(forceDisposeTextures?: boolean): void;
  44532. /**
  44533. * Get the current class name of the texture useful for serialization or dynamic coding.
  44534. * @returns "PBRClearCoatConfiguration"
  44535. */
  44536. getClassName(): string;
  44537. /**
  44538. * Add fallbacks to the effect fallbacks list.
  44539. * @param defines defines the Base texture to use.
  44540. * @param fallbacks defines the current fallback list.
  44541. * @param currentRank defines the current fallback rank.
  44542. * @returns the new fallback rank.
  44543. */
  44544. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44545. /**
  44546. * Add the required uniforms to the current list.
  44547. * @param uniforms defines the current uniform list.
  44548. */
  44549. static AddUniforms(uniforms: string[]): void;
  44550. /**
  44551. * Add the required samplers to the current list.
  44552. * @param samplers defines the current sampler list.
  44553. */
  44554. static AddSamplers(samplers: string[]): void;
  44555. /**
  44556. * Add the required uniforms to the current buffer.
  44557. * @param uniformBuffer defines the current uniform buffer.
  44558. */
  44559. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44560. /**
  44561. * Makes a duplicate of the current configuration into another one.
  44562. * @param clearCoatConfiguration define the config where to copy the info
  44563. */
  44564. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44565. /**
  44566. * Serializes this clear coat configuration.
  44567. * @returns - An object with the serialized config.
  44568. */
  44569. serialize(): any;
  44570. /**
  44571. * Parses a Clear Coat Configuration from a serialized object.
  44572. * @param source - Serialized object.
  44573. */
  44574. parse(source: any): void;
  44575. }
  44576. }
  44577. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44578. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44579. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44581. import { Vector2 } from "babylonjs/Maths/math";
  44582. import { Scene } from "babylonjs/scene";
  44583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44584. import { IAnimatable } from "babylonjs/Misc/tools";
  44585. import { Nullable } from "babylonjs/types";
  44586. /**
  44587. * @hidden
  44588. */
  44589. export interface IMaterialAnisotropicDefines {
  44590. ANISOTROPIC: boolean;
  44591. ANISOTROPIC_TEXTURE: boolean;
  44592. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44593. MAINUV1: boolean;
  44594. _areTexturesDirty: boolean;
  44595. _needUVs: boolean;
  44596. }
  44597. /**
  44598. * Define the code related to the anisotropic parameters of the pbr material.
  44599. */
  44600. export class PBRAnisotropicConfiguration {
  44601. private _isEnabled;
  44602. /**
  44603. * Defines if the anisotropy is enabled in the material.
  44604. */
  44605. isEnabled: boolean;
  44606. /**
  44607. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44608. */
  44609. intensity: number;
  44610. /**
  44611. * Defines if the effect is along the tangents, bitangents or in between.
  44612. * By default, the effect is "strectching" the highlights along the tangents.
  44613. */
  44614. direction: Vector2;
  44615. private _texture;
  44616. /**
  44617. * Stores the anisotropy values in a texture.
  44618. * rg is direction (like normal from -1 to 1)
  44619. * b is a intensity
  44620. */
  44621. texture: Nullable<BaseTexture>;
  44622. /** @hidden */
  44623. private _internalMarkAllSubMeshesAsTexturesDirty;
  44624. /** @hidden */
  44625. _markAllSubMeshesAsTexturesDirty(): void;
  44626. /**
  44627. * Instantiate a new istance of anisotropy configuration.
  44628. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44629. */
  44630. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44631. /**
  44632. * Specifies that the submesh is ready to be used.
  44633. * @param defines the list of "defines" to update.
  44634. * @param scene defines the scene the material belongs to.
  44635. * @returns - boolean indicating that the submesh is ready or not.
  44636. */
  44637. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44638. /**
  44639. * Checks to see if a texture is used in the material.
  44640. * @param defines the list of "defines" to update.
  44641. * @param mesh the mesh we are preparing the defines for.
  44642. * @param scene defines the scene the material belongs to.
  44643. */
  44644. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44645. /**
  44646. * Binds the material data.
  44647. * @param uniformBuffer defines the Uniform buffer to fill in.
  44648. * @param scene defines the scene the material belongs to.
  44649. * @param isFrozen defines wether the material is frozen or not.
  44650. */
  44651. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44652. /**
  44653. * Checks to see if a texture is used in the material.
  44654. * @param texture - Base texture to use.
  44655. * @returns - Boolean specifying if a texture is used in the material.
  44656. */
  44657. hasTexture(texture: BaseTexture): boolean;
  44658. /**
  44659. * Returns an array of the actively used textures.
  44660. * @param activeTextures Array of BaseTextures
  44661. */
  44662. getActiveTextures(activeTextures: BaseTexture[]): void;
  44663. /**
  44664. * Returns the animatable textures.
  44665. * @param animatables Array of animatable textures.
  44666. */
  44667. getAnimatables(animatables: IAnimatable[]): void;
  44668. /**
  44669. * Disposes the resources of the material.
  44670. * @param forceDisposeTextures - Forces the disposal of all textures.
  44671. */
  44672. dispose(forceDisposeTextures?: boolean): void;
  44673. /**
  44674. * Get the current class name of the texture useful for serialization or dynamic coding.
  44675. * @returns "PBRAnisotropicConfiguration"
  44676. */
  44677. getClassName(): string;
  44678. /**
  44679. * Add fallbacks to the effect fallbacks list.
  44680. * @param defines defines the Base texture to use.
  44681. * @param fallbacks defines the current fallback list.
  44682. * @param currentRank defines the current fallback rank.
  44683. * @returns the new fallback rank.
  44684. */
  44685. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44686. /**
  44687. * Add the required uniforms to the current list.
  44688. * @param uniforms defines the current uniform list.
  44689. */
  44690. static AddUniforms(uniforms: string[]): void;
  44691. /**
  44692. * Add the required uniforms to the current buffer.
  44693. * @param uniformBuffer defines the current uniform buffer.
  44694. */
  44695. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44696. /**
  44697. * Add the required samplers to the current list.
  44698. * @param samplers defines the current sampler list.
  44699. */
  44700. static AddSamplers(samplers: string[]): void;
  44701. /**
  44702. * Makes a duplicate of the current configuration into another one.
  44703. * @param anisotropicConfiguration define the config where to copy the info
  44704. */
  44705. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44706. /**
  44707. * Serializes this anisotropy configuration.
  44708. * @returns - An object with the serialized config.
  44709. */
  44710. serialize(): any;
  44711. /**
  44712. * Parses a anisotropy Configuration from a serialized object.
  44713. * @param source - Serialized object.
  44714. */
  44715. parse(source: any): void;
  44716. }
  44717. }
  44718. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44719. /**
  44720. * @hidden
  44721. */
  44722. export interface IMaterialBRDFDefines {
  44723. BRDF_V_HEIGHT_CORRELATED: boolean;
  44724. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44725. /** @hidden */
  44726. _areMiscDirty: boolean;
  44727. }
  44728. /**
  44729. * Define the code related to the BRDF parameters of the pbr material.
  44730. */
  44731. export class PBRBRDFConfiguration {
  44732. private _useEnergyConservation;
  44733. /**
  44734. * Defines if the material uses energy conservation.
  44735. */
  44736. useEnergyConservation: boolean;
  44737. private _useSmithVisibilityHeightCorrelated;
  44738. /**
  44739. * LEGACY Mode set to false
  44740. * Defines if the material uses height smith correlated visibility term.
  44741. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44742. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44743. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44744. * Not relying on height correlated will also disable energy conservation.
  44745. */
  44746. useSmithVisibilityHeightCorrelated: boolean;
  44747. /** @hidden */
  44748. private _internalMarkAllSubMeshesAsMiscDirty;
  44749. /** @hidden */
  44750. _markAllSubMeshesAsMiscDirty(): void;
  44751. /**
  44752. * Instantiate a new istance of clear coat configuration.
  44753. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44754. */
  44755. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44756. /**
  44757. * Checks to see if a texture is used in the material.
  44758. * @param defines the list of "defines" to update.
  44759. */
  44760. prepareDefines(defines: IMaterialBRDFDefines): void;
  44761. /**
  44762. * Get the current class name of the texture useful for serialization or dynamic coding.
  44763. * @returns "PBRClearCoatConfiguration"
  44764. */
  44765. getClassName(): string;
  44766. /**
  44767. * Makes a duplicate of the current configuration into another one.
  44768. * @param brdfConfiguration define the config where to copy the info
  44769. */
  44770. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44771. /**
  44772. * Serializes this BRDF configuration.
  44773. * @returns - An object with the serialized config.
  44774. */
  44775. serialize(): any;
  44776. /**
  44777. * Parses a BRDF Configuration from a serialized object.
  44778. * @param source - Serialized object.
  44779. */
  44780. parse(source: any): void;
  44781. }
  44782. }
  44783. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  44784. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44785. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44786. import { Color3 } from "babylonjs/Maths/math";
  44787. import { Scene } from "babylonjs/scene";
  44788. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44789. import { IAnimatable } from "babylonjs/Misc/tools";
  44790. import { Nullable } from "babylonjs/types";
  44791. /**
  44792. * @hidden
  44793. */
  44794. export interface IMaterialSheenDefines {
  44795. SHEEN: boolean;
  44796. SHEEN_TEXTURE: boolean;
  44797. SHEEN_TEXTUREDIRECTUV: number;
  44798. SHEEN_LINKWITHALBEDO: boolean;
  44799. /** @hidden */
  44800. _areTexturesDirty: boolean;
  44801. }
  44802. /**
  44803. * Define the code related to the Sheen parameters of the pbr material.
  44804. */
  44805. export class PBRSheenConfiguration {
  44806. private _isEnabled;
  44807. /**
  44808. * Defines if the material uses sheen.
  44809. */
  44810. isEnabled: boolean;
  44811. private _linkSheenWithAlbedo;
  44812. /**
  44813. * Defines if the sheen is linked to the sheen color.
  44814. */
  44815. linkSheenWithAlbedo: boolean;
  44816. /**
  44817. * Defines the sheen intensity.
  44818. */
  44819. intensity: number;
  44820. /**
  44821. * Defines the sheen color.
  44822. */
  44823. color: Color3;
  44824. private _texture;
  44825. /**
  44826. * Stores the sheen tint values in a texture.
  44827. * rgb is tint
  44828. * a is a intensity
  44829. */
  44830. texture: Nullable<BaseTexture>;
  44831. /** @hidden */
  44832. private _internalMarkAllSubMeshesAsTexturesDirty;
  44833. /** @hidden */
  44834. _markAllSubMeshesAsTexturesDirty(): void;
  44835. /**
  44836. * Instantiate a new istance of clear coat configuration.
  44837. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44838. */
  44839. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44840. /**
  44841. * Specifies that the submesh is ready to be used.
  44842. * @param defines the list of "defines" to update.
  44843. * @param scene defines the scene the material belongs to.
  44844. * @returns - boolean indicating that the submesh is ready or not.
  44845. */
  44846. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44847. /**
  44848. * Checks to see if a texture is used in the material.
  44849. * @param defines the list of "defines" to update.
  44850. * @param scene defines the scene the material belongs to.
  44851. */
  44852. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44853. /**
  44854. * Binds the material data.
  44855. * @param uniformBuffer defines the Uniform buffer to fill in.
  44856. * @param scene defines the scene the material belongs to.
  44857. * @param isFrozen defines wether the material is frozen or not.
  44858. */
  44859. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44860. /**
  44861. * Checks to see if a texture is used in the material.
  44862. * @param texture - Base texture to use.
  44863. * @returns - Boolean specifying if a texture is used in the material.
  44864. */
  44865. hasTexture(texture: BaseTexture): boolean;
  44866. /**
  44867. * Returns an array of the actively used textures.
  44868. * @param activeTextures Array of BaseTextures
  44869. */
  44870. getActiveTextures(activeTextures: BaseTexture[]): void;
  44871. /**
  44872. * Returns the animatable textures.
  44873. * @param animatables Array of animatable textures.
  44874. */
  44875. getAnimatables(animatables: IAnimatable[]): void;
  44876. /**
  44877. * Disposes the resources of the material.
  44878. * @param forceDisposeTextures - Forces the disposal of all textures.
  44879. */
  44880. dispose(forceDisposeTextures?: boolean): void;
  44881. /**
  44882. * Get the current class name of the texture useful for serialization or dynamic coding.
  44883. * @returns "PBRSheenConfiguration"
  44884. */
  44885. getClassName(): string;
  44886. /**
  44887. * Add fallbacks to the effect fallbacks list.
  44888. * @param defines defines the Base texture to use.
  44889. * @param fallbacks defines the current fallback list.
  44890. * @param currentRank defines the current fallback rank.
  44891. * @returns the new fallback rank.
  44892. */
  44893. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44894. /**
  44895. * Add the required uniforms to the current list.
  44896. * @param uniforms defines the current uniform list.
  44897. */
  44898. static AddUniforms(uniforms: string[]): void;
  44899. /**
  44900. * Add the required uniforms to the current buffer.
  44901. * @param uniformBuffer defines the current uniform buffer.
  44902. */
  44903. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44904. /**
  44905. * Add the required samplers to the current list.
  44906. * @param samplers defines the current sampler list.
  44907. */
  44908. static AddSamplers(samplers: string[]): void;
  44909. /**
  44910. * Makes a duplicate of the current configuration into another one.
  44911. * @param sheenConfiguration define the config where to copy the info
  44912. */
  44913. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44914. /**
  44915. * Serializes this BRDF configuration.
  44916. * @returns - An object with the serialized config.
  44917. */
  44918. serialize(): any;
  44919. /**
  44920. * Parses a Sheen Configuration from a serialized object.
  44921. * @param source - Serialized object.
  44922. */
  44923. parse(source: any): void;
  44924. }
  44925. }
  44926. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44927. /** @hidden */
  44928. export var pbrFragmentDeclaration: {
  44929. name: string;
  44930. shader: string;
  44931. };
  44932. }
  44933. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44934. /** @hidden */
  44935. export var pbrUboDeclaration: {
  44936. name: string;
  44937. shader: string;
  44938. };
  44939. }
  44940. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44941. /** @hidden */
  44942. export var pbrFunctions: {
  44943. name: string;
  44944. shader: string;
  44945. };
  44946. }
  44947. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44948. /** @hidden */
  44949. export var harmonicsFunctions: {
  44950. name: string;
  44951. shader: string;
  44952. };
  44953. }
  44954. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44955. /** @hidden */
  44956. export var pbrPreLightingFunctions: {
  44957. name: string;
  44958. shader: string;
  44959. };
  44960. }
  44961. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44962. /** @hidden */
  44963. export var pbrFalloffLightingFunctions: {
  44964. name: string;
  44965. shader: string;
  44966. };
  44967. }
  44968. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44969. /** @hidden */
  44970. export var pbrLightingFunctions: {
  44971. name: string;
  44972. shader: string;
  44973. };
  44974. }
  44975. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44976. /** @hidden */
  44977. export var pbrDebug: {
  44978. name: string;
  44979. shader: string;
  44980. };
  44981. }
  44982. declare module "babylonjs/Shaders/pbr.fragment" {
  44983. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44984. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44985. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44986. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44987. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44988. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44989. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44990. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44991. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44992. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44993. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44994. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44995. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44996. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44997. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44998. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44999. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45000. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45001. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45002. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45003. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45004. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45005. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45006. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45007. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45008. /** @hidden */
  45009. export var pbrPixelShader: {
  45010. name: string;
  45011. shader: string;
  45012. };
  45013. }
  45014. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45015. /** @hidden */
  45016. export var pbrVertexDeclaration: {
  45017. name: string;
  45018. shader: string;
  45019. };
  45020. }
  45021. declare module "babylonjs/Shaders/pbr.vertex" {
  45022. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45023. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45024. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45025. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45026. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45027. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45028. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45029. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45030. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45031. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45032. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45033. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45034. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45035. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45036. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45037. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45038. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45039. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45040. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45041. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45042. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45043. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45044. /** @hidden */
  45045. export var pbrVertexShader: {
  45046. name: string;
  45047. shader: string;
  45048. };
  45049. }
  45050. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45051. import { IAnimatable } from "babylonjs/Misc/tools";
  45052. import { Nullable } from "babylonjs/types";
  45053. import { Scene } from "babylonjs/scene";
  45054. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45055. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45057. import { Mesh } from "babylonjs/Meshes/mesh";
  45058. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45059. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45060. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45061. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45062. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45063. import { Material } from "babylonjs/Materials/material";
  45064. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45065. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45066. import "babylonjs/Shaders/pbr.fragment";
  45067. import "babylonjs/Shaders/pbr.vertex";
  45068. /**
  45069. * The Physically based material base class of BJS.
  45070. *
  45071. * This offers the main features of a standard PBR material.
  45072. * For more information, please refer to the documentation :
  45073. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45074. */
  45075. export abstract class PBRBaseMaterial extends PushMaterial {
  45076. /**
  45077. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45078. */
  45079. static readonly PBRMATERIAL_OPAQUE: number;
  45080. /**
  45081. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45082. */
  45083. static readonly PBRMATERIAL_ALPHATEST: number;
  45084. /**
  45085. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45086. */
  45087. static readonly PBRMATERIAL_ALPHABLEND: number;
  45088. /**
  45089. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45090. * They are also discarded below the alpha cutoff threshold to improve performances.
  45091. */
  45092. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45093. /**
  45094. * Defines the default value of how much AO map is occluding the analytical lights
  45095. * (point spot...).
  45096. */
  45097. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45098. /**
  45099. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45100. */
  45101. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45102. /**
  45103. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45104. * to enhance interoperability with other engines.
  45105. */
  45106. static readonly LIGHTFALLOFF_GLTF: number;
  45107. /**
  45108. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45109. * to enhance interoperability with other materials.
  45110. */
  45111. static readonly LIGHTFALLOFF_STANDARD: number;
  45112. /**
  45113. * Intensity of the direct lights e.g. the four lights available in your scene.
  45114. * This impacts both the direct diffuse and specular highlights.
  45115. */
  45116. protected _directIntensity: number;
  45117. /**
  45118. * Intensity of the emissive part of the material.
  45119. * This helps controlling the emissive effect without modifying the emissive color.
  45120. */
  45121. protected _emissiveIntensity: number;
  45122. /**
  45123. * Intensity of the environment e.g. how much the environment will light the object
  45124. * either through harmonics for rough material or through the refelction for shiny ones.
  45125. */
  45126. protected _environmentIntensity: number;
  45127. /**
  45128. * This is a special control allowing the reduction of the specular highlights coming from the
  45129. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45130. */
  45131. protected _specularIntensity: number;
  45132. /**
  45133. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45134. */
  45135. private _lightingInfos;
  45136. /**
  45137. * Debug Control allowing disabling the bump map on this material.
  45138. */
  45139. protected _disableBumpMap: boolean;
  45140. /**
  45141. * AKA Diffuse Texture in standard nomenclature.
  45142. */
  45143. protected _albedoTexture: BaseTexture;
  45144. /**
  45145. * AKA Occlusion Texture in other nomenclature.
  45146. */
  45147. protected _ambientTexture: BaseTexture;
  45148. /**
  45149. * AKA Occlusion Texture Intensity in other nomenclature.
  45150. */
  45151. protected _ambientTextureStrength: number;
  45152. /**
  45153. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45154. * 1 means it completely occludes it
  45155. * 0 mean it has no impact
  45156. */
  45157. protected _ambientTextureImpactOnAnalyticalLights: number;
  45158. /**
  45159. * Stores the alpha values in a texture.
  45160. */
  45161. protected _opacityTexture: BaseTexture;
  45162. /**
  45163. * Stores the reflection values in a texture.
  45164. */
  45165. protected _reflectionTexture: BaseTexture;
  45166. /**
  45167. * Stores the refraction values in a texture.
  45168. */
  45169. protected _refractionTexture: BaseTexture;
  45170. /**
  45171. * Stores the emissive values in a texture.
  45172. */
  45173. protected _emissiveTexture: BaseTexture;
  45174. /**
  45175. * AKA Specular texture in other nomenclature.
  45176. */
  45177. protected _reflectivityTexture: BaseTexture;
  45178. /**
  45179. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45180. */
  45181. protected _metallicTexture: BaseTexture;
  45182. /**
  45183. * Specifies the metallic scalar of the metallic/roughness workflow.
  45184. * Can also be used to scale the metalness values of the metallic texture.
  45185. */
  45186. protected _metallic: Nullable<number>;
  45187. /**
  45188. * Specifies the roughness scalar of the metallic/roughness workflow.
  45189. * Can also be used to scale the roughness values of the metallic texture.
  45190. */
  45191. protected _roughness: Nullable<number>;
  45192. /**
  45193. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45194. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45195. */
  45196. protected _microSurfaceTexture: BaseTexture;
  45197. /**
  45198. * Stores surface normal data used to displace a mesh in a texture.
  45199. */
  45200. protected _bumpTexture: BaseTexture;
  45201. /**
  45202. * Stores the pre-calculated light information of a mesh in a texture.
  45203. */
  45204. protected _lightmapTexture: BaseTexture;
  45205. /**
  45206. * The color of a material in ambient lighting.
  45207. */
  45208. protected _ambientColor: Color3;
  45209. /**
  45210. * AKA Diffuse Color in other nomenclature.
  45211. */
  45212. protected _albedoColor: Color3;
  45213. /**
  45214. * AKA Specular Color in other nomenclature.
  45215. */
  45216. protected _reflectivityColor: Color3;
  45217. /**
  45218. * The color applied when light is reflected from a material.
  45219. */
  45220. protected _reflectionColor: Color3;
  45221. /**
  45222. * The color applied when light is emitted from a material.
  45223. */
  45224. protected _emissiveColor: Color3;
  45225. /**
  45226. * AKA Glossiness in other nomenclature.
  45227. */
  45228. protected _microSurface: number;
  45229. /**
  45230. * source material index of refraction (IOR)' / 'destination material IOR.
  45231. */
  45232. protected _indexOfRefraction: number;
  45233. /**
  45234. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45235. */
  45236. protected _invertRefractionY: boolean;
  45237. /**
  45238. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45239. * Materials half opaque for instance using refraction could benefit from this control.
  45240. */
  45241. protected _linkRefractionWithTransparency: boolean;
  45242. /**
  45243. * Specifies that the material will use the light map as a show map.
  45244. */
  45245. protected _useLightmapAsShadowmap: boolean;
  45246. /**
  45247. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45248. * makes the reflect vector face the model (under horizon).
  45249. */
  45250. protected _useHorizonOcclusion: boolean;
  45251. /**
  45252. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45253. * too much the area relying on ambient texture to define their ambient occlusion.
  45254. */
  45255. protected _useRadianceOcclusion: boolean;
  45256. /**
  45257. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45258. */
  45259. protected _useAlphaFromAlbedoTexture: boolean;
  45260. /**
  45261. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45262. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45263. */
  45264. protected _useSpecularOverAlpha: boolean;
  45265. /**
  45266. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45267. */
  45268. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45269. /**
  45270. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45271. */
  45272. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45273. /**
  45274. * Specifies if the metallic texture contains the roughness information in its green channel.
  45275. */
  45276. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45277. /**
  45278. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45279. */
  45280. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45281. /**
  45282. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45283. */
  45284. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45285. /**
  45286. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45287. */
  45288. protected _useAmbientInGrayScale: boolean;
  45289. /**
  45290. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45291. * The material will try to infer what glossiness each pixel should be.
  45292. */
  45293. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45294. /**
  45295. * Defines the falloff type used in this material.
  45296. * It by default is Physical.
  45297. */
  45298. protected _lightFalloff: number;
  45299. /**
  45300. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45301. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45302. */
  45303. protected _useRadianceOverAlpha: boolean;
  45304. /**
  45305. * Allows using an object space normal map (instead of tangent space).
  45306. */
  45307. protected _useObjectSpaceNormalMap: boolean;
  45308. /**
  45309. * Allows using the bump map in parallax mode.
  45310. */
  45311. protected _useParallax: boolean;
  45312. /**
  45313. * Allows using the bump map in parallax occlusion mode.
  45314. */
  45315. protected _useParallaxOcclusion: boolean;
  45316. /**
  45317. * Controls the scale bias of the parallax mode.
  45318. */
  45319. protected _parallaxScaleBias: number;
  45320. /**
  45321. * If sets to true, disables all the lights affecting the material.
  45322. */
  45323. protected _disableLighting: boolean;
  45324. /**
  45325. * Number of Simultaneous lights allowed on the material.
  45326. */
  45327. protected _maxSimultaneousLights: number;
  45328. /**
  45329. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45330. */
  45331. protected _invertNormalMapX: boolean;
  45332. /**
  45333. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45334. */
  45335. protected _invertNormalMapY: boolean;
  45336. /**
  45337. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45338. */
  45339. protected _twoSidedLighting: boolean;
  45340. /**
  45341. * Defines the alpha limits in alpha test mode.
  45342. */
  45343. protected _alphaCutOff: number;
  45344. /**
  45345. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45346. */
  45347. protected _forceAlphaTest: boolean;
  45348. /**
  45349. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45350. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45351. */
  45352. protected _useAlphaFresnel: boolean;
  45353. /**
  45354. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45355. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45356. */
  45357. protected _useLinearAlphaFresnel: boolean;
  45358. /**
  45359. * The transparency mode of the material.
  45360. */
  45361. protected _transparencyMode: Nullable<number>;
  45362. /**
  45363. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45364. * from cos thetav and roughness:
  45365. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45366. */
  45367. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45368. /**
  45369. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45370. */
  45371. protected _forceIrradianceInFragment: boolean;
  45372. /**
  45373. * Force normal to face away from face.
  45374. */
  45375. protected _forceNormalForward: boolean;
  45376. /**
  45377. * Enables specular anti aliasing in the PBR shader.
  45378. * It will both interacts on the Geometry for analytical and IBL lighting.
  45379. * It also prefilter the roughness map based on the bump values.
  45380. */
  45381. protected _enableSpecularAntiAliasing: boolean;
  45382. /**
  45383. * Default configuration related to image processing available in the PBR Material.
  45384. */
  45385. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45386. /**
  45387. * Keep track of the image processing observer to allow dispose and replace.
  45388. */
  45389. private _imageProcessingObserver;
  45390. /**
  45391. * Attaches a new image processing configuration to the PBR Material.
  45392. * @param configuration
  45393. */
  45394. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45395. /**
  45396. * Stores the available render targets.
  45397. */
  45398. private _renderTargets;
  45399. /**
  45400. * Sets the global ambient color for the material used in lighting calculations.
  45401. */
  45402. private _globalAmbientColor;
  45403. /**
  45404. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45405. */
  45406. private _useLogarithmicDepth;
  45407. /**
  45408. * If set to true, no lighting calculations will be applied.
  45409. */
  45410. private _unlit;
  45411. private _debugMode;
  45412. /**
  45413. * @hidden
  45414. * This is reserved for the inspector.
  45415. * Defines the material debug mode.
  45416. * It helps seeing only some components of the material while troubleshooting.
  45417. */
  45418. debugMode: number;
  45419. /**
  45420. * @hidden
  45421. * This is reserved for the inspector.
  45422. * Specify from where on screen the debug mode should start.
  45423. * The value goes from -1 (full screen) to 1 (not visible)
  45424. * It helps with side by side comparison against the final render
  45425. * This defaults to -1
  45426. */
  45427. private debugLimit;
  45428. /**
  45429. * @hidden
  45430. * This is reserved for the inspector.
  45431. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45432. * You can use the factor to better multiply the final value.
  45433. */
  45434. private debugFactor;
  45435. /**
  45436. * Defines the clear coat layer parameters for the material.
  45437. */
  45438. readonly clearCoat: PBRClearCoatConfiguration;
  45439. /**
  45440. * Defines the anisotropic parameters for the material.
  45441. */
  45442. readonly anisotropy: PBRAnisotropicConfiguration;
  45443. /**
  45444. * Defines the BRDF parameters for the material.
  45445. */
  45446. readonly brdf: PBRBRDFConfiguration;
  45447. /**
  45448. * Defines the Sheen parameters for the material.
  45449. */
  45450. readonly sheen: PBRSheenConfiguration;
  45451. /**
  45452. * Instantiates a new PBRMaterial instance.
  45453. *
  45454. * @param name The material name
  45455. * @param scene The scene the material will be use in.
  45456. */
  45457. constructor(name: string, scene: Scene);
  45458. /**
  45459. * Gets a boolean indicating that current material needs to register RTT
  45460. */
  45461. readonly hasRenderTargetTextures: boolean;
  45462. /**
  45463. * Gets the name of the material class.
  45464. */
  45465. getClassName(): string;
  45466. /**
  45467. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45468. */
  45469. /**
  45470. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45471. */
  45472. useLogarithmicDepth: boolean;
  45473. /**
  45474. * Gets the current transparency mode.
  45475. */
  45476. /**
  45477. * Sets the transparency mode of the material.
  45478. *
  45479. * | Value | Type | Description |
  45480. * | ----- | ----------------------------------- | ----------- |
  45481. * | 0 | OPAQUE | |
  45482. * | 1 | ALPHATEST | |
  45483. * | 2 | ALPHABLEND | |
  45484. * | 3 | ALPHATESTANDBLEND | |
  45485. *
  45486. */
  45487. transparencyMode: Nullable<number>;
  45488. /**
  45489. * Returns true if alpha blending should be disabled.
  45490. */
  45491. private readonly _disableAlphaBlending;
  45492. /**
  45493. * Specifies whether or not this material should be rendered in alpha blend mode.
  45494. */
  45495. needAlphaBlending(): boolean;
  45496. /**
  45497. * Specifies if the mesh will require alpha blending.
  45498. * @param mesh - BJS mesh.
  45499. */
  45500. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45501. /**
  45502. * Specifies whether or not this material should be rendered in alpha test mode.
  45503. */
  45504. needAlphaTesting(): boolean;
  45505. /**
  45506. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45507. */
  45508. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45509. /**
  45510. * Gets the texture used for the alpha test.
  45511. */
  45512. getAlphaTestTexture(): BaseTexture;
  45513. /**
  45514. * Specifies that the submesh is ready to be used.
  45515. * @param mesh - BJS mesh.
  45516. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45517. * @param useInstances - Specifies that instances should be used.
  45518. * @returns - boolean indicating that the submesh is ready or not.
  45519. */
  45520. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45521. /**
  45522. * Specifies if the material uses metallic roughness workflow.
  45523. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45524. */
  45525. isMetallicWorkflow(): boolean;
  45526. private _prepareEffect;
  45527. private _prepareDefines;
  45528. /**
  45529. * Force shader compilation
  45530. */
  45531. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45532. clipPlane: boolean;
  45533. }>): void;
  45534. /**
  45535. * Initializes the uniform buffer layout for the shader.
  45536. */
  45537. buildUniformLayout(): void;
  45538. /**
  45539. * Unbinds the textures.
  45540. */
  45541. unbind(): void;
  45542. /**
  45543. * Binds the submesh data.
  45544. * @param world - The world matrix.
  45545. * @param mesh - The BJS mesh.
  45546. * @param subMesh - A submesh of the BJS mesh.
  45547. */
  45548. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45549. /**
  45550. * Returns the animatable textures.
  45551. * @returns - Array of animatable textures.
  45552. */
  45553. getAnimatables(): IAnimatable[];
  45554. /**
  45555. * Returns the texture used for reflections.
  45556. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45557. */
  45558. private _getReflectionTexture;
  45559. /**
  45560. * Returns the texture used for refraction or null if none is used.
  45561. * @returns - Refection texture if present. If no refraction texture and refraction
  45562. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45563. */
  45564. private _getRefractionTexture;
  45565. /**
  45566. * Returns an array of the actively used textures.
  45567. * @returns - Array of BaseTextures
  45568. */
  45569. getActiveTextures(): BaseTexture[];
  45570. /**
  45571. * Checks to see if a texture is used in the material.
  45572. * @param texture - Base texture to use.
  45573. * @returns - Boolean specifying if a texture is used in the material.
  45574. */
  45575. hasTexture(texture: BaseTexture): boolean;
  45576. /**
  45577. * Disposes the resources of the material.
  45578. * @param forceDisposeEffect - Forces the disposal of effects.
  45579. * @param forceDisposeTextures - Forces the disposal of all textures.
  45580. */
  45581. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45582. }
  45583. }
  45584. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45585. import { Nullable } from "babylonjs/types";
  45586. import { Scene } from "babylonjs/scene";
  45587. import { Color3 } from "babylonjs/Maths/math";
  45588. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45589. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45591. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45592. /**
  45593. * The Physically based material of BJS.
  45594. *
  45595. * This offers the main features of a standard PBR material.
  45596. * For more information, please refer to the documentation :
  45597. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45598. */
  45599. export class PBRMaterial extends PBRBaseMaterial {
  45600. /**
  45601. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45602. */
  45603. static readonly PBRMATERIAL_OPAQUE: number;
  45604. /**
  45605. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45606. */
  45607. static readonly PBRMATERIAL_ALPHATEST: number;
  45608. /**
  45609. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45610. */
  45611. static readonly PBRMATERIAL_ALPHABLEND: number;
  45612. /**
  45613. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45614. * They are also discarded below the alpha cutoff threshold to improve performances.
  45615. */
  45616. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45617. /**
  45618. * Defines the default value of how much AO map is occluding the analytical lights
  45619. * (point spot...).
  45620. */
  45621. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45622. /**
  45623. * Intensity of the direct lights e.g. the four lights available in your scene.
  45624. * This impacts both the direct diffuse and specular highlights.
  45625. */
  45626. directIntensity: number;
  45627. /**
  45628. * Intensity of the emissive part of the material.
  45629. * This helps controlling the emissive effect without modifying the emissive color.
  45630. */
  45631. emissiveIntensity: number;
  45632. /**
  45633. * Intensity of the environment e.g. how much the environment will light the object
  45634. * either through harmonics for rough material or through the refelction for shiny ones.
  45635. */
  45636. environmentIntensity: number;
  45637. /**
  45638. * This is a special control allowing the reduction of the specular highlights coming from the
  45639. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45640. */
  45641. specularIntensity: number;
  45642. /**
  45643. * Debug Control allowing disabling the bump map on this material.
  45644. */
  45645. disableBumpMap: boolean;
  45646. /**
  45647. * AKA Diffuse Texture in standard nomenclature.
  45648. */
  45649. albedoTexture: BaseTexture;
  45650. /**
  45651. * AKA Occlusion Texture in other nomenclature.
  45652. */
  45653. ambientTexture: BaseTexture;
  45654. /**
  45655. * AKA Occlusion Texture Intensity in other nomenclature.
  45656. */
  45657. ambientTextureStrength: number;
  45658. /**
  45659. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45660. * 1 means it completely occludes it
  45661. * 0 mean it has no impact
  45662. */
  45663. ambientTextureImpactOnAnalyticalLights: number;
  45664. /**
  45665. * Stores the alpha values in a texture.
  45666. */
  45667. opacityTexture: BaseTexture;
  45668. /**
  45669. * Stores the reflection values in a texture.
  45670. */
  45671. reflectionTexture: Nullable<BaseTexture>;
  45672. /**
  45673. * Stores the emissive values in a texture.
  45674. */
  45675. emissiveTexture: BaseTexture;
  45676. /**
  45677. * AKA Specular texture in other nomenclature.
  45678. */
  45679. reflectivityTexture: BaseTexture;
  45680. /**
  45681. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45682. */
  45683. metallicTexture: BaseTexture;
  45684. /**
  45685. * Specifies the metallic scalar of the metallic/roughness workflow.
  45686. * Can also be used to scale the metalness values of the metallic texture.
  45687. */
  45688. metallic: Nullable<number>;
  45689. /**
  45690. * Specifies the roughness scalar of the metallic/roughness workflow.
  45691. * Can also be used to scale the roughness values of the metallic texture.
  45692. */
  45693. roughness: Nullable<number>;
  45694. /**
  45695. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45696. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45697. */
  45698. microSurfaceTexture: BaseTexture;
  45699. /**
  45700. * Stores surface normal data used to displace a mesh in a texture.
  45701. */
  45702. bumpTexture: BaseTexture;
  45703. /**
  45704. * Stores the pre-calculated light information of a mesh in a texture.
  45705. */
  45706. lightmapTexture: BaseTexture;
  45707. /**
  45708. * Stores the refracted light information in a texture.
  45709. */
  45710. refractionTexture: BaseTexture;
  45711. /**
  45712. * The color of a material in ambient lighting.
  45713. */
  45714. ambientColor: Color3;
  45715. /**
  45716. * AKA Diffuse Color in other nomenclature.
  45717. */
  45718. albedoColor: Color3;
  45719. /**
  45720. * AKA Specular Color in other nomenclature.
  45721. */
  45722. reflectivityColor: Color3;
  45723. /**
  45724. * The color reflected from the material.
  45725. */
  45726. reflectionColor: Color3;
  45727. /**
  45728. * The color emitted from the material.
  45729. */
  45730. emissiveColor: Color3;
  45731. /**
  45732. * AKA Glossiness in other nomenclature.
  45733. */
  45734. microSurface: number;
  45735. /**
  45736. * source material index of refraction (IOR)' / 'destination material IOR.
  45737. */
  45738. indexOfRefraction: number;
  45739. /**
  45740. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45741. */
  45742. invertRefractionY: boolean;
  45743. /**
  45744. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45745. * Materials half opaque for instance using refraction could benefit from this control.
  45746. */
  45747. linkRefractionWithTransparency: boolean;
  45748. /**
  45749. * If true, the light map contains occlusion information instead of lighting info.
  45750. */
  45751. useLightmapAsShadowmap: boolean;
  45752. /**
  45753. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45754. */
  45755. useAlphaFromAlbedoTexture: boolean;
  45756. /**
  45757. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45758. */
  45759. forceAlphaTest: boolean;
  45760. /**
  45761. * Defines the alpha limits in alpha test mode.
  45762. */
  45763. alphaCutOff: number;
  45764. /**
  45765. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45766. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45767. */
  45768. useSpecularOverAlpha: boolean;
  45769. /**
  45770. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45771. */
  45772. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45773. /**
  45774. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45775. */
  45776. useRoughnessFromMetallicTextureAlpha: boolean;
  45777. /**
  45778. * Specifies if the metallic texture contains the roughness information in its green channel.
  45779. */
  45780. useRoughnessFromMetallicTextureGreen: boolean;
  45781. /**
  45782. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45783. */
  45784. useMetallnessFromMetallicTextureBlue: boolean;
  45785. /**
  45786. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45787. */
  45788. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45789. /**
  45790. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45791. */
  45792. useAmbientInGrayScale: boolean;
  45793. /**
  45794. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45795. * The material will try to infer what glossiness each pixel should be.
  45796. */
  45797. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45798. /**
  45799. * BJS is using an harcoded light falloff based on a manually sets up range.
  45800. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45801. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45802. */
  45803. /**
  45804. * BJS is using an harcoded light falloff based on a manually sets up range.
  45805. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45806. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45807. */
  45808. usePhysicalLightFalloff: boolean;
  45809. /**
  45810. * In order to support the falloff compatibility with gltf, a special mode has been added
  45811. * to reproduce the gltf light falloff.
  45812. */
  45813. /**
  45814. * In order to support the falloff compatibility with gltf, a special mode has been added
  45815. * to reproduce the gltf light falloff.
  45816. */
  45817. useGLTFLightFalloff: boolean;
  45818. /**
  45819. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45820. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45821. */
  45822. useRadianceOverAlpha: boolean;
  45823. /**
  45824. * Allows using an object space normal map (instead of tangent space).
  45825. */
  45826. useObjectSpaceNormalMap: boolean;
  45827. /**
  45828. * Allows using the bump map in parallax mode.
  45829. */
  45830. useParallax: boolean;
  45831. /**
  45832. * Allows using the bump map in parallax occlusion mode.
  45833. */
  45834. useParallaxOcclusion: boolean;
  45835. /**
  45836. * Controls the scale bias of the parallax mode.
  45837. */
  45838. parallaxScaleBias: number;
  45839. /**
  45840. * If sets to true, disables all the lights affecting the material.
  45841. */
  45842. disableLighting: boolean;
  45843. /**
  45844. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45845. */
  45846. forceIrradianceInFragment: boolean;
  45847. /**
  45848. * Number of Simultaneous lights allowed on the material.
  45849. */
  45850. maxSimultaneousLights: number;
  45851. /**
  45852. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45853. */
  45854. invertNormalMapX: boolean;
  45855. /**
  45856. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45857. */
  45858. invertNormalMapY: boolean;
  45859. /**
  45860. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45861. */
  45862. twoSidedLighting: boolean;
  45863. /**
  45864. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45865. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45866. */
  45867. useAlphaFresnel: boolean;
  45868. /**
  45869. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45870. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45871. */
  45872. useLinearAlphaFresnel: boolean;
  45873. /**
  45874. * Let user defines the brdf lookup texture used for IBL.
  45875. * A default 8bit version is embedded but you could point at :
  45876. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45877. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45878. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45879. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45880. */
  45881. environmentBRDFTexture: Nullable<BaseTexture>;
  45882. /**
  45883. * Force normal to face away from face.
  45884. */
  45885. forceNormalForward: boolean;
  45886. /**
  45887. * Enables specular anti aliasing in the PBR shader.
  45888. * It will both interacts on the Geometry for analytical and IBL lighting.
  45889. * It also prefilter the roughness map based on the bump values.
  45890. */
  45891. enableSpecularAntiAliasing: boolean;
  45892. /**
  45893. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45894. * makes the reflect vector face the model (under horizon).
  45895. */
  45896. useHorizonOcclusion: boolean;
  45897. /**
  45898. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45899. * too much the area relying on ambient texture to define their ambient occlusion.
  45900. */
  45901. useRadianceOcclusion: boolean;
  45902. /**
  45903. * If set to true, no lighting calculations will be applied.
  45904. */
  45905. unlit: boolean;
  45906. /**
  45907. * Gets the image processing configuration used either in this material.
  45908. */
  45909. /**
  45910. * Sets the Default image processing configuration used either in the this material.
  45911. *
  45912. * If sets to null, the scene one is in use.
  45913. */
  45914. imageProcessingConfiguration: ImageProcessingConfiguration;
  45915. /**
  45916. * Gets wether the color curves effect is enabled.
  45917. */
  45918. /**
  45919. * Sets wether the color curves effect is enabled.
  45920. */
  45921. cameraColorCurvesEnabled: boolean;
  45922. /**
  45923. * Gets wether the color grading effect is enabled.
  45924. */
  45925. /**
  45926. * Gets wether the color grading effect is enabled.
  45927. */
  45928. cameraColorGradingEnabled: boolean;
  45929. /**
  45930. * Gets wether tonemapping is enabled or not.
  45931. */
  45932. /**
  45933. * Sets wether tonemapping is enabled or not
  45934. */
  45935. cameraToneMappingEnabled: boolean;
  45936. /**
  45937. * The camera exposure used on this material.
  45938. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45939. * This corresponds to a photographic exposure.
  45940. */
  45941. /**
  45942. * The camera exposure used on this material.
  45943. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45944. * This corresponds to a photographic exposure.
  45945. */
  45946. cameraExposure: number;
  45947. /**
  45948. * Gets The camera contrast used on this material.
  45949. */
  45950. /**
  45951. * Sets The camera contrast used on this material.
  45952. */
  45953. cameraContrast: number;
  45954. /**
  45955. * Gets the Color Grading 2D Lookup Texture.
  45956. */
  45957. /**
  45958. * Sets the Color Grading 2D Lookup Texture.
  45959. */
  45960. cameraColorGradingTexture: Nullable<BaseTexture>;
  45961. /**
  45962. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45963. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45964. * 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;
  45965. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45966. */
  45967. /**
  45968. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45969. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45970. * 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;
  45971. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45972. */
  45973. cameraColorCurves: Nullable<ColorCurves>;
  45974. /**
  45975. * Instantiates a new PBRMaterial instance.
  45976. *
  45977. * @param name The material name
  45978. * @param scene The scene the material will be use in.
  45979. */
  45980. constructor(name: string, scene: Scene);
  45981. /**
  45982. * Returns the name of this material class.
  45983. */
  45984. getClassName(): string;
  45985. /**
  45986. * Makes a duplicate of the current material.
  45987. * @param name - name to use for the new material.
  45988. */
  45989. clone(name: string): PBRMaterial;
  45990. /**
  45991. * Serializes this PBR Material.
  45992. * @returns - An object with the serialized material.
  45993. */
  45994. serialize(): any;
  45995. /**
  45996. * Parses a PBR Material from a serialized object.
  45997. * @param source - Serialized object.
  45998. * @param scene - BJS scene instance.
  45999. * @param rootUrl - url for the scene object
  46000. * @returns - PBRMaterial
  46001. */
  46002. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46003. }
  46004. }
  46005. declare module "babylonjs/Misc/dds" {
  46006. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46007. import { Engine } from "babylonjs/Engines/engine";
  46008. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46009. import { Nullable } from "babylonjs/types";
  46010. import { Scene } from "babylonjs/scene";
  46011. /**
  46012. * Direct draw surface info
  46013. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46014. */
  46015. export interface DDSInfo {
  46016. /**
  46017. * Width of the texture
  46018. */
  46019. width: number;
  46020. /**
  46021. * Width of the texture
  46022. */
  46023. height: number;
  46024. /**
  46025. * Number of Mipmaps for the texture
  46026. * @see https://en.wikipedia.org/wiki/Mipmap
  46027. */
  46028. mipmapCount: number;
  46029. /**
  46030. * If the textures format is a known fourCC format
  46031. * @see https://www.fourcc.org/
  46032. */
  46033. isFourCC: boolean;
  46034. /**
  46035. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46036. */
  46037. isRGB: boolean;
  46038. /**
  46039. * If the texture is a lumincance format
  46040. */
  46041. isLuminance: boolean;
  46042. /**
  46043. * If this is a cube texture
  46044. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46045. */
  46046. isCube: boolean;
  46047. /**
  46048. * If the texture is a compressed format eg. FOURCC_DXT1
  46049. */
  46050. isCompressed: boolean;
  46051. /**
  46052. * The dxgiFormat of the texture
  46053. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46054. */
  46055. dxgiFormat: number;
  46056. /**
  46057. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46058. */
  46059. textureType: number;
  46060. /**
  46061. * Sphericle polynomial created for the dds texture
  46062. */
  46063. sphericalPolynomial?: SphericalPolynomial;
  46064. }
  46065. /**
  46066. * Class used to provide DDS decompression tools
  46067. */
  46068. export class DDSTools {
  46069. /**
  46070. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46071. */
  46072. static StoreLODInAlphaChannel: boolean;
  46073. /**
  46074. * Gets DDS information from an array buffer
  46075. * @param arrayBuffer defines the array buffer to read data from
  46076. * @returns the DDS information
  46077. */
  46078. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46079. private static _FloatView;
  46080. private static _Int32View;
  46081. private static _ToHalfFloat;
  46082. private static _FromHalfFloat;
  46083. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46084. private static _GetHalfFloatRGBAArrayBuffer;
  46085. private static _GetFloatRGBAArrayBuffer;
  46086. private static _GetFloatAsUIntRGBAArrayBuffer;
  46087. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46088. private static _GetRGBAArrayBuffer;
  46089. private static _ExtractLongWordOrder;
  46090. private static _GetRGBArrayBuffer;
  46091. private static _GetLuminanceArrayBuffer;
  46092. /**
  46093. * Uploads DDS Levels to a Babylon Texture
  46094. * @hidden
  46095. */
  46096. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46097. }
  46098. module "babylonjs/Engines/engine" {
  46099. interface Engine {
  46100. /**
  46101. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46102. * @param rootUrl defines the url where the file to load is located
  46103. * @param scene defines the current scene
  46104. * @param lodScale defines scale to apply to the mip map selection
  46105. * @param lodOffset defines offset to apply to the mip map selection
  46106. * @param onLoad defines an optional callback raised when the texture is loaded
  46107. * @param onError defines an optional callback raised if there is an issue to load the texture
  46108. * @param format defines the format of the data
  46109. * @param forcedExtension defines the extension to use to pick the right loader
  46110. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46111. * @returns the cube texture as an InternalTexture
  46112. */
  46113. 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;
  46114. }
  46115. }
  46116. }
  46117. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46118. import { Nullable } from "babylonjs/types";
  46119. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46120. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46121. /**
  46122. * Implementation of the DDS Texture Loader.
  46123. * @hidden
  46124. */
  46125. export class _DDSTextureLoader implements IInternalTextureLoader {
  46126. /**
  46127. * Defines wether the loader supports cascade loading the different faces.
  46128. */
  46129. readonly supportCascades: boolean;
  46130. /**
  46131. * This returns if the loader support the current file information.
  46132. * @param extension defines the file extension of the file being loaded
  46133. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46134. * @param fallback defines the fallback internal texture if any
  46135. * @param isBase64 defines whether the texture is encoded as a base64
  46136. * @param isBuffer defines whether the texture data are stored as a buffer
  46137. * @returns true if the loader can load the specified file
  46138. */
  46139. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46140. /**
  46141. * Transform the url before loading if required.
  46142. * @param rootUrl the url of the texture
  46143. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46144. * @returns the transformed texture
  46145. */
  46146. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46147. /**
  46148. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46149. * @param rootUrl the url of the texture
  46150. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46151. * @returns the fallback texture
  46152. */
  46153. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46154. /**
  46155. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46156. * @param data contains the texture data
  46157. * @param texture defines the BabylonJS internal texture
  46158. * @param createPolynomials will be true if polynomials have been requested
  46159. * @param onLoad defines the callback to trigger once the texture is ready
  46160. * @param onError defines the callback to trigger in case of error
  46161. */
  46162. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46163. /**
  46164. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46165. * @param data contains the texture data
  46166. * @param texture defines the BabylonJS internal texture
  46167. * @param callback defines the method to call once ready to upload
  46168. */
  46169. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46170. }
  46171. }
  46172. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46173. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46174. /** @hidden */
  46175. export var rgbdEncodePixelShader: {
  46176. name: string;
  46177. shader: string;
  46178. };
  46179. }
  46180. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46181. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46182. /** @hidden */
  46183. export var rgbdDecodePixelShader: {
  46184. name: string;
  46185. shader: string;
  46186. };
  46187. }
  46188. declare module "babylonjs/Misc/environmentTextureTools" {
  46189. import { Nullable } from "babylonjs/types";
  46190. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46191. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46192. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46193. import "babylonjs/Shaders/rgbdEncode.fragment";
  46194. import "babylonjs/Shaders/rgbdDecode.fragment";
  46195. /**
  46196. * Raw texture data and descriptor sufficient for WebGL texture upload
  46197. */
  46198. export interface EnvironmentTextureInfo {
  46199. /**
  46200. * Version of the environment map
  46201. */
  46202. version: number;
  46203. /**
  46204. * Width of image
  46205. */
  46206. width: number;
  46207. /**
  46208. * Irradiance information stored in the file.
  46209. */
  46210. irradiance: any;
  46211. /**
  46212. * Specular information stored in the file.
  46213. */
  46214. specular: any;
  46215. }
  46216. /**
  46217. * Sets of helpers addressing the serialization and deserialization of environment texture
  46218. * stored in a BabylonJS env file.
  46219. * Those files are usually stored as .env files.
  46220. */
  46221. export class EnvironmentTextureTools {
  46222. /**
  46223. * Magic number identifying the env file.
  46224. */
  46225. private static _MagicBytes;
  46226. /**
  46227. * Gets the environment info from an env file.
  46228. * @param data The array buffer containing the .env bytes.
  46229. * @returns the environment file info (the json header) if successfully parsed.
  46230. */
  46231. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46232. /**
  46233. * Creates an environment texture from a loaded cube texture.
  46234. * @param texture defines the cube texture to convert in env file
  46235. * @return a promise containing the environment data if succesfull.
  46236. */
  46237. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46238. /**
  46239. * Creates a JSON representation of the spherical data.
  46240. * @param texture defines the texture containing the polynomials
  46241. * @return the JSON representation of the spherical info
  46242. */
  46243. private static _CreateEnvTextureIrradiance;
  46244. /**
  46245. * Uploads the texture info contained in the env file to the GPU.
  46246. * @param texture defines the internal texture to upload to
  46247. * @param arrayBuffer defines the buffer cotaining the data to load
  46248. * @param info defines the texture info retrieved through the GetEnvInfo method
  46249. * @returns a promise
  46250. */
  46251. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46252. /**
  46253. * Uploads the levels of image data to the GPU.
  46254. * @param texture defines the internal texture to upload to
  46255. * @param imageData defines the array buffer views of image data [mipmap][face]
  46256. * @returns a promise
  46257. */
  46258. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46259. /**
  46260. * Uploads spherical polynomials information to the texture.
  46261. * @param texture defines the texture we are trying to upload the information to
  46262. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46263. */
  46264. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46265. /** @hidden */
  46266. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46267. }
  46268. }
  46269. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46270. import { Nullable } from "babylonjs/types";
  46271. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46272. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46273. /**
  46274. * Implementation of the ENV Texture Loader.
  46275. * @hidden
  46276. */
  46277. export class _ENVTextureLoader implements IInternalTextureLoader {
  46278. /**
  46279. * Defines wether the loader supports cascade loading the different faces.
  46280. */
  46281. readonly supportCascades: boolean;
  46282. /**
  46283. * This returns if the loader support the current file information.
  46284. * @param extension defines the file extension of the file being loaded
  46285. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46286. * @param fallback defines the fallback internal texture if any
  46287. * @param isBase64 defines whether the texture is encoded as a base64
  46288. * @param isBuffer defines whether the texture data are stored as a buffer
  46289. * @returns true if the loader can load the specified file
  46290. */
  46291. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46292. /**
  46293. * Transform the url before loading if required.
  46294. * @param rootUrl the url of the texture
  46295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46296. * @returns the transformed texture
  46297. */
  46298. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46299. /**
  46300. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46301. * @param rootUrl the url of the texture
  46302. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46303. * @returns the fallback texture
  46304. */
  46305. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46306. /**
  46307. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46308. * @param data contains the texture data
  46309. * @param texture defines the BabylonJS internal texture
  46310. * @param createPolynomials will be true if polynomials have been requested
  46311. * @param onLoad defines the callback to trigger once the texture is ready
  46312. * @param onError defines the callback to trigger in case of error
  46313. */
  46314. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46315. /**
  46316. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46317. * @param data contains the texture data
  46318. * @param texture defines the BabylonJS internal texture
  46319. * @param callback defines the method to call once ready to upload
  46320. */
  46321. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46322. }
  46323. }
  46324. declare module "babylonjs/Misc/khronosTextureContainer" {
  46325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46326. /**
  46327. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46328. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46329. */
  46330. export class KhronosTextureContainer {
  46331. /** contents of the KTX container file */
  46332. arrayBuffer: any;
  46333. private static HEADER_LEN;
  46334. private static COMPRESSED_2D;
  46335. private static COMPRESSED_3D;
  46336. private static TEX_2D;
  46337. private static TEX_3D;
  46338. /**
  46339. * Gets the openGL type
  46340. */
  46341. glType: number;
  46342. /**
  46343. * Gets the openGL type size
  46344. */
  46345. glTypeSize: number;
  46346. /**
  46347. * Gets the openGL format
  46348. */
  46349. glFormat: number;
  46350. /**
  46351. * Gets the openGL internal format
  46352. */
  46353. glInternalFormat: number;
  46354. /**
  46355. * Gets the base internal format
  46356. */
  46357. glBaseInternalFormat: number;
  46358. /**
  46359. * Gets image width in pixel
  46360. */
  46361. pixelWidth: number;
  46362. /**
  46363. * Gets image height in pixel
  46364. */
  46365. pixelHeight: number;
  46366. /**
  46367. * Gets image depth in pixels
  46368. */
  46369. pixelDepth: number;
  46370. /**
  46371. * Gets the number of array elements
  46372. */
  46373. numberOfArrayElements: number;
  46374. /**
  46375. * Gets the number of faces
  46376. */
  46377. numberOfFaces: number;
  46378. /**
  46379. * Gets the number of mipmap levels
  46380. */
  46381. numberOfMipmapLevels: number;
  46382. /**
  46383. * Gets the bytes of key value data
  46384. */
  46385. bytesOfKeyValueData: number;
  46386. /**
  46387. * Gets the load type
  46388. */
  46389. loadType: number;
  46390. /**
  46391. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46392. */
  46393. isInvalid: boolean;
  46394. /**
  46395. * Creates a new KhronosTextureContainer
  46396. * @param arrayBuffer contents of the KTX container file
  46397. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46398. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46399. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46400. */
  46401. constructor(
  46402. /** contents of the KTX container file */
  46403. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46404. /**
  46405. * Uploads KTX content to a Babylon Texture.
  46406. * It is assumed that the texture has already been created & is currently bound
  46407. * @hidden
  46408. */
  46409. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46410. private _upload2DCompressedLevels;
  46411. }
  46412. }
  46413. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46414. import { Nullable } from "babylonjs/types";
  46415. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46416. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46417. /**
  46418. * Implementation of the KTX Texture Loader.
  46419. * @hidden
  46420. */
  46421. export class _KTXTextureLoader implements IInternalTextureLoader {
  46422. /**
  46423. * Defines wether the loader supports cascade loading the different faces.
  46424. */
  46425. readonly supportCascades: boolean;
  46426. /**
  46427. * This returns if the loader support the current file information.
  46428. * @param extension defines the file extension of the file being loaded
  46429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46430. * @param fallback defines the fallback internal texture if any
  46431. * @param isBase64 defines whether the texture is encoded as a base64
  46432. * @param isBuffer defines whether the texture data are stored as a buffer
  46433. * @returns true if the loader can load the specified file
  46434. */
  46435. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46436. /**
  46437. * Transform the url before loading if required.
  46438. * @param rootUrl the url of the texture
  46439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46440. * @returns the transformed texture
  46441. */
  46442. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46443. /**
  46444. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46445. * @param rootUrl the url of the texture
  46446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46447. * @returns the fallback texture
  46448. */
  46449. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46450. /**
  46451. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46452. * @param data contains the texture data
  46453. * @param texture defines the BabylonJS internal texture
  46454. * @param createPolynomials will be true if polynomials have been requested
  46455. * @param onLoad defines the callback to trigger once the texture is ready
  46456. * @param onError defines the callback to trigger in case of error
  46457. */
  46458. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46459. /**
  46460. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46461. * @param data contains the texture data
  46462. * @param texture defines the BabylonJS internal texture
  46463. * @param callback defines the method to call once ready to upload
  46464. */
  46465. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46466. }
  46467. }
  46468. declare module "babylonjs/Helpers/sceneHelpers" {
  46469. import { Nullable } from "babylonjs/types";
  46470. import { Mesh } from "babylonjs/Meshes/mesh";
  46471. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46472. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46473. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46474. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46475. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46476. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46477. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46478. import "babylonjs/Meshes/Builders/boxBuilder";
  46479. /** @hidden */
  46480. export var _forceSceneHelpersToBundle: boolean;
  46481. module "babylonjs/scene" {
  46482. interface Scene {
  46483. /**
  46484. * Creates a default light for the scene.
  46485. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46486. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46487. */
  46488. createDefaultLight(replace?: boolean): void;
  46489. /**
  46490. * Creates a default camera for the scene.
  46491. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46492. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46493. * @param replace has default false, when true replaces the active camera in the scene
  46494. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46495. */
  46496. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46497. /**
  46498. * Creates a default camera and a default light.
  46499. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46500. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46501. * @param replace has the default false, when true replaces the active camera/light in the scene
  46502. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46503. */
  46504. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46505. /**
  46506. * Creates a new sky box
  46507. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46508. * @param environmentTexture defines the texture to use as environment texture
  46509. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46510. * @param scale defines the overall scale of the skybox
  46511. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46512. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46513. * @returns a new mesh holding the sky box
  46514. */
  46515. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46516. /**
  46517. * Creates a new environment
  46518. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46519. * @param options defines the options you can use to configure the environment
  46520. * @returns the new EnvironmentHelper
  46521. */
  46522. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46523. /**
  46524. * Creates a new VREXperienceHelper
  46525. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46526. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46527. * @returns a new VREXperienceHelper
  46528. */
  46529. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46530. /**
  46531. * Creates a new XREXperienceHelper
  46532. * @see http://doc.babylonjs.com/how_to/webxr
  46533. * @returns a promise for a new XREXperienceHelper
  46534. */
  46535. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46536. }
  46537. }
  46538. }
  46539. declare module "babylonjs/Helpers/videoDome" {
  46540. import { Scene } from "babylonjs/scene";
  46541. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46542. import { Mesh } from "babylonjs/Meshes/mesh";
  46543. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46544. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46545. import "babylonjs/Meshes/Builders/sphereBuilder";
  46546. /**
  46547. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46548. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46549. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46550. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46551. */
  46552. export class VideoDome extends TransformNode {
  46553. /**
  46554. * Define the video source as a Monoscopic panoramic 360 video.
  46555. */
  46556. static readonly MODE_MONOSCOPIC: number;
  46557. /**
  46558. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46559. */
  46560. static readonly MODE_TOPBOTTOM: number;
  46561. /**
  46562. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46563. */
  46564. static readonly MODE_SIDEBYSIDE: number;
  46565. private _useDirectMapping;
  46566. /**
  46567. * The video texture being displayed on the sphere
  46568. */
  46569. protected _videoTexture: VideoTexture;
  46570. /**
  46571. * Gets the video texture being displayed on the sphere
  46572. */
  46573. readonly videoTexture: VideoTexture;
  46574. /**
  46575. * The skybox material
  46576. */
  46577. protected _material: BackgroundMaterial;
  46578. /**
  46579. * The surface used for the skybox
  46580. */
  46581. protected _mesh: Mesh;
  46582. /**
  46583. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46584. * Also see the options.resolution property.
  46585. */
  46586. fovMultiplier: number;
  46587. private _videoMode;
  46588. /**
  46589. * Gets or set the current video mode for the video. It can be:
  46590. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46591. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46592. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46593. */
  46594. videoMode: number;
  46595. /**
  46596. * Oberserver used in Stereoscopic VR Mode.
  46597. */
  46598. private _onBeforeCameraRenderObserver;
  46599. /**
  46600. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46601. * @param name Element's name, child elements will append suffixes for their own names.
  46602. * @param urlsOrVideo defines the url(s) or the video element to use
  46603. * @param options An object containing optional or exposed sub element properties
  46604. */
  46605. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46606. resolution?: number;
  46607. clickToPlay?: boolean;
  46608. autoPlay?: boolean;
  46609. loop?: boolean;
  46610. size?: number;
  46611. poster?: string;
  46612. useDirectMapping?: boolean;
  46613. }, scene: Scene);
  46614. private _changeVideoMode;
  46615. /**
  46616. * Releases resources associated with this node.
  46617. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46618. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46619. */
  46620. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46621. }
  46622. }
  46623. declare module "babylonjs/Helpers/index" {
  46624. export * from "babylonjs/Helpers/environmentHelper";
  46625. export * from "babylonjs/Helpers/photoDome";
  46626. export * from "babylonjs/Helpers/sceneHelpers";
  46627. export * from "babylonjs/Helpers/videoDome";
  46628. }
  46629. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46630. import { PerfCounter } from "babylonjs/Misc/tools";
  46631. import { IDisposable } from "babylonjs/scene";
  46632. import { Engine } from "babylonjs/Engines/engine";
  46633. /**
  46634. * This class can be used to get instrumentation data from a Babylon engine
  46635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46636. */
  46637. export class EngineInstrumentation implements IDisposable {
  46638. /**
  46639. * Define the instrumented engine.
  46640. */
  46641. engine: Engine;
  46642. private _captureGPUFrameTime;
  46643. private _gpuFrameTimeToken;
  46644. private _gpuFrameTime;
  46645. private _captureShaderCompilationTime;
  46646. private _shaderCompilationTime;
  46647. private _onBeginFrameObserver;
  46648. private _onEndFrameObserver;
  46649. private _onBeforeShaderCompilationObserver;
  46650. private _onAfterShaderCompilationObserver;
  46651. /**
  46652. * Gets the perf counter used for GPU frame time
  46653. */
  46654. readonly gpuFrameTimeCounter: PerfCounter;
  46655. /**
  46656. * Gets the GPU frame time capture status
  46657. */
  46658. /**
  46659. * Enable or disable the GPU frame time capture
  46660. */
  46661. captureGPUFrameTime: boolean;
  46662. /**
  46663. * Gets the perf counter used for shader compilation time
  46664. */
  46665. readonly shaderCompilationTimeCounter: PerfCounter;
  46666. /**
  46667. * Gets the shader compilation time capture status
  46668. */
  46669. /**
  46670. * Enable or disable the shader compilation time capture
  46671. */
  46672. captureShaderCompilationTime: boolean;
  46673. /**
  46674. * Instantiates a new engine instrumentation.
  46675. * This class can be used to get instrumentation data from a Babylon engine
  46676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46677. * @param engine Defines the engine to instrument
  46678. */
  46679. constructor(
  46680. /**
  46681. * Define the instrumented engine.
  46682. */
  46683. engine: Engine);
  46684. /**
  46685. * Dispose and release associated resources.
  46686. */
  46687. dispose(): void;
  46688. }
  46689. }
  46690. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46691. import { PerfCounter } from "babylonjs/Misc/tools";
  46692. import { Scene, IDisposable } from "babylonjs/scene";
  46693. /**
  46694. * This class can be used to get instrumentation data from a Babylon engine
  46695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46696. */
  46697. export class SceneInstrumentation implements IDisposable {
  46698. /**
  46699. * Defines the scene to instrument
  46700. */
  46701. scene: Scene;
  46702. private _captureActiveMeshesEvaluationTime;
  46703. private _activeMeshesEvaluationTime;
  46704. private _captureRenderTargetsRenderTime;
  46705. private _renderTargetsRenderTime;
  46706. private _captureFrameTime;
  46707. private _frameTime;
  46708. private _captureRenderTime;
  46709. private _renderTime;
  46710. private _captureInterFrameTime;
  46711. private _interFrameTime;
  46712. private _captureParticlesRenderTime;
  46713. private _particlesRenderTime;
  46714. private _captureSpritesRenderTime;
  46715. private _spritesRenderTime;
  46716. private _capturePhysicsTime;
  46717. private _physicsTime;
  46718. private _captureAnimationsTime;
  46719. private _animationsTime;
  46720. private _captureCameraRenderTime;
  46721. private _cameraRenderTime;
  46722. private _onBeforeActiveMeshesEvaluationObserver;
  46723. private _onAfterActiveMeshesEvaluationObserver;
  46724. private _onBeforeRenderTargetsRenderObserver;
  46725. private _onAfterRenderTargetsRenderObserver;
  46726. private _onAfterRenderObserver;
  46727. private _onBeforeDrawPhaseObserver;
  46728. private _onAfterDrawPhaseObserver;
  46729. private _onBeforeAnimationsObserver;
  46730. private _onBeforeParticlesRenderingObserver;
  46731. private _onAfterParticlesRenderingObserver;
  46732. private _onBeforeSpritesRenderingObserver;
  46733. private _onAfterSpritesRenderingObserver;
  46734. private _onBeforePhysicsObserver;
  46735. private _onAfterPhysicsObserver;
  46736. private _onAfterAnimationsObserver;
  46737. private _onBeforeCameraRenderObserver;
  46738. private _onAfterCameraRenderObserver;
  46739. /**
  46740. * Gets the perf counter used for active meshes evaluation time
  46741. */
  46742. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46743. /**
  46744. * Gets the active meshes evaluation time capture status
  46745. */
  46746. /**
  46747. * Enable or disable the active meshes evaluation time capture
  46748. */
  46749. captureActiveMeshesEvaluationTime: boolean;
  46750. /**
  46751. * Gets the perf counter used for render targets render time
  46752. */
  46753. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46754. /**
  46755. * Gets the render targets render time capture status
  46756. */
  46757. /**
  46758. * Enable or disable the render targets render time capture
  46759. */
  46760. captureRenderTargetsRenderTime: boolean;
  46761. /**
  46762. * Gets the perf counter used for particles render time
  46763. */
  46764. readonly particlesRenderTimeCounter: PerfCounter;
  46765. /**
  46766. * Gets the particles render time capture status
  46767. */
  46768. /**
  46769. * Enable or disable the particles render time capture
  46770. */
  46771. captureParticlesRenderTime: boolean;
  46772. /**
  46773. * Gets the perf counter used for sprites render time
  46774. */
  46775. readonly spritesRenderTimeCounter: PerfCounter;
  46776. /**
  46777. * Gets the sprites render time capture status
  46778. */
  46779. /**
  46780. * Enable or disable the sprites render time capture
  46781. */
  46782. captureSpritesRenderTime: boolean;
  46783. /**
  46784. * Gets the perf counter used for physics time
  46785. */
  46786. readonly physicsTimeCounter: PerfCounter;
  46787. /**
  46788. * Gets the physics time capture status
  46789. */
  46790. /**
  46791. * Enable or disable the physics time capture
  46792. */
  46793. capturePhysicsTime: boolean;
  46794. /**
  46795. * Gets the perf counter used for animations time
  46796. */
  46797. readonly animationsTimeCounter: PerfCounter;
  46798. /**
  46799. * Gets the animations time capture status
  46800. */
  46801. /**
  46802. * Enable or disable the animations time capture
  46803. */
  46804. captureAnimationsTime: boolean;
  46805. /**
  46806. * Gets the perf counter used for frame time capture
  46807. */
  46808. readonly frameTimeCounter: PerfCounter;
  46809. /**
  46810. * Gets the frame time capture status
  46811. */
  46812. /**
  46813. * Enable or disable the frame time capture
  46814. */
  46815. captureFrameTime: boolean;
  46816. /**
  46817. * Gets the perf counter used for inter-frames time capture
  46818. */
  46819. readonly interFrameTimeCounter: PerfCounter;
  46820. /**
  46821. * Gets the inter-frames time capture status
  46822. */
  46823. /**
  46824. * Enable or disable the inter-frames time capture
  46825. */
  46826. captureInterFrameTime: boolean;
  46827. /**
  46828. * Gets the perf counter used for render time capture
  46829. */
  46830. readonly renderTimeCounter: PerfCounter;
  46831. /**
  46832. * Gets the render time capture status
  46833. */
  46834. /**
  46835. * Enable or disable the render time capture
  46836. */
  46837. captureRenderTime: boolean;
  46838. /**
  46839. * Gets the perf counter used for camera render time capture
  46840. */
  46841. readonly cameraRenderTimeCounter: PerfCounter;
  46842. /**
  46843. * Gets the camera render time capture status
  46844. */
  46845. /**
  46846. * Enable or disable the camera render time capture
  46847. */
  46848. captureCameraRenderTime: boolean;
  46849. /**
  46850. * Gets the perf counter used for draw calls
  46851. */
  46852. readonly drawCallsCounter: PerfCounter;
  46853. /**
  46854. * Gets the perf counter used for texture collisions
  46855. */
  46856. readonly textureCollisionsCounter: PerfCounter;
  46857. /**
  46858. * Instantiates a new scene instrumentation.
  46859. * This class can be used to get instrumentation data from a Babylon engine
  46860. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46861. * @param scene Defines the scene to instrument
  46862. */
  46863. constructor(
  46864. /**
  46865. * Defines the scene to instrument
  46866. */
  46867. scene: Scene);
  46868. /**
  46869. * Dispose and release associated resources.
  46870. */
  46871. dispose(): void;
  46872. }
  46873. }
  46874. declare module "babylonjs/Instrumentation/index" {
  46875. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46876. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46877. export * from "babylonjs/Instrumentation/timeToken";
  46878. }
  46879. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46880. /** @hidden */
  46881. export var glowMapGenerationPixelShader: {
  46882. name: string;
  46883. shader: string;
  46884. };
  46885. }
  46886. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46887. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46888. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46889. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46890. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46891. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46892. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46893. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46894. /** @hidden */
  46895. export var glowMapGenerationVertexShader: {
  46896. name: string;
  46897. shader: string;
  46898. };
  46899. }
  46900. declare module "babylonjs/Layers/effectLayer" {
  46901. import { Observable } from "babylonjs/Misc/observable";
  46902. import { Nullable } from "babylonjs/types";
  46903. import { Camera } from "babylonjs/Cameras/camera";
  46904. import { Scene } from "babylonjs/scene";
  46905. import { Color4, ISize } from "babylonjs/Maths/math";
  46906. import { Engine } from "babylonjs/Engines/engine";
  46907. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46909. import { Mesh } from "babylonjs/Meshes/mesh";
  46910. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46912. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46913. import { Effect } from "babylonjs/Materials/effect";
  46914. import { Material } from "babylonjs/Materials/material";
  46915. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46916. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46917. /**
  46918. * Effect layer options. This helps customizing the behaviour
  46919. * of the effect layer.
  46920. */
  46921. export interface IEffectLayerOptions {
  46922. /**
  46923. * Multiplication factor apply to the canvas size to compute the render target size
  46924. * used to generated the objects (the smaller the faster).
  46925. */
  46926. mainTextureRatio: number;
  46927. /**
  46928. * Enforces a fixed size texture to ensure effect stability across devices.
  46929. */
  46930. mainTextureFixedSize?: number;
  46931. /**
  46932. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46933. */
  46934. alphaBlendingMode: number;
  46935. /**
  46936. * The camera attached to the layer.
  46937. */
  46938. camera: Nullable<Camera>;
  46939. /**
  46940. * The rendering group to draw the layer in.
  46941. */
  46942. renderingGroupId: number;
  46943. }
  46944. /**
  46945. * The effect layer Helps adding post process effect blended with the main pass.
  46946. *
  46947. * This can be for instance use to generate glow or higlight effects on the scene.
  46948. *
  46949. * The effect layer class can not be used directly and is intented to inherited from to be
  46950. * customized per effects.
  46951. */
  46952. export abstract class EffectLayer {
  46953. private _vertexBuffers;
  46954. private _indexBuffer;
  46955. private _cachedDefines;
  46956. private _effectLayerMapGenerationEffect;
  46957. private _effectLayerOptions;
  46958. private _mergeEffect;
  46959. protected _scene: Scene;
  46960. protected _engine: Engine;
  46961. protected _maxSize: number;
  46962. protected _mainTextureDesiredSize: ISize;
  46963. protected _mainTexture: RenderTargetTexture;
  46964. protected _shouldRender: boolean;
  46965. protected _postProcesses: PostProcess[];
  46966. protected _textures: BaseTexture[];
  46967. protected _emissiveTextureAndColor: {
  46968. texture: Nullable<BaseTexture>;
  46969. color: Color4;
  46970. };
  46971. /**
  46972. * The name of the layer
  46973. */
  46974. name: string;
  46975. /**
  46976. * The clear color of the texture used to generate the glow map.
  46977. */
  46978. neutralColor: Color4;
  46979. /**
  46980. * Specifies wether the highlight layer is enabled or not.
  46981. */
  46982. isEnabled: boolean;
  46983. /**
  46984. * Gets the camera attached to the layer.
  46985. */
  46986. readonly camera: Nullable<Camera>;
  46987. /**
  46988. * Gets the rendering group id the layer should render in.
  46989. */
  46990. readonly renderingGroupId: number;
  46991. /**
  46992. * An event triggered when the effect layer has been disposed.
  46993. */
  46994. onDisposeObservable: Observable<EffectLayer>;
  46995. /**
  46996. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46997. */
  46998. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46999. /**
  47000. * An event triggered when the generated texture is being merged in the scene.
  47001. */
  47002. onBeforeComposeObservable: Observable<EffectLayer>;
  47003. /**
  47004. * An event triggered when the generated texture has been merged in the scene.
  47005. */
  47006. onAfterComposeObservable: Observable<EffectLayer>;
  47007. /**
  47008. * An event triggered when the efffect layer changes its size.
  47009. */
  47010. onSizeChangedObservable: Observable<EffectLayer>;
  47011. /** @hidden */
  47012. static _SceneComponentInitialization: (scene: Scene) => void;
  47013. /**
  47014. * Instantiates a new effect Layer and references it in the scene.
  47015. * @param name The name of the layer
  47016. * @param scene The scene to use the layer in
  47017. */
  47018. constructor(
  47019. /** The Friendly of the effect in the scene */
  47020. name: string, scene: Scene);
  47021. /**
  47022. * Get the effect name of the layer.
  47023. * @return The effect name
  47024. */
  47025. abstract getEffectName(): string;
  47026. /**
  47027. * Checks for the readiness of the element composing the layer.
  47028. * @param subMesh the mesh to check for
  47029. * @param useInstances specify wether or not to use instances to render the mesh
  47030. * @return true if ready otherwise, false
  47031. */
  47032. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47033. /**
  47034. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47035. * @returns true if the effect requires stencil during the main canvas render pass.
  47036. */
  47037. abstract needStencil(): boolean;
  47038. /**
  47039. * Create the merge effect. This is the shader use to blit the information back
  47040. * to the main canvas at the end of the scene rendering.
  47041. * @returns The effect containing the shader used to merge the effect on the main canvas
  47042. */
  47043. protected abstract _createMergeEffect(): Effect;
  47044. /**
  47045. * Creates the render target textures and post processes used in the effect layer.
  47046. */
  47047. protected abstract _createTextureAndPostProcesses(): void;
  47048. /**
  47049. * Implementation specific of rendering the generating effect on the main canvas.
  47050. * @param effect The effect used to render through
  47051. */
  47052. protected abstract _internalRender(effect: Effect): void;
  47053. /**
  47054. * Sets the required values for both the emissive texture and and the main color.
  47055. */
  47056. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47057. /**
  47058. * Free any resources and references associated to a mesh.
  47059. * Internal use
  47060. * @param mesh The mesh to free.
  47061. */
  47062. abstract _disposeMesh(mesh: Mesh): void;
  47063. /**
  47064. * Serializes this layer (Glow or Highlight for example)
  47065. * @returns a serialized layer object
  47066. */
  47067. abstract serialize?(): any;
  47068. /**
  47069. * Initializes the effect layer with the required options.
  47070. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47071. */
  47072. protected _init(options: Partial<IEffectLayerOptions>): void;
  47073. /**
  47074. * Generates the index buffer of the full screen quad blending to the main canvas.
  47075. */
  47076. private _generateIndexBuffer;
  47077. /**
  47078. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47079. */
  47080. private _genrateVertexBuffer;
  47081. /**
  47082. * Sets the main texture desired size which is the closest power of two
  47083. * of the engine canvas size.
  47084. */
  47085. private _setMainTextureSize;
  47086. /**
  47087. * Creates the main texture for the effect layer.
  47088. */
  47089. protected _createMainTexture(): void;
  47090. /**
  47091. * Adds specific effects defines.
  47092. * @param defines The defines to add specifics to.
  47093. */
  47094. protected _addCustomEffectDefines(defines: string[]): void;
  47095. /**
  47096. * Checks for the readiness of the element composing the layer.
  47097. * @param subMesh the mesh to check for
  47098. * @param useInstances specify wether or not to use instances to render the mesh
  47099. * @param emissiveTexture the associated emissive texture used to generate the glow
  47100. * @return true if ready otherwise, false
  47101. */
  47102. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47103. /**
  47104. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47105. */
  47106. render(): void;
  47107. /**
  47108. * Determine if a given mesh will be used in the current effect.
  47109. * @param mesh mesh to test
  47110. * @returns true if the mesh will be used
  47111. */
  47112. hasMesh(mesh: AbstractMesh): boolean;
  47113. /**
  47114. * Returns true if the layer contains information to display, otherwise false.
  47115. * @returns true if the glow layer should be rendered
  47116. */
  47117. shouldRender(): boolean;
  47118. /**
  47119. * Returns true if the mesh should render, otherwise false.
  47120. * @param mesh The mesh to render
  47121. * @returns true if it should render otherwise false
  47122. */
  47123. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47124. /**
  47125. * Returns true if the mesh can be rendered, otherwise false.
  47126. * @param mesh The mesh to render
  47127. * @param material The material used on the mesh
  47128. * @returns true if it can be rendered otherwise false
  47129. */
  47130. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47131. /**
  47132. * Returns true if the mesh should render, otherwise false.
  47133. * @param mesh The mesh to render
  47134. * @returns true if it should render otherwise false
  47135. */
  47136. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47137. /**
  47138. * Renders the submesh passed in parameter to the generation map.
  47139. */
  47140. protected _renderSubMesh(subMesh: SubMesh): void;
  47141. /**
  47142. * Rebuild the required buffers.
  47143. * @hidden Internal use only.
  47144. */
  47145. _rebuild(): void;
  47146. /**
  47147. * Dispose only the render target textures and post process.
  47148. */
  47149. private _disposeTextureAndPostProcesses;
  47150. /**
  47151. * Dispose the highlight layer and free resources.
  47152. */
  47153. dispose(): void;
  47154. /**
  47155. * Gets the class name of the effect layer
  47156. * @returns the string with the class name of the effect layer
  47157. */
  47158. getClassName(): string;
  47159. /**
  47160. * Creates an effect layer from parsed effect layer data
  47161. * @param parsedEffectLayer defines effect layer data
  47162. * @param scene defines the current scene
  47163. * @param rootUrl defines the root URL containing the effect layer information
  47164. * @returns a parsed effect Layer
  47165. */
  47166. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47167. }
  47168. }
  47169. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47170. import { Scene } from "babylonjs/scene";
  47171. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47172. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47173. import { AbstractScene } from "babylonjs/abstractScene";
  47174. module "babylonjs/abstractScene" {
  47175. interface AbstractScene {
  47176. /**
  47177. * The list of effect layers (highlights/glow) added to the scene
  47178. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47179. * @see http://doc.babylonjs.com/how_to/glow_layer
  47180. */
  47181. effectLayers: Array<EffectLayer>;
  47182. /**
  47183. * Removes the given effect layer from this scene.
  47184. * @param toRemove defines the effect layer to remove
  47185. * @returns the index of the removed effect layer
  47186. */
  47187. removeEffectLayer(toRemove: EffectLayer): number;
  47188. /**
  47189. * Adds the given effect layer to this scene
  47190. * @param newEffectLayer defines the effect layer to add
  47191. */
  47192. addEffectLayer(newEffectLayer: EffectLayer): void;
  47193. }
  47194. }
  47195. /**
  47196. * Defines the layer scene component responsible to manage any effect layers
  47197. * in a given scene.
  47198. */
  47199. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47200. /**
  47201. * The component name helpfull to identify the component in the list of scene components.
  47202. */
  47203. readonly name: string;
  47204. /**
  47205. * The scene the component belongs to.
  47206. */
  47207. scene: Scene;
  47208. private _engine;
  47209. private _renderEffects;
  47210. private _needStencil;
  47211. private _previousStencilState;
  47212. /**
  47213. * Creates a new instance of the component for the given scene
  47214. * @param scene Defines the scene to register the component in
  47215. */
  47216. constructor(scene: Scene);
  47217. /**
  47218. * Registers the component in a given scene
  47219. */
  47220. register(): void;
  47221. /**
  47222. * Rebuilds the elements related to this component in case of
  47223. * context lost for instance.
  47224. */
  47225. rebuild(): void;
  47226. /**
  47227. * Serializes the component data to the specified json object
  47228. * @param serializationObject The object to serialize to
  47229. */
  47230. serialize(serializationObject: any): void;
  47231. /**
  47232. * Adds all the element from the container to the scene
  47233. * @param container the container holding the elements
  47234. */
  47235. addFromContainer(container: AbstractScene): void;
  47236. /**
  47237. * Removes all the elements in the container from the scene
  47238. * @param container contains the elements to remove
  47239. */
  47240. removeFromContainer(container: AbstractScene): void;
  47241. /**
  47242. * Disposes the component and the associated ressources.
  47243. */
  47244. dispose(): void;
  47245. private _isReadyForMesh;
  47246. private _renderMainTexture;
  47247. private _setStencil;
  47248. private _setStencilBack;
  47249. private _draw;
  47250. private _drawCamera;
  47251. private _drawRenderingGroup;
  47252. }
  47253. }
  47254. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47255. /** @hidden */
  47256. export var glowMapMergePixelShader: {
  47257. name: string;
  47258. shader: string;
  47259. };
  47260. }
  47261. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47262. /** @hidden */
  47263. export var glowMapMergeVertexShader: {
  47264. name: string;
  47265. shader: string;
  47266. };
  47267. }
  47268. declare module "babylonjs/Layers/glowLayer" {
  47269. import { Nullable } from "babylonjs/types";
  47270. import { Camera } from "babylonjs/Cameras/camera";
  47271. import { Scene } from "babylonjs/scene";
  47272. import { Color4 } from "babylonjs/Maths/math";
  47273. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47275. import { Mesh } from "babylonjs/Meshes/mesh";
  47276. import { Texture } from "babylonjs/Materials/Textures/texture";
  47277. import { Effect } from "babylonjs/Materials/effect";
  47278. import { Material } from "babylonjs/Materials/material";
  47279. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47280. import "babylonjs/Shaders/glowMapMerge.fragment";
  47281. import "babylonjs/Shaders/glowMapMerge.vertex";
  47282. import "babylonjs/Layers/effectLayerSceneComponent";
  47283. module "babylonjs/abstractScene" {
  47284. interface AbstractScene {
  47285. /**
  47286. * Return a the first highlight layer of the scene with a given name.
  47287. * @param name The name of the highlight layer to look for.
  47288. * @return The highlight layer if found otherwise null.
  47289. */
  47290. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47291. }
  47292. }
  47293. /**
  47294. * Glow layer options. This helps customizing the behaviour
  47295. * of the glow layer.
  47296. */
  47297. export interface IGlowLayerOptions {
  47298. /**
  47299. * Multiplication factor apply to the canvas size to compute the render target size
  47300. * used to generated the glowing objects (the smaller the faster).
  47301. */
  47302. mainTextureRatio: number;
  47303. /**
  47304. * Enforces a fixed size texture to ensure resize independant blur.
  47305. */
  47306. mainTextureFixedSize?: number;
  47307. /**
  47308. * How big is the kernel of the blur texture.
  47309. */
  47310. blurKernelSize: number;
  47311. /**
  47312. * The camera attached to the layer.
  47313. */
  47314. camera: Nullable<Camera>;
  47315. /**
  47316. * Enable MSAA by chosing the number of samples.
  47317. */
  47318. mainTextureSamples?: number;
  47319. /**
  47320. * The rendering group to draw the layer in.
  47321. */
  47322. renderingGroupId: number;
  47323. }
  47324. /**
  47325. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47326. *
  47327. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47328. * glowy meshes to your scene.
  47329. *
  47330. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47331. */
  47332. export class GlowLayer extends EffectLayer {
  47333. /**
  47334. * Effect Name of the layer.
  47335. */
  47336. static readonly EffectName: string;
  47337. /**
  47338. * The default blur kernel size used for the glow.
  47339. */
  47340. static DefaultBlurKernelSize: number;
  47341. /**
  47342. * The default texture size ratio used for the glow.
  47343. */
  47344. static DefaultTextureRatio: number;
  47345. /**
  47346. * Sets the kernel size of the blur.
  47347. */
  47348. /**
  47349. * Gets the kernel size of the blur.
  47350. */
  47351. blurKernelSize: number;
  47352. /**
  47353. * Sets the glow intensity.
  47354. */
  47355. /**
  47356. * Gets the glow intensity.
  47357. */
  47358. intensity: number;
  47359. private _options;
  47360. private _intensity;
  47361. private _horizontalBlurPostprocess1;
  47362. private _verticalBlurPostprocess1;
  47363. private _horizontalBlurPostprocess2;
  47364. private _verticalBlurPostprocess2;
  47365. private _blurTexture1;
  47366. private _blurTexture2;
  47367. private _postProcesses1;
  47368. private _postProcesses2;
  47369. private _includedOnlyMeshes;
  47370. private _excludedMeshes;
  47371. /**
  47372. * Callback used to let the user override the color selection on a per mesh basis
  47373. */
  47374. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47375. /**
  47376. * Callback used to let the user override the texture selection on a per mesh basis
  47377. */
  47378. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47379. /**
  47380. * Instantiates a new glow Layer and references it to the scene.
  47381. * @param name The name of the layer
  47382. * @param scene The scene to use the layer in
  47383. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47384. */
  47385. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47386. /**
  47387. * Get the effect name of the layer.
  47388. * @return The effect name
  47389. */
  47390. getEffectName(): string;
  47391. /**
  47392. * Create the merge effect. This is the shader use to blit the information back
  47393. * to the main canvas at the end of the scene rendering.
  47394. */
  47395. protected _createMergeEffect(): Effect;
  47396. /**
  47397. * Creates the render target textures and post processes used in the glow layer.
  47398. */
  47399. protected _createTextureAndPostProcesses(): void;
  47400. /**
  47401. * Checks for the readiness of the element composing the layer.
  47402. * @param subMesh the mesh to check for
  47403. * @param useInstances specify wether or not to use instances to render the mesh
  47404. * @param emissiveTexture the associated emissive texture used to generate the glow
  47405. * @return true if ready otherwise, false
  47406. */
  47407. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47408. /**
  47409. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47410. */
  47411. needStencil(): boolean;
  47412. /**
  47413. * Returns true if the mesh can be rendered, otherwise false.
  47414. * @param mesh The mesh to render
  47415. * @param material The material used on the mesh
  47416. * @returns true if it can be rendered otherwise false
  47417. */
  47418. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47419. /**
  47420. * Implementation specific of rendering the generating effect on the main canvas.
  47421. * @param effect The effect used to render through
  47422. */
  47423. protected _internalRender(effect: Effect): void;
  47424. /**
  47425. * Sets the required values for both the emissive texture and and the main color.
  47426. */
  47427. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47428. /**
  47429. * Returns true if the mesh should render, otherwise false.
  47430. * @param mesh The mesh to render
  47431. * @returns true if it should render otherwise false
  47432. */
  47433. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47434. /**
  47435. * Adds specific effects defines.
  47436. * @param defines The defines to add specifics to.
  47437. */
  47438. protected _addCustomEffectDefines(defines: string[]): void;
  47439. /**
  47440. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47441. * @param mesh The mesh to exclude from the glow layer
  47442. */
  47443. addExcludedMesh(mesh: Mesh): void;
  47444. /**
  47445. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47446. * @param mesh The mesh to remove
  47447. */
  47448. removeExcludedMesh(mesh: Mesh): void;
  47449. /**
  47450. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47451. * @param mesh The mesh to include in the glow layer
  47452. */
  47453. addIncludedOnlyMesh(mesh: Mesh): void;
  47454. /**
  47455. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47456. * @param mesh The mesh to remove
  47457. */
  47458. removeIncludedOnlyMesh(mesh: Mesh): void;
  47459. /**
  47460. * Determine if a given mesh will be used in the glow layer
  47461. * @param mesh The mesh to test
  47462. * @returns true if the mesh will be highlighted by the current glow layer
  47463. */
  47464. hasMesh(mesh: AbstractMesh): boolean;
  47465. /**
  47466. * Free any resources and references associated to a mesh.
  47467. * Internal use
  47468. * @param mesh The mesh to free.
  47469. * @hidden
  47470. */
  47471. _disposeMesh(mesh: Mesh): void;
  47472. /**
  47473. * Gets the class name of the effect layer
  47474. * @returns the string with the class name of the effect layer
  47475. */
  47476. getClassName(): string;
  47477. /**
  47478. * Serializes this glow layer
  47479. * @returns a serialized glow layer object
  47480. */
  47481. serialize(): any;
  47482. /**
  47483. * Creates a Glow Layer from parsed glow layer data
  47484. * @param parsedGlowLayer defines glow layer data
  47485. * @param scene defines the current scene
  47486. * @param rootUrl defines the root URL containing the glow layer information
  47487. * @returns a parsed Glow Layer
  47488. */
  47489. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47490. }
  47491. }
  47492. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47493. /** @hidden */
  47494. export var glowBlurPostProcessPixelShader: {
  47495. name: string;
  47496. shader: string;
  47497. };
  47498. }
  47499. declare module "babylonjs/Layers/highlightLayer" {
  47500. import { Observable } from "babylonjs/Misc/observable";
  47501. import { Nullable } from "babylonjs/types";
  47502. import { Camera } from "babylonjs/Cameras/camera";
  47503. import { Scene } from "babylonjs/scene";
  47504. import { Color3, Color4 } from "babylonjs/Maths/math";
  47505. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47507. import { Mesh } from "babylonjs/Meshes/mesh";
  47508. import { Effect } from "babylonjs/Materials/effect";
  47509. import { Material } from "babylonjs/Materials/material";
  47510. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47511. import "babylonjs/Shaders/glowMapMerge.fragment";
  47512. import "babylonjs/Shaders/glowMapMerge.vertex";
  47513. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47514. module "babylonjs/abstractScene" {
  47515. interface AbstractScene {
  47516. /**
  47517. * Return a the first highlight layer of the scene with a given name.
  47518. * @param name The name of the highlight layer to look for.
  47519. * @return The highlight layer if found otherwise null.
  47520. */
  47521. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47522. }
  47523. }
  47524. /**
  47525. * Highlight layer options. This helps customizing the behaviour
  47526. * of the highlight layer.
  47527. */
  47528. export interface IHighlightLayerOptions {
  47529. /**
  47530. * Multiplication factor apply to the canvas size to compute the render target size
  47531. * used to generated the glowing objects (the smaller the faster).
  47532. */
  47533. mainTextureRatio: number;
  47534. /**
  47535. * Enforces a fixed size texture to ensure resize independant blur.
  47536. */
  47537. mainTextureFixedSize?: number;
  47538. /**
  47539. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47540. * of the picture to blur (the smaller the faster).
  47541. */
  47542. blurTextureSizeRatio: number;
  47543. /**
  47544. * How big in texel of the blur texture is the vertical blur.
  47545. */
  47546. blurVerticalSize: number;
  47547. /**
  47548. * How big in texel of the blur texture is the horizontal blur.
  47549. */
  47550. blurHorizontalSize: number;
  47551. /**
  47552. * Alpha blending mode used to apply the blur. Default is combine.
  47553. */
  47554. alphaBlendingMode: number;
  47555. /**
  47556. * The camera attached to the layer.
  47557. */
  47558. camera: Nullable<Camera>;
  47559. /**
  47560. * Should we display highlight as a solid stroke?
  47561. */
  47562. isStroke?: boolean;
  47563. /**
  47564. * The rendering group to draw the layer in.
  47565. */
  47566. renderingGroupId: number;
  47567. }
  47568. /**
  47569. * The highlight layer Helps adding a glow effect around a mesh.
  47570. *
  47571. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47572. * glowy meshes to your scene.
  47573. *
  47574. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47575. */
  47576. export class HighlightLayer extends EffectLayer {
  47577. name: string;
  47578. /**
  47579. * Effect Name of the highlight layer.
  47580. */
  47581. static readonly EffectName: string;
  47582. /**
  47583. * The neutral color used during the preparation of the glow effect.
  47584. * This is black by default as the blend operation is a blend operation.
  47585. */
  47586. static NeutralColor: Color4;
  47587. /**
  47588. * Stencil value used for glowing meshes.
  47589. */
  47590. static GlowingMeshStencilReference: number;
  47591. /**
  47592. * Stencil value used for the other meshes in the scene.
  47593. */
  47594. static NormalMeshStencilReference: number;
  47595. /**
  47596. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47597. */
  47598. innerGlow: boolean;
  47599. /**
  47600. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47601. */
  47602. outerGlow: boolean;
  47603. /**
  47604. * Specifies the horizontal size of the blur.
  47605. */
  47606. /**
  47607. * Gets the horizontal size of the blur.
  47608. */
  47609. blurHorizontalSize: number;
  47610. /**
  47611. * Specifies the vertical size of the blur.
  47612. */
  47613. /**
  47614. * Gets the vertical size of the blur.
  47615. */
  47616. blurVerticalSize: number;
  47617. /**
  47618. * An event triggered when the highlight layer is being blurred.
  47619. */
  47620. onBeforeBlurObservable: Observable<HighlightLayer>;
  47621. /**
  47622. * An event triggered when the highlight layer has been blurred.
  47623. */
  47624. onAfterBlurObservable: Observable<HighlightLayer>;
  47625. private _instanceGlowingMeshStencilReference;
  47626. private _options;
  47627. private _downSamplePostprocess;
  47628. private _horizontalBlurPostprocess;
  47629. private _verticalBlurPostprocess;
  47630. private _blurTexture;
  47631. private _meshes;
  47632. private _excludedMeshes;
  47633. /**
  47634. * Instantiates a new highlight Layer and references it to the scene..
  47635. * @param name The name of the layer
  47636. * @param scene The scene to use the layer in
  47637. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47638. */
  47639. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47640. /**
  47641. * Get the effect name of the layer.
  47642. * @return The effect name
  47643. */
  47644. getEffectName(): string;
  47645. /**
  47646. * Create the merge effect. This is the shader use to blit the information back
  47647. * to the main canvas at the end of the scene rendering.
  47648. */
  47649. protected _createMergeEffect(): Effect;
  47650. /**
  47651. * Creates the render target textures and post processes used in the highlight layer.
  47652. */
  47653. protected _createTextureAndPostProcesses(): void;
  47654. /**
  47655. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47656. */
  47657. needStencil(): boolean;
  47658. /**
  47659. * Checks for the readiness of the element composing the layer.
  47660. * @param subMesh the mesh to check for
  47661. * @param useInstances specify wether or not to use instances to render the mesh
  47662. * @param emissiveTexture the associated emissive texture used to generate the glow
  47663. * @return true if ready otherwise, false
  47664. */
  47665. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47666. /**
  47667. * Implementation specific of rendering the generating effect on the main canvas.
  47668. * @param effect The effect used to render through
  47669. */
  47670. protected _internalRender(effect: Effect): void;
  47671. /**
  47672. * Returns true if the layer contains information to display, otherwise false.
  47673. */
  47674. shouldRender(): boolean;
  47675. /**
  47676. * Returns true if the mesh should render, otherwise false.
  47677. * @param mesh The mesh to render
  47678. * @returns true if it should render otherwise false
  47679. */
  47680. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47681. /**
  47682. * Sets the required values for both the emissive texture and and the main color.
  47683. */
  47684. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47685. /**
  47686. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47687. * @param mesh The mesh to exclude from the highlight layer
  47688. */
  47689. addExcludedMesh(mesh: Mesh): void;
  47690. /**
  47691. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47692. * @param mesh The mesh to highlight
  47693. */
  47694. removeExcludedMesh(mesh: Mesh): void;
  47695. /**
  47696. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47697. * @param mesh mesh to test
  47698. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47699. */
  47700. hasMesh(mesh: AbstractMesh): boolean;
  47701. /**
  47702. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47703. * @param mesh The mesh to highlight
  47704. * @param color The color of the highlight
  47705. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47706. */
  47707. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47708. /**
  47709. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47710. * @param mesh The mesh to highlight
  47711. */
  47712. removeMesh(mesh: Mesh): void;
  47713. /**
  47714. * Force the stencil to the normal expected value for none glowing parts
  47715. */
  47716. private _defaultStencilReference;
  47717. /**
  47718. * Free any resources and references associated to a mesh.
  47719. * Internal use
  47720. * @param mesh The mesh to free.
  47721. * @hidden
  47722. */
  47723. _disposeMesh(mesh: Mesh): void;
  47724. /**
  47725. * Dispose the highlight layer and free resources.
  47726. */
  47727. dispose(): void;
  47728. /**
  47729. * Gets the class name of the effect layer
  47730. * @returns the string with the class name of the effect layer
  47731. */
  47732. getClassName(): string;
  47733. /**
  47734. * Serializes this Highlight layer
  47735. * @returns a serialized Highlight layer object
  47736. */
  47737. serialize(): any;
  47738. /**
  47739. * Creates a Highlight layer from parsed Highlight layer data
  47740. * @param parsedHightlightLayer defines the Highlight layer data
  47741. * @param scene defines the current scene
  47742. * @param rootUrl defines the root URL containing the Highlight layer information
  47743. * @returns a parsed Highlight layer
  47744. */
  47745. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47746. }
  47747. }
  47748. declare module "babylonjs/Layers/index" {
  47749. export * from "babylonjs/Layers/effectLayer";
  47750. export * from "babylonjs/Layers/effectLayerSceneComponent";
  47751. export * from "babylonjs/Layers/glowLayer";
  47752. export * from "babylonjs/Layers/highlightLayer";
  47753. export * from "babylonjs/Layers/layer";
  47754. export * from "babylonjs/Layers/layerSceneComponent";
  47755. }
  47756. declare module "babylonjs/Shaders/lensFlare.fragment" {
  47757. /** @hidden */
  47758. export var lensFlarePixelShader: {
  47759. name: string;
  47760. shader: string;
  47761. };
  47762. }
  47763. declare module "babylonjs/Shaders/lensFlare.vertex" {
  47764. /** @hidden */
  47765. export var lensFlareVertexShader: {
  47766. name: string;
  47767. shader: string;
  47768. };
  47769. }
  47770. declare module "babylonjs/LensFlares/lensFlareSystem" {
  47771. import { Scene } from "babylonjs/scene";
  47772. import { Vector3, Viewport } from "babylonjs/Maths/math";
  47773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47774. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  47775. import "babylonjs/Shaders/lensFlare.fragment";
  47776. import "babylonjs/Shaders/lensFlare.vertex";
  47777. /**
  47778. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47779. * It is usually composed of several `lensFlare`.
  47780. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47781. */
  47782. export class LensFlareSystem {
  47783. /**
  47784. * Define the name of the lens flare system
  47785. */
  47786. name: string;
  47787. /**
  47788. * List of lens flares used in this system.
  47789. */
  47790. lensFlares: LensFlare[];
  47791. /**
  47792. * Define a limit from the border the lens flare can be visible.
  47793. */
  47794. borderLimit: number;
  47795. /**
  47796. * Define a viewport border we do not want to see the lens flare in.
  47797. */
  47798. viewportBorder: number;
  47799. /**
  47800. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47801. */
  47802. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47803. /**
  47804. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47805. */
  47806. layerMask: number;
  47807. /**
  47808. * Define the id of the lens flare system in the scene.
  47809. * (equal to name by default)
  47810. */
  47811. id: string;
  47812. private _scene;
  47813. private _emitter;
  47814. private _vertexBuffers;
  47815. private _indexBuffer;
  47816. private _effect;
  47817. private _positionX;
  47818. private _positionY;
  47819. private _isEnabled;
  47820. /** @hidden */
  47821. static _SceneComponentInitialization: (scene: Scene) => void;
  47822. /**
  47823. * Instantiates a lens flare system.
  47824. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47825. * It is usually composed of several `lensFlare`.
  47826. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47827. * @param name Define the name of the lens flare system in the scene
  47828. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47829. * @param scene Define the scene the lens flare system belongs to
  47830. */
  47831. constructor(
  47832. /**
  47833. * Define the name of the lens flare system
  47834. */
  47835. name: string, emitter: any, scene: Scene);
  47836. /**
  47837. * Define if the lens flare system is enabled.
  47838. */
  47839. isEnabled: boolean;
  47840. /**
  47841. * Get the scene the effects belongs to.
  47842. * @returns the scene holding the lens flare system
  47843. */
  47844. getScene(): Scene;
  47845. /**
  47846. * Get the emitter of the lens flare system.
  47847. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47848. * @returns the emitter of the lens flare system
  47849. */
  47850. getEmitter(): any;
  47851. /**
  47852. * Set the emitter of the lens flare system.
  47853. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47854. * @param newEmitter Define the new emitter of the system
  47855. */
  47856. setEmitter(newEmitter: any): void;
  47857. /**
  47858. * Get the lens flare system emitter position.
  47859. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47860. * @returns the position
  47861. */
  47862. getEmitterPosition(): Vector3;
  47863. /**
  47864. * @hidden
  47865. */
  47866. computeEffectivePosition(globalViewport: Viewport): boolean;
  47867. /** @hidden */
  47868. _isVisible(): boolean;
  47869. /**
  47870. * @hidden
  47871. */
  47872. render(): boolean;
  47873. /**
  47874. * Dispose and release the lens flare with its associated resources.
  47875. */
  47876. dispose(): void;
  47877. /**
  47878. * Parse a lens flare system from a JSON repressentation
  47879. * @param parsedLensFlareSystem Define the JSON to parse
  47880. * @param scene Define the scene the parsed system should be instantiated in
  47881. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47882. * @returns the parsed system
  47883. */
  47884. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47885. /**
  47886. * Serialize the current Lens Flare System into a JSON representation.
  47887. * @returns the serialized JSON
  47888. */
  47889. serialize(): any;
  47890. }
  47891. }
  47892. declare module "babylonjs/LensFlares/lensFlare" {
  47893. import { Nullable } from "babylonjs/types";
  47894. import { Color3 } from "babylonjs/Maths/math";
  47895. import { Texture } from "babylonjs/Materials/Textures/texture";
  47896. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47897. /**
  47898. * This represents one of the lens effect in a `lensFlareSystem`.
  47899. * It controls one of the indiviual texture used in the effect.
  47900. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47901. */
  47902. export class LensFlare {
  47903. /**
  47904. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47905. */
  47906. size: number;
  47907. /**
  47908. * 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.
  47909. */
  47910. position: number;
  47911. /**
  47912. * Define the lens color.
  47913. */
  47914. color: Color3;
  47915. /**
  47916. * Define the lens texture.
  47917. */
  47918. texture: Nullable<Texture>;
  47919. /**
  47920. * Define the alpha mode to render this particular lens.
  47921. */
  47922. alphaMode: number;
  47923. private _system;
  47924. /**
  47925. * Creates a new Lens Flare.
  47926. * This represents one of the lens effect in a `lensFlareSystem`.
  47927. * It controls one of the indiviual texture used in the effect.
  47928. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47929. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47930. * @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.
  47931. * @param color Define the lens color
  47932. * @param imgUrl Define the lens texture url
  47933. * @param system Define the `lensFlareSystem` this flare is part of
  47934. * @returns The newly created Lens Flare
  47935. */
  47936. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47937. /**
  47938. * Instantiates a new Lens Flare.
  47939. * This represents one of the lens effect in a `lensFlareSystem`.
  47940. * It controls one of the indiviual texture used in the effect.
  47941. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47942. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47943. * @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.
  47944. * @param color Define the lens color
  47945. * @param imgUrl Define the lens texture url
  47946. * @param system Define the `lensFlareSystem` this flare is part of
  47947. */
  47948. constructor(
  47949. /**
  47950. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47951. */
  47952. size: number,
  47953. /**
  47954. * 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.
  47955. */
  47956. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47957. /**
  47958. * Dispose and release the lens flare with its associated resources.
  47959. */
  47960. dispose(): void;
  47961. }
  47962. }
  47963. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47964. import { Nullable } from "babylonjs/types";
  47965. import { Scene } from "babylonjs/scene";
  47966. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47967. import { AbstractScene } from "babylonjs/abstractScene";
  47968. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47969. module "babylonjs/abstractScene" {
  47970. interface AbstractScene {
  47971. /**
  47972. * The list of lens flare system added to the scene
  47973. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47974. */
  47975. lensFlareSystems: Array<LensFlareSystem>;
  47976. /**
  47977. * Removes the given lens flare system from this scene.
  47978. * @param toRemove The lens flare system to remove
  47979. * @returns The index of the removed lens flare system
  47980. */
  47981. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47982. /**
  47983. * Adds the given lens flare system to this scene
  47984. * @param newLensFlareSystem The lens flare system to add
  47985. */
  47986. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47987. /**
  47988. * Gets a lens flare system using its name
  47989. * @param name defines the name to look for
  47990. * @returns the lens flare system or null if not found
  47991. */
  47992. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47993. /**
  47994. * Gets a lens flare system using its id
  47995. * @param id defines the id to look for
  47996. * @returns the lens flare system or null if not found
  47997. */
  47998. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47999. }
  48000. }
  48001. /**
  48002. * Defines the lens flare scene component responsible to manage any lens flares
  48003. * in a given scene.
  48004. */
  48005. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48006. /**
  48007. * The component name helpfull to identify the component in the list of scene components.
  48008. */
  48009. readonly name: string;
  48010. /**
  48011. * The scene the component belongs to.
  48012. */
  48013. scene: Scene;
  48014. /**
  48015. * Creates a new instance of the component for the given scene
  48016. * @param scene Defines the scene to register the component in
  48017. */
  48018. constructor(scene: Scene);
  48019. /**
  48020. * Registers the component in a given scene
  48021. */
  48022. register(): void;
  48023. /**
  48024. * Rebuilds the elements related to this component in case of
  48025. * context lost for instance.
  48026. */
  48027. rebuild(): void;
  48028. /**
  48029. * Adds all the element from the container to the scene
  48030. * @param container the container holding the elements
  48031. */
  48032. addFromContainer(container: AbstractScene): void;
  48033. /**
  48034. * Removes all the elements in the container from the scene
  48035. * @param container contains the elements to remove
  48036. */
  48037. removeFromContainer(container: AbstractScene): void;
  48038. /**
  48039. * Serializes the component data to the specified json object
  48040. * @param serializationObject The object to serialize to
  48041. */
  48042. serialize(serializationObject: any): void;
  48043. /**
  48044. * Disposes the component and the associated ressources.
  48045. */
  48046. dispose(): void;
  48047. private _draw;
  48048. }
  48049. }
  48050. declare module "babylonjs/LensFlares/index" {
  48051. export * from "babylonjs/LensFlares/lensFlare";
  48052. export * from "babylonjs/LensFlares/lensFlareSystem";
  48053. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48054. }
  48055. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48056. import { Scene } from "babylonjs/scene";
  48057. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48058. import { AbstractScene } from "babylonjs/abstractScene";
  48059. /**
  48060. * Defines the shadow generator component responsible to manage any shadow generators
  48061. * in a given scene.
  48062. */
  48063. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48064. /**
  48065. * The component name helpfull to identify the component in the list of scene components.
  48066. */
  48067. readonly name: string;
  48068. /**
  48069. * The scene the component belongs to.
  48070. */
  48071. scene: Scene;
  48072. /**
  48073. * Creates a new instance of the component for the given scene
  48074. * @param scene Defines the scene to register the component in
  48075. */
  48076. constructor(scene: Scene);
  48077. /**
  48078. * Registers the component in a given scene
  48079. */
  48080. register(): void;
  48081. /**
  48082. * Rebuilds the elements related to this component in case of
  48083. * context lost for instance.
  48084. */
  48085. rebuild(): void;
  48086. /**
  48087. * Serializes the component data to the specified json object
  48088. * @param serializationObject The object to serialize to
  48089. */
  48090. serialize(serializationObject: any): void;
  48091. /**
  48092. * Adds all the element from the container to the scene
  48093. * @param container the container holding the elements
  48094. */
  48095. addFromContainer(container: AbstractScene): void;
  48096. /**
  48097. * Removes all the elements in the container from the scene
  48098. * @param container contains the elements to remove
  48099. */
  48100. removeFromContainer(container: AbstractScene): void;
  48101. /**
  48102. * Rebuilds the elements related to this component in case of
  48103. * context lost for instance.
  48104. */
  48105. dispose(): void;
  48106. private _gatherRenderTargets;
  48107. }
  48108. }
  48109. declare module "babylonjs/Lights/Shadows/index" {
  48110. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48111. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48112. }
  48113. declare module "babylonjs/Lights/directionalLight" {
  48114. import { Camera } from "babylonjs/Cameras/camera";
  48115. import { Scene } from "babylonjs/scene";
  48116. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48118. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48119. import { Effect } from "babylonjs/Materials/effect";
  48120. /**
  48121. * A directional light is defined by a direction (what a surprise!).
  48122. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48123. * 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.
  48124. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48125. */
  48126. export class DirectionalLight extends ShadowLight {
  48127. private _shadowFrustumSize;
  48128. /**
  48129. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48130. */
  48131. /**
  48132. * Specifies a fix frustum size for the shadow generation.
  48133. */
  48134. shadowFrustumSize: number;
  48135. private _shadowOrthoScale;
  48136. /**
  48137. * Gets the shadow projection scale against the optimal computed one.
  48138. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48139. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48140. */
  48141. /**
  48142. * Sets the shadow projection scale against the optimal computed one.
  48143. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48144. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48145. */
  48146. shadowOrthoScale: number;
  48147. /**
  48148. * Automatically compute the projection matrix to best fit (including all the casters)
  48149. * on each frame.
  48150. */
  48151. autoUpdateExtends: boolean;
  48152. private _orthoLeft;
  48153. private _orthoRight;
  48154. private _orthoTop;
  48155. private _orthoBottom;
  48156. /**
  48157. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48158. * The directional light is emitted from everywhere in the given direction.
  48159. * It can cast shadows.
  48160. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48161. * @param name The friendly name of the light
  48162. * @param direction The direction of the light
  48163. * @param scene The scene the light belongs to
  48164. */
  48165. constructor(name: string, direction: Vector3, scene: Scene);
  48166. /**
  48167. * Returns the string "DirectionalLight".
  48168. * @return The class name
  48169. */
  48170. getClassName(): string;
  48171. /**
  48172. * Returns the integer 1.
  48173. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48174. */
  48175. getTypeID(): number;
  48176. /**
  48177. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48178. * Returns the DirectionalLight Shadow projection matrix.
  48179. */
  48180. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48181. /**
  48182. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48183. * Returns the DirectionalLight Shadow projection matrix.
  48184. */
  48185. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48186. /**
  48187. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48188. * Returns the DirectionalLight Shadow projection matrix.
  48189. */
  48190. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48191. protected _buildUniformLayout(): void;
  48192. /**
  48193. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48194. * @param effect The effect to update
  48195. * @param lightIndex The index of the light in the effect to update
  48196. * @returns The directional light
  48197. */
  48198. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48199. /**
  48200. * Gets the minZ used for shadow according to both the scene and the light.
  48201. *
  48202. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48203. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48204. * @param activeCamera The camera we are returning the min for
  48205. * @returns the depth min z
  48206. */
  48207. getDepthMinZ(activeCamera: Camera): number;
  48208. /**
  48209. * Gets the maxZ used for shadow according to both the scene and the light.
  48210. *
  48211. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48212. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48213. * @param activeCamera The camera we are returning the max for
  48214. * @returns the depth max z
  48215. */
  48216. getDepthMaxZ(activeCamera: Camera): number;
  48217. /**
  48218. * Prepares the list of defines specific to the light type.
  48219. * @param defines the list of defines
  48220. * @param lightIndex defines the index of the light for the effect
  48221. */
  48222. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48223. }
  48224. }
  48225. declare module "babylonjs/Lights/pointLight" {
  48226. import { Scene } from "babylonjs/scene";
  48227. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48229. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48230. import { Effect } from "babylonjs/Materials/effect";
  48231. /**
  48232. * A point light is a light defined by an unique point in world space.
  48233. * The light is emitted in every direction from this point.
  48234. * A good example of a point light is a standard light bulb.
  48235. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48236. */
  48237. export class PointLight extends ShadowLight {
  48238. private _shadowAngle;
  48239. /**
  48240. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48241. * This specifies what angle the shadow will use to be created.
  48242. *
  48243. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48244. */
  48245. /**
  48246. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48247. * This specifies what angle the shadow will use to be created.
  48248. *
  48249. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48250. */
  48251. shadowAngle: number;
  48252. /**
  48253. * Gets the direction if it has been set.
  48254. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48255. */
  48256. /**
  48257. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48258. */
  48259. direction: Vector3;
  48260. /**
  48261. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48262. * A PointLight emits the light in every direction.
  48263. * It can cast shadows.
  48264. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48265. * ```javascript
  48266. * var pointLight = new PointLight("pl", camera.position, scene);
  48267. * ```
  48268. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48269. * @param name The light friendly name
  48270. * @param position The position of the point light in the scene
  48271. * @param scene The scene the lights belongs to
  48272. */
  48273. constructor(name: string, position: Vector3, scene: Scene);
  48274. /**
  48275. * Returns the string "PointLight"
  48276. * @returns the class name
  48277. */
  48278. getClassName(): string;
  48279. /**
  48280. * Returns the integer 0.
  48281. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48282. */
  48283. getTypeID(): number;
  48284. /**
  48285. * Specifies wether or not the shadowmap should be a cube texture.
  48286. * @returns true if the shadowmap needs to be a cube texture.
  48287. */
  48288. needCube(): boolean;
  48289. /**
  48290. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48291. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48292. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48293. */
  48294. getShadowDirection(faceIndex?: number): Vector3;
  48295. /**
  48296. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48297. * - fov = PI / 2
  48298. * - aspect ratio : 1.0
  48299. * - z-near and far equal to the active camera minZ and maxZ.
  48300. * Returns the PointLight.
  48301. */
  48302. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48303. protected _buildUniformLayout(): void;
  48304. /**
  48305. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48306. * @param effect The effect to update
  48307. * @param lightIndex The index of the light in the effect to update
  48308. * @returns The point light
  48309. */
  48310. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48311. /**
  48312. * Prepares the list of defines specific to the light type.
  48313. * @param defines the list of defines
  48314. * @param lightIndex defines the index of the light for the effect
  48315. */
  48316. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48317. }
  48318. }
  48319. declare module "babylonjs/Lights/spotLight" {
  48320. import { Nullable } from "babylonjs/types";
  48321. import { Scene } from "babylonjs/scene";
  48322. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48324. import { Effect } from "babylonjs/Materials/effect";
  48325. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48326. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48327. /**
  48328. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48329. * These values define a cone of light starting from the position, emitting toward the direction.
  48330. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48331. * and the exponent defines the speed of the decay of the light with distance (reach).
  48332. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48333. */
  48334. export class SpotLight extends ShadowLight {
  48335. private _angle;
  48336. private _innerAngle;
  48337. private _cosHalfAngle;
  48338. private _lightAngleScale;
  48339. private _lightAngleOffset;
  48340. /**
  48341. * Gets the cone angle of the spot light in Radians.
  48342. */
  48343. /**
  48344. * Sets the cone angle of the spot light in Radians.
  48345. */
  48346. angle: number;
  48347. /**
  48348. * Only used in gltf falloff mode, this defines the angle where
  48349. * the directional falloff will start before cutting at angle which could be seen
  48350. * as outer angle.
  48351. */
  48352. /**
  48353. * Only used in gltf falloff mode, this defines the angle where
  48354. * the directional falloff will start before cutting at angle which could be seen
  48355. * as outer angle.
  48356. */
  48357. innerAngle: number;
  48358. private _shadowAngleScale;
  48359. /**
  48360. * Allows scaling the angle of the light for shadow generation only.
  48361. */
  48362. /**
  48363. * Allows scaling the angle of the light for shadow generation only.
  48364. */
  48365. shadowAngleScale: number;
  48366. /**
  48367. * The light decay speed with the distance from the emission spot.
  48368. */
  48369. exponent: number;
  48370. private _projectionTextureMatrix;
  48371. /**
  48372. * Allows reading the projecton texture
  48373. */
  48374. readonly projectionTextureMatrix: Matrix;
  48375. protected _projectionTextureLightNear: number;
  48376. /**
  48377. * Gets the near clip of the Spotlight for texture projection.
  48378. */
  48379. /**
  48380. * Sets the near clip of the Spotlight for texture projection.
  48381. */
  48382. projectionTextureLightNear: number;
  48383. protected _projectionTextureLightFar: number;
  48384. /**
  48385. * Gets the far clip of the Spotlight for texture projection.
  48386. */
  48387. /**
  48388. * Sets the far clip of the Spotlight for texture projection.
  48389. */
  48390. projectionTextureLightFar: number;
  48391. protected _projectionTextureUpDirection: Vector3;
  48392. /**
  48393. * Gets the Up vector of the Spotlight for texture projection.
  48394. */
  48395. /**
  48396. * Sets the Up vector of the Spotlight for texture projection.
  48397. */
  48398. projectionTextureUpDirection: Vector3;
  48399. private _projectionTexture;
  48400. /**
  48401. * Gets the projection texture of the light.
  48402. */
  48403. /**
  48404. * Sets the projection texture of the light.
  48405. */
  48406. projectionTexture: Nullable<BaseTexture>;
  48407. private _projectionTextureViewLightDirty;
  48408. private _projectionTextureProjectionLightDirty;
  48409. private _projectionTextureDirty;
  48410. private _projectionTextureViewTargetVector;
  48411. private _projectionTextureViewLightMatrix;
  48412. private _projectionTextureProjectionLightMatrix;
  48413. private _projectionTextureScalingMatrix;
  48414. /**
  48415. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48416. * It can cast shadows.
  48417. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48418. * @param name The light friendly name
  48419. * @param position The position of the spot light in the scene
  48420. * @param direction The direction of the light in the scene
  48421. * @param angle The cone angle of the light in Radians
  48422. * @param exponent The light decay speed with the distance from the emission spot
  48423. * @param scene The scene the lights belongs to
  48424. */
  48425. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48426. /**
  48427. * Returns the string "SpotLight".
  48428. * @returns the class name
  48429. */
  48430. getClassName(): string;
  48431. /**
  48432. * Returns the integer 2.
  48433. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48434. */
  48435. getTypeID(): number;
  48436. /**
  48437. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48438. */
  48439. protected _setDirection(value: Vector3): void;
  48440. /**
  48441. * Overrides the position setter to recompute the projection texture view light Matrix.
  48442. */
  48443. protected _setPosition(value: Vector3): void;
  48444. /**
  48445. * 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.
  48446. * Returns the SpotLight.
  48447. */
  48448. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48449. protected _computeProjectionTextureViewLightMatrix(): void;
  48450. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48451. /**
  48452. * Main function for light texture projection matrix computing.
  48453. */
  48454. protected _computeProjectionTextureMatrix(): void;
  48455. protected _buildUniformLayout(): void;
  48456. private _computeAngleValues;
  48457. /**
  48458. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48459. * @param effect The effect to update
  48460. * @param lightIndex The index of the light in the effect to update
  48461. * @returns The spot light
  48462. */
  48463. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48464. /**
  48465. * Disposes the light and the associated resources.
  48466. */
  48467. dispose(): void;
  48468. /**
  48469. * Prepares the list of defines specific to the light type.
  48470. * @param defines the list of defines
  48471. * @param lightIndex defines the index of the light for the effect
  48472. */
  48473. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48474. }
  48475. }
  48476. declare module "babylonjs/Lights/index" {
  48477. export * from "babylonjs/Lights/light";
  48478. export * from "babylonjs/Lights/shadowLight";
  48479. export * from "babylonjs/Lights/Shadows/index";
  48480. export * from "babylonjs/Lights/directionalLight";
  48481. export * from "babylonjs/Lights/hemisphericLight";
  48482. export * from "babylonjs/Lights/pointLight";
  48483. export * from "babylonjs/Lights/spotLight";
  48484. }
  48485. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48486. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48487. /**
  48488. * Header information of HDR texture files.
  48489. */
  48490. export interface HDRInfo {
  48491. /**
  48492. * The height of the texture in pixels.
  48493. */
  48494. height: number;
  48495. /**
  48496. * The width of the texture in pixels.
  48497. */
  48498. width: number;
  48499. /**
  48500. * The index of the beginning of the data in the binary file.
  48501. */
  48502. dataPosition: number;
  48503. }
  48504. /**
  48505. * This groups tools to convert HDR texture to native colors array.
  48506. */
  48507. export class HDRTools {
  48508. private static Ldexp;
  48509. private static Rgbe2float;
  48510. private static readStringLine;
  48511. /**
  48512. * Reads header information from an RGBE texture stored in a native array.
  48513. * More information on this format are available here:
  48514. * https://en.wikipedia.org/wiki/RGBE_image_format
  48515. *
  48516. * @param uint8array The binary file stored in native array.
  48517. * @return The header information.
  48518. */
  48519. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48520. /**
  48521. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48522. * This RGBE texture needs to store the information as a panorama.
  48523. *
  48524. * More information on this format are available here:
  48525. * https://en.wikipedia.org/wiki/RGBE_image_format
  48526. *
  48527. * @param buffer The binary file stored in an array buffer.
  48528. * @param size The expected size of the extracted cubemap.
  48529. * @return The Cube Map information.
  48530. */
  48531. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48532. /**
  48533. * Returns the pixels data extracted from an RGBE texture.
  48534. * This pixels will be stored left to right up to down in the R G B order in one array.
  48535. *
  48536. * More information on this format are available here:
  48537. * https://en.wikipedia.org/wiki/RGBE_image_format
  48538. *
  48539. * @param uint8array The binary file stored in an array buffer.
  48540. * @param hdrInfo The header information of the file.
  48541. * @return The pixels data in RGB right to left up to down order.
  48542. */
  48543. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48544. private static RGBE_ReadPixels_RLE;
  48545. }
  48546. }
  48547. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48548. import { Nullable } from "babylonjs/types";
  48549. import { Scene } from "babylonjs/scene";
  48550. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48552. /**
  48553. * This represents a texture coming from an HDR input.
  48554. *
  48555. * The only supported format is currently panorama picture stored in RGBE format.
  48556. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48557. */
  48558. export class HDRCubeTexture extends BaseTexture {
  48559. private static _facesMapping;
  48560. private _generateHarmonics;
  48561. private _noMipmap;
  48562. private _textureMatrix;
  48563. private _size;
  48564. private _onLoad;
  48565. private _onError;
  48566. /**
  48567. * The texture URL.
  48568. */
  48569. url: string;
  48570. /**
  48571. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48572. */
  48573. coordinatesMode: number;
  48574. protected _isBlocking: boolean;
  48575. /**
  48576. * Sets wether or not the texture is blocking during loading.
  48577. */
  48578. /**
  48579. * Gets wether or not the texture is blocking during loading.
  48580. */
  48581. isBlocking: boolean;
  48582. protected _rotationY: number;
  48583. /**
  48584. * Sets texture matrix rotation angle around Y axis in radians.
  48585. */
  48586. /**
  48587. * Gets texture matrix rotation angle around Y axis radians.
  48588. */
  48589. rotationY: number;
  48590. /**
  48591. * Gets or sets the center of the bounding box associated with the cube texture
  48592. * It must define where the camera used to render the texture was set
  48593. */
  48594. boundingBoxPosition: Vector3;
  48595. private _boundingBoxSize;
  48596. /**
  48597. * Gets or sets the size of the bounding box associated with the cube texture
  48598. * When defined, the cubemap will switch to local mode
  48599. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48600. * @example https://www.babylonjs-playground.com/#RNASML
  48601. */
  48602. boundingBoxSize: Vector3;
  48603. /**
  48604. * Instantiates an HDRTexture from the following parameters.
  48605. *
  48606. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48607. * @param scene The scene the texture will be used in
  48608. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48609. * @param noMipmap Forces to not generate the mipmap if true
  48610. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48611. * @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)
  48612. * @param reserved Reserved flag for internal use.
  48613. */
  48614. 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>);
  48615. /**
  48616. * Get the current class name of the texture useful for serialization or dynamic coding.
  48617. * @returns "HDRCubeTexture"
  48618. */
  48619. getClassName(): string;
  48620. /**
  48621. * Occurs when the file is raw .hdr file.
  48622. */
  48623. private loadTexture;
  48624. clone(): HDRCubeTexture;
  48625. delayLoad(): void;
  48626. /**
  48627. * Get the texture reflection matrix used to rotate/transform the reflection.
  48628. * @returns the reflection matrix
  48629. */
  48630. getReflectionTextureMatrix(): Matrix;
  48631. /**
  48632. * Set the texture reflection matrix used to rotate/transform the reflection.
  48633. * @param value Define the reflection matrix to set
  48634. */
  48635. setReflectionTextureMatrix(value: Matrix): void;
  48636. /**
  48637. * Parses a JSON representation of an HDR Texture in order to create the texture
  48638. * @param parsedTexture Define the JSON representation
  48639. * @param scene Define the scene the texture should be created in
  48640. * @param rootUrl Define the root url in case we need to load relative dependencies
  48641. * @returns the newly created texture after parsing
  48642. */
  48643. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48644. serialize(): any;
  48645. }
  48646. }
  48647. declare module "babylonjs/Physics/physicsEngine" {
  48648. import { Nullable } from "babylonjs/types";
  48649. import { Vector3 } from "babylonjs/Maths/math";
  48650. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48651. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48652. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48653. /**
  48654. * Class used to control physics engine
  48655. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48656. */
  48657. export class PhysicsEngine implements IPhysicsEngine {
  48658. private _physicsPlugin;
  48659. /**
  48660. * Global value used to control the smallest number supported by the simulation
  48661. */
  48662. static Epsilon: number;
  48663. private _impostors;
  48664. private _joints;
  48665. /**
  48666. * Gets the gravity vector used by the simulation
  48667. */
  48668. gravity: Vector3;
  48669. /**
  48670. * Factory used to create the default physics plugin.
  48671. * @returns The default physics plugin
  48672. */
  48673. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48674. /**
  48675. * Creates a new Physics Engine
  48676. * @param gravity defines the gravity vector used by the simulation
  48677. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48678. */
  48679. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48680. /**
  48681. * Sets the gravity vector used by the simulation
  48682. * @param gravity defines the gravity vector to use
  48683. */
  48684. setGravity(gravity: Vector3): void;
  48685. /**
  48686. * Set the time step of the physics engine.
  48687. * Default is 1/60.
  48688. * To slow it down, enter 1/600 for example.
  48689. * To speed it up, 1/30
  48690. * @param newTimeStep defines the new timestep to apply to this world.
  48691. */
  48692. setTimeStep(newTimeStep?: number): void;
  48693. /**
  48694. * Get the time step of the physics engine.
  48695. * @returns the current time step
  48696. */
  48697. getTimeStep(): number;
  48698. /**
  48699. * Release all resources
  48700. */
  48701. dispose(): void;
  48702. /**
  48703. * Gets the name of the current physics plugin
  48704. * @returns the name of the plugin
  48705. */
  48706. getPhysicsPluginName(): string;
  48707. /**
  48708. * Adding a new impostor for the impostor tracking.
  48709. * This will be done by the impostor itself.
  48710. * @param impostor the impostor to add
  48711. */
  48712. addImpostor(impostor: PhysicsImpostor): void;
  48713. /**
  48714. * Remove an impostor from the engine.
  48715. * This impostor and its mesh will not longer be updated by the physics engine.
  48716. * @param impostor the impostor to remove
  48717. */
  48718. removeImpostor(impostor: PhysicsImpostor): void;
  48719. /**
  48720. * Add a joint to the physics engine
  48721. * @param mainImpostor defines the main impostor to which the joint is added.
  48722. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48723. * @param joint defines the joint that will connect both impostors.
  48724. */
  48725. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48726. /**
  48727. * Removes a joint from the simulation
  48728. * @param mainImpostor defines the impostor used with the joint
  48729. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48730. * @param joint defines the joint to remove
  48731. */
  48732. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48733. /**
  48734. * Called by the scene. No need to call it.
  48735. * @param delta defines the timespam between frames
  48736. */
  48737. _step(delta: number): void;
  48738. /**
  48739. * Gets the current plugin used to run the simulation
  48740. * @returns current plugin
  48741. */
  48742. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48743. /**
  48744. * Gets the list of physic impostors
  48745. * @returns an array of PhysicsImpostor
  48746. */
  48747. getImpostors(): Array<PhysicsImpostor>;
  48748. /**
  48749. * Gets the impostor for a physics enabled object
  48750. * @param object defines the object impersonated by the impostor
  48751. * @returns the PhysicsImpostor or null if not found
  48752. */
  48753. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48754. /**
  48755. * Gets the impostor for a physics body object
  48756. * @param body defines physics body used by the impostor
  48757. * @returns the PhysicsImpostor or null if not found
  48758. */
  48759. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48760. }
  48761. }
  48762. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  48763. import { Nullable } from "babylonjs/types";
  48764. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48766. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48767. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48768. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48769. /** @hidden */
  48770. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48771. private _useDeltaForWorldStep;
  48772. world: any;
  48773. name: string;
  48774. private _physicsMaterials;
  48775. private _fixedTimeStep;
  48776. BJSCANNON: any;
  48777. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48778. setGravity(gravity: Vector3): void;
  48779. setTimeStep(timeStep: number): void;
  48780. getTimeStep(): number;
  48781. executeStep(delta: number): void;
  48782. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48783. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48784. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48785. private _processChildMeshes;
  48786. removePhysicsBody(impostor: PhysicsImpostor): void;
  48787. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48788. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48789. private _addMaterial;
  48790. private _checkWithEpsilon;
  48791. private _createShape;
  48792. private _createHeightmap;
  48793. private _minus90X;
  48794. private _plus90X;
  48795. private _tmpPosition;
  48796. private _tmpDeltaPosition;
  48797. private _tmpUnityRotation;
  48798. private _updatePhysicsBodyTransformation;
  48799. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48800. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48801. isSupported(): boolean;
  48802. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48803. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48804. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48805. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48806. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48807. getBodyMass(impostor: PhysicsImpostor): number;
  48808. getBodyFriction(impostor: PhysicsImpostor): number;
  48809. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48810. getBodyRestitution(impostor: PhysicsImpostor): number;
  48811. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48812. sleepBody(impostor: PhysicsImpostor): void;
  48813. wakeUpBody(impostor: PhysicsImpostor): void;
  48814. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48815. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48816. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48817. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48818. getRadius(impostor: PhysicsImpostor): number;
  48819. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48820. dispose(): void;
  48821. private _extendNamespace;
  48822. }
  48823. }
  48824. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48825. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48826. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48827. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48829. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48830. import { Nullable } from "babylonjs/types";
  48831. /** @hidden */
  48832. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48833. world: any;
  48834. name: string;
  48835. BJSOIMO: any;
  48836. constructor(iterations?: number, oimoInjection?: any);
  48837. setGravity(gravity: Vector3): void;
  48838. setTimeStep(timeStep: number): void;
  48839. getTimeStep(): number;
  48840. private _tmpImpostorsArray;
  48841. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48842. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48843. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48844. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48845. private _tmpPositionVector;
  48846. removePhysicsBody(impostor: PhysicsImpostor): void;
  48847. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48848. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48849. isSupported(): boolean;
  48850. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48851. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48852. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48853. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48854. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48855. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48856. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48857. getBodyMass(impostor: PhysicsImpostor): number;
  48858. getBodyFriction(impostor: PhysicsImpostor): number;
  48859. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48860. getBodyRestitution(impostor: PhysicsImpostor): number;
  48861. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48862. sleepBody(impostor: PhysicsImpostor): void;
  48863. wakeUpBody(impostor: PhysicsImpostor): void;
  48864. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48865. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48866. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48867. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48868. getRadius(impostor: PhysicsImpostor): number;
  48869. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48870. dispose(): void;
  48871. }
  48872. }
  48873. declare module "babylonjs/Probes/reflectionProbe" {
  48874. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48875. import { Vector3 } from "babylonjs/Maths/math";
  48876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48877. import { Nullable } from "babylonjs/types";
  48878. import { Scene } from "babylonjs/scene";
  48879. module "babylonjs/abstractScene" {
  48880. interface AbstractScene {
  48881. /**
  48882. * The list of reflection probes added to the scene
  48883. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48884. */
  48885. reflectionProbes: Array<ReflectionProbe>;
  48886. /**
  48887. * Removes the given reflection probe from this scene.
  48888. * @param toRemove The reflection probe to remove
  48889. * @returns The index of the removed reflection probe
  48890. */
  48891. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48892. /**
  48893. * Adds the given reflection probe to this scene.
  48894. * @param newReflectionProbe The reflection probe to add
  48895. */
  48896. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48897. }
  48898. }
  48899. /**
  48900. * Class used to generate realtime reflection / refraction cube textures
  48901. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48902. */
  48903. export class ReflectionProbe {
  48904. /** defines the name of the probe */
  48905. name: string;
  48906. private _scene;
  48907. private _renderTargetTexture;
  48908. private _projectionMatrix;
  48909. private _viewMatrix;
  48910. private _target;
  48911. private _add;
  48912. private _attachedMesh;
  48913. private _invertYAxis;
  48914. /** Gets or sets probe position (center of the cube map) */
  48915. position: Vector3;
  48916. /**
  48917. * Creates a new reflection probe
  48918. * @param name defines the name of the probe
  48919. * @param size defines the texture resolution (for each face)
  48920. * @param scene defines the hosting scene
  48921. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48922. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48923. */
  48924. constructor(
  48925. /** defines the name of the probe */
  48926. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48927. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48928. samples: number;
  48929. /** Gets or sets the refresh rate to use (on every frame by default) */
  48930. refreshRate: number;
  48931. /**
  48932. * Gets the hosting scene
  48933. * @returns a Scene
  48934. */
  48935. getScene(): Scene;
  48936. /** Gets the internal CubeTexture used to render to */
  48937. readonly cubeTexture: RenderTargetTexture;
  48938. /** Gets the list of meshes to render */
  48939. readonly renderList: Nullable<AbstractMesh[]>;
  48940. /**
  48941. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48942. * @param mesh defines the mesh to attach to
  48943. */
  48944. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48945. /**
  48946. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48947. * @param renderingGroupId The rendering group id corresponding to its index
  48948. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48949. */
  48950. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48951. /**
  48952. * Clean all associated resources
  48953. */
  48954. dispose(): void;
  48955. /**
  48956. * Converts the reflection probe information to a readable string for debug purpose.
  48957. * @param fullDetails Supports for multiple levels of logging within scene loading
  48958. * @returns the human readable reflection probe info
  48959. */
  48960. toString(fullDetails?: boolean): string;
  48961. /**
  48962. * Get the class name of the relfection probe.
  48963. * @returns "ReflectionProbe"
  48964. */
  48965. getClassName(): string;
  48966. /**
  48967. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48968. * @returns The JSON representation of the texture
  48969. */
  48970. serialize(): any;
  48971. /**
  48972. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48973. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48974. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48975. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48976. * @returns The parsed reflection probe if successful
  48977. */
  48978. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48979. }
  48980. }
  48981. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48982. /** @hidden */
  48983. export var _BabylonLoaderRegistered: boolean;
  48984. }
  48985. declare module "babylonjs/Loading/Plugins/index" {
  48986. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48987. }
  48988. declare module "babylonjs/Loading/index" {
  48989. export * from "babylonjs/Loading/loadingScreen";
  48990. export * from "babylonjs/Loading/Plugins/index";
  48991. export * from "babylonjs/Loading/sceneLoader";
  48992. export * from "babylonjs/Loading/sceneLoaderFlags";
  48993. }
  48994. declare module "babylonjs/Materials/Background/index" {
  48995. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48996. }
  48997. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48998. import { Scene } from "babylonjs/scene";
  48999. import { Color3 } from "babylonjs/Maths/math";
  49000. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49001. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49002. /**
  49003. * The Physically based simple base material of BJS.
  49004. *
  49005. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49006. * It is used as the base class for both the specGloss and metalRough conventions.
  49007. */
  49008. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49009. /**
  49010. * Number of Simultaneous lights allowed on the material.
  49011. */
  49012. maxSimultaneousLights: number;
  49013. /**
  49014. * If sets to true, disables all the lights affecting the material.
  49015. */
  49016. disableLighting: boolean;
  49017. /**
  49018. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49019. */
  49020. environmentTexture: BaseTexture;
  49021. /**
  49022. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49023. */
  49024. invertNormalMapX: boolean;
  49025. /**
  49026. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49027. */
  49028. invertNormalMapY: boolean;
  49029. /**
  49030. * Normal map used in the model.
  49031. */
  49032. normalTexture: BaseTexture;
  49033. /**
  49034. * Emissivie color used to self-illuminate the model.
  49035. */
  49036. emissiveColor: Color3;
  49037. /**
  49038. * Emissivie texture used to self-illuminate the model.
  49039. */
  49040. emissiveTexture: BaseTexture;
  49041. /**
  49042. * Occlusion Channel Strenght.
  49043. */
  49044. occlusionStrength: number;
  49045. /**
  49046. * Occlusion Texture of the material (adding extra occlusion effects).
  49047. */
  49048. occlusionTexture: BaseTexture;
  49049. /**
  49050. * Defines the alpha limits in alpha test mode.
  49051. */
  49052. alphaCutOff: number;
  49053. /**
  49054. * Gets the current double sided mode.
  49055. */
  49056. /**
  49057. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49058. */
  49059. doubleSided: boolean;
  49060. /**
  49061. * Stores the pre-calculated light information of a mesh in a texture.
  49062. */
  49063. lightmapTexture: BaseTexture;
  49064. /**
  49065. * If true, the light map contains occlusion information instead of lighting info.
  49066. */
  49067. useLightmapAsShadowmap: boolean;
  49068. /**
  49069. * Instantiates a new PBRMaterial instance.
  49070. *
  49071. * @param name The material name
  49072. * @param scene The scene the material will be use in.
  49073. */
  49074. constructor(name: string, scene: Scene);
  49075. getClassName(): string;
  49076. }
  49077. }
  49078. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49079. import { Scene } from "babylonjs/scene";
  49080. import { Color3 } from "babylonjs/Maths/math";
  49081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49082. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49083. /**
  49084. * The PBR material of BJS following the metal roughness convention.
  49085. *
  49086. * This fits to the PBR convention in the GLTF definition:
  49087. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49088. */
  49089. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49090. /**
  49091. * The base color has two different interpretations depending on the value of metalness.
  49092. * When the material is a metal, the base color is the specific measured reflectance value
  49093. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49094. * of the material.
  49095. */
  49096. baseColor: Color3;
  49097. /**
  49098. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49099. * well as opacity information in the alpha channel.
  49100. */
  49101. baseTexture: BaseTexture;
  49102. /**
  49103. * Specifies the metallic scalar value of the material.
  49104. * Can also be used to scale the metalness values of the metallic texture.
  49105. */
  49106. metallic: number;
  49107. /**
  49108. * Specifies the roughness scalar value of the material.
  49109. * Can also be used to scale the roughness values of the metallic texture.
  49110. */
  49111. roughness: number;
  49112. /**
  49113. * Texture containing both the metallic value in the B channel and the
  49114. * roughness value in the G channel to keep better precision.
  49115. */
  49116. metallicRoughnessTexture: BaseTexture;
  49117. /**
  49118. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49119. *
  49120. * @param name The material name
  49121. * @param scene The scene the material will be use in.
  49122. */
  49123. constructor(name: string, scene: Scene);
  49124. /**
  49125. * Return the currrent class name of the material.
  49126. */
  49127. getClassName(): string;
  49128. /**
  49129. * Makes a duplicate of the current material.
  49130. * @param name - name to use for the new material.
  49131. */
  49132. clone(name: string): PBRMetallicRoughnessMaterial;
  49133. /**
  49134. * Serialize the material to a parsable JSON object.
  49135. */
  49136. serialize(): any;
  49137. /**
  49138. * Parses a JSON object correponding to the serialize function.
  49139. */
  49140. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49141. }
  49142. }
  49143. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49144. import { Scene } from "babylonjs/scene";
  49145. import { Color3 } from "babylonjs/Maths/math";
  49146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49147. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49148. /**
  49149. * The PBR material of BJS following the specular glossiness convention.
  49150. *
  49151. * This fits to the PBR convention in the GLTF definition:
  49152. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49153. */
  49154. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49155. /**
  49156. * Specifies the diffuse color of the material.
  49157. */
  49158. diffuseColor: Color3;
  49159. /**
  49160. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49161. * channel.
  49162. */
  49163. diffuseTexture: BaseTexture;
  49164. /**
  49165. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49166. */
  49167. specularColor: Color3;
  49168. /**
  49169. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49170. */
  49171. glossiness: number;
  49172. /**
  49173. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49174. */
  49175. specularGlossinessTexture: BaseTexture;
  49176. /**
  49177. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49178. *
  49179. * @param name The material name
  49180. * @param scene The scene the material will be use in.
  49181. */
  49182. constructor(name: string, scene: Scene);
  49183. /**
  49184. * Return the currrent class name of the material.
  49185. */
  49186. getClassName(): string;
  49187. /**
  49188. * Makes a duplicate of the current material.
  49189. * @param name - name to use for the new material.
  49190. */
  49191. clone(name: string): PBRSpecularGlossinessMaterial;
  49192. /**
  49193. * Serialize the material to a parsable JSON object.
  49194. */
  49195. serialize(): any;
  49196. /**
  49197. * Parses a JSON object correponding to the serialize function.
  49198. */
  49199. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49200. }
  49201. }
  49202. declare module "babylonjs/Materials/PBR/index" {
  49203. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49204. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49205. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49206. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49207. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49208. }
  49209. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49210. import { Nullable } from "babylonjs/types";
  49211. import { Scene } from "babylonjs/scene";
  49212. import { Matrix } from "babylonjs/Maths/math";
  49213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49214. /**
  49215. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49216. * It can help converting any input color in a desired output one. This can then be used to create effects
  49217. * from sepia, black and white to sixties or futuristic rendering...
  49218. *
  49219. * The only supported format is currently 3dl.
  49220. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49221. */
  49222. export class ColorGradingTexture extends BaseTexture {
  49223. /**
  49224. * The current texture matrix. (will always be identity in color grading texture)
  49225. */
  49226. private _textureMatrix;
  49227. /**
  49228. * The texture URL.
  49229. */
  49230. url: string;
  49231. /**
  49232. * Empty line regex stored for GC.
  49233. */
  49234. private static _noneEmptyLineRegex;
  49235. private _engine;
  49236. /**
  49237. * Instantiates a ColorGradingTexture from the following parameters.
  49238. *
  49239. * @param url The location of the color gradind data (currently only supporting 3dl)
  49240. * @param scene The scene the texture will be used in
  49241. */
  49242. constructor(url: string, scene: Scene);
  49243. /**
  49244. * Returns the texture matrix used in most of the material.
  49245. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49246. */
  49247. getTextureMatrix(): Matrix;
  49248. /**
  49249. * Occurs when the file being loaded is a .3dl LUT file.
  49250. */
  49251. private load3dlTexture;
  49252. /**
  49253. * Starts the loading process of the texture.
  49254. */
  49255. private loadTexture;
  49256. /**
  49257. * Clones the color gradind texture.
  49258. */
  49259. clone(): ColorGradingTexture;
  49260. /**
  49261. * Called during delayed load for textures.
  49262. */
  49263. delayLoad(): void;
  49264. /**
  49265. * Parses a color grading texture serialized by Babylon.
  49266. * @param parsedTexture The texture information being parsedTexture
  49267. * @param scene The scene to load the texture in
  49268. * @param rootUrl The root url of the data assets to load
  49269. * @return A color gradind texture
  49270. */
  49271. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49272. /**
  49273. * Serializes the LUT texture to json format.
  49274. */
  49275. serialize(): any;
  49276. }
  49277. }
  49278. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  49279. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49280. import { Scene } from "babylonjs/scene";
  49281. import { Nullable } from "babylonjs/types";
  49282. /**
  49283. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49284. */
  49285. export class EquiRectangularCubeTexture extends BaseTexture {
  49286. /** The six faces of the cube. */
  49287. private static _FacesMapping;
  49288. private _noMipmap;
  49289. private _onLoad;
  49290. private _onError;
  49291. /** The size of the cubemap. */
  49292. private _size;
  49293. /** The buffer of the image. */
  49294. private _buffer;
  49295. /** The width of the input image. */
  49296. private _width;
  49297. /** The height of the input image. */
  49298. private _height;
  49299. /** The URL to the image. */
  49300. url: string;
  49301. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49302. coordinatesMode: number;
  49303. /**
  49304. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49305. * @param url The location of the image
  49306. * @param scene The scene the texture will be used in
  49307. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49308. * @param noMipmap Forces to not generate the mipmap if true
  49309. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49310. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49311. * @param onLoad — defines a callback called when texture is loaded
  49312. * @param onError — defines a callback called if there is an error
  49313. */
  49314. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49315. /**
  49316. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49317. */
  49318. private loadImage;
  49319. /**
  49320. * Convert the image buffer into a cubemap and create a CubeTexture.
  49321. */
  49322. private loadTexture;
  49323. /**
  49324. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49325. * @param buffer The ArrayBuffer that should be converted.
  49326. * @returns The buffer as Float32Array.
  49327. */
  49328. private getFloat32ArrayFromArrayBuffer;
  49329. /**
  49330. * Get the current class name of the texture useful for serialization or dynamic coding.
  49331. * @returns "EquiRectangularCubeTexture"
  49332. */
  49333. getClassName(): string;
  49334. /**
  49335. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49336. * @returns A clone of the current EquiRectangularCubeTexture.
  49337. */
  49338. clone(): EquiRectangularCubeTexture;
  49339. }
  49340. }
  49341. declare module "babylonjs/Misc/tga" {
  49342. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49343. /**
  49344. * Based on jsTGALoader - Javascript loader for TGA file
  49345. * By Vincent Thibault
  49346. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49347. */
  49348. export class TGATools {
  49349. private static _TYPE_INDEXED;
  49350. private static _TYPE_RGB;
  49351. private static _TYPE_GREY;
  49352. private static _TYPE_RLE_INDEXED;
  49353. private static _TYPE_RLE_RGB;
  49354. private static _TYPE_RLE_GREY;
  49355. private static _ORIGIN_MASK;
  49356. private static _ORIGIN_SHIFT;
  49357. private static _ORIGIN_BL;
  49358. private static _ORIGIN_BR;
  49359. private static _ORIGIN_UL;
  49360. private static _ORIGIN_UR;
  49361. /**
  49362. * Gets the header of a TGA file
  49363. * @param data defines the TGA data
  49364. * @returns the header
  49365. */
  49366. static GetTGAHeader(data: Uint8Array): any;
  49367. /**
  49368. * Uploads TGA content to a Babylon Texture
  49369. * @hidden
  49370. */
  49371. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49372. /** @hidden */
  49373. 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;
  49374. /** @hidden */
  49375. 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;
  49376. /** @hidden */
  49377. 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;
  49378. /** @hidden */
  49379. 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;
  49380. /** @hidden */
  49381. 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;
  49382. /** @hidden */
  49383. 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;
  49384. }
  49385. }
  49386. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49387. import { Nullable } from "babylonjs/types";
  49388. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49389. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49390. /**
  49391. * Implementation of the TGA Texture Loader.
  49392. * @hidden
  49393. */
  49394. export class _TGATextureLoader implements IInternalTextureLoader {
  49395. /**
  49396. * Defines wether the loader supports cascade loading the different faces.
  49397. */
  49398. readonly supportCascades: boolean;
  49399. /**
  49400. * This returns if the loader support the current file information.
  49401. * @param extension defines the file extension of the file being loaded
  49402. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49403. * @param fallback defines the fallback internal texture if any
  49404. * @param isBase64 defines whether the texture is encoded as a base64
  49405. * @param isBuffer defines whether the texture data are stored as a buffer
  49406. * @returns true if the loader can load the specified file
  49407. */
  49408. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49409. /**
  49410. * Transform the url before loading if required.
  49411. * @param rootUrl the url of the texture
  49412. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49413. * @returns the transformed texture
  49414. */
  49415. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49416. /**
  49417. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49418. * @param rootUrl the url of the texture
  49419. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49420. * @returns the fallback texture
  49421. */
  49422. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49423. /**
  49424. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49425. * @param data contains the texture data
  49426. * @param texture defines the BabylonJS internal texture
  49427. * @param createPolynomials will be true if polynomials have been requested
  49428. * @param onLoad defines the callback to trigger once the texture is ready
  49429. * @param onError defines the callback to trigger in case of error
  49430. */
  49431. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49432. /**
  49433. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49434. * @param data contains the texture data
  49435. * @param texture defines the BabylonJS internal texture
  49436. * @param callback defines the method to call once ready to upload
  49437. */
  49438. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49439. }
  49440. }
  49441. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49442. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49443. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49444. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49445. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49446. }
  49447. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49448. import { Scene } from "babylonjs/scene";
  49449. import { Texture } from "babylonjs/Materials/Textures/texture";
  49450. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49451. /**
  49452. * 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.
  49453. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49454. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49455. */
  49456. export class CustomProceduralTexture extends ProceduralTexture {
  49457. private _animate;
  49458. private _time;
  49459. private _config;
  49460. private _texturePath;
  49461. /**
  49462. * Instantiates a new Custom Procedural Texture.
  49463. * 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.
  49464. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49465. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49466. * @param name Define the name of the texture
  49467. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49468. * @param size Define the size of the texture to create
  49469. * @param scene Define the scene the texture belongs to
  49470. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49471. * @param generateMipMaps Define if the texture should creates mip maps or not
  49472. */
  49473. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49474. private _loadJson;
  49475. /**
  49476. * Is the texture ready to be used ? (rendered at least once)
  49477. * @returns true if ready, otherwise, false.
  49478. */
  49479. isReady(): boolean;
  49480. /**
  49481. * Render the texture to its associated render target.
  49482. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49483. */
  49484. render(useCameraPostProcess?: boolean): void;
  49485. /**
  49486. * Update the list of dependant textures samplers in the shader.
  49487. */
  49488. updateTextures(): void;
  49489. /**
  49490. * Update the uniform values of the procedural texture in the shader.
  49491. */
  49492. updateShaderUniforms(): void;
  49493. /**
  49494. * Define if the texture animates or not.
  49495. */
  49496. animate: boolean;
  49497. }
  49498. }
  49499. declare module "babylonjs/Shaders/noise.fragment" {
  49500. /** @hidden */
  49501. export var noisePixelShader: {
  49502. name: string;
  49503. shader: string;
  49504. };
  49505. }
  49506. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49507. import { Nullable } from "babylonjs/types";
  49508. import { Scene } from "babylonjs/scene";
  49509. import { Texture } from "babylonjs/Materials/Textures/texture";
  49510. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49511. import "babylonjs/Shaders/noise.fragment";
  49512. /**
  49513. * Class used to generate noise procedural textures
  49514. */
  49515. export class NoiseProceduralTexture extends ProceduralTexture {
  49516. private _time;
  49517. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49518. brightness: number;
  49519. /** Defines the number of octaves to process */
  49520. octaves: number;
  49521. /** Defines the level of persistence (0.8 by default) */
  49522. persistence: number;
  49523. /** Gets or sets animation speed factor (default is 1) */
  49524. animationSpeedFactor: number;
  49525. /**
  49526. * Creates a new NoiseProceduralTexture
  49527. * @param name defines the name fo the texture
  49528. * @param size defines the size of the texture (default is 256)
  49529. * @param scene defines the hosting scene
  49530. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49531. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49532. */
  49533. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49534. private _updateShaderUniforms;
  49535. protected _getDefines(): string;
  49536. /** Generate the current state of the procedural texture */
  49537. render(useCameraPostProcess?: boolean): void;
  49538. /**
  49539. * Serializes this noise procedural texture
  49540. * @returns a serialized noise procedural texture object
  49541. */
  49542. serialize(): any;
  49543. /**
  49544. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49545. * @param parsedTexture defines parsed texture data
  49546. * @param scene defines the current scene
  49547. * @param rootUrl defines the root URL containing noise procedural texture information
  49548. * @returns a parsed NoiseProceduralTexture
  49549. */
  49550. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49551. }
  49552. }
  49553. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49554. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49555. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49556. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49557. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49558. }
  49559. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49560. import { Nullable } from "babylonjs/types";
  49561. import { Scene } from "babylonjs/scene";
  49562. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49563. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49564. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49565. /**
  49566. * Raw cube texture where the raw buffers are passed in
  49567. */
  49568. export class RawCubeTexture extends CubeTexture {
  49569. /**
  49570. * Creates a cube texture where the raw buffers are passed in.
  49571. * @param scene defines the scene the texture is attached to
  49572. * @param data defines the array of data to use to create each face
  49573. * @param size defines the size of the textures
  49574. * @param format defines the format of the data
  49575. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49576. * @param generateMipMaps defines if the engine should generate the mip levels
  49577. * @param invertY defines if data must be stored with Y axis inverted
  49578. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49579. * @param compression defines the compression used (null by default)
  49580. */
  49581. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49582. /**
  49583. * Updates the raw cube texture.
  49584. * @param data defines the data to store
  49585. * @param format defines the data format
  49586. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49587. * @param invertY defines if data must be stored with Y axis inverted
  49588. * @param compression defines the compression used (null by default)
  49589. * @param level defines which level of the texture to update
  49590. */
  49591. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49592. /**
  49593. * Updates a raw cube texture with RGBD encoded data.
  49594. * @param data defines the array of data [mipmap][face] to use to create each face
  49595. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49596. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49597. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49598. * @returns a promsie that resolves when the operation is complete
  49599. */
  49600. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49601. /**
  49602. * Clones the raw cube texture.
  49603. * @return a new cube texture
  49604. */
  49605. clone(): CubeTexture;
  49606. /** @hidden */
  49607. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49608. }
  49609. }
  49610. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49611. import { Scene } from "babylonjs/scene";
  49612. import { Texture } from "babylonjs/Materials/Textures/texture";
  49613. /**
  49614. * Class used to store 3D textures containing user data
  49615. */
  49616. export class RawTexture3D extends Texture {
  49617. /** Gets or sets the texture format to use */
  49618. format: number;
  49619. private _engine;
  49620. /**
  49621. * Create a new RawTexture3D
  49622. * @param data defines the data of the texture
  49623. * @param width defines the width of the texture
  49624. * @param height defines the height of the texture
  49625. * @param depth defines the depth of the texture
  49626. * @param format defines the texture format to use
  49627. * @param scene defines the hosting scene
  49628. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49629. * @param invertY defines if texture must be stored with Y axis inverted
  49630. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49631. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49632. */
  49633. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49634. /** Gets or sets the texture format to use */
  49635. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49636. /**
  49637. * Update the texture with new data
  49638. * @param data defines the data to store in the texture
  49639. */
  49640. update(data: ArrayBufferView): void;
  49641. }
  49642. }
  49643. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49644. import { Scene } from "babylonjs/scene";
  49645. import { Plane } from "babylonjs/Maths/math";
  49646. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49647. /**
  49648. * Creates a refraction texture used by refraction channel of the standard material.
  49649. * It is like a mirror but to see through a material.
  49650. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49651. */
  49652. export class RefractionTexture extends RenderTargetTexture {
  49653. /**
  49654. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49655. * 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.
  49656. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49657. */
  49658. refractionPlane: Plane;
  49659. /**
  49660. * Define how deep under the surface we should see.
  49661. */
  49662. depth: number;
  49663. /**
  49664. * Creates a refraction texture used by refraction channel of the standard material.
  49665. * It is like a mirror but to see through a material.
  49666. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49667. * @param name Define the texture name
  49668. * @param size Define the size of the underlying texture
  49669. * @param scene Define the scene the refraction belongs to
  49670. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49671. */
  49672. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49673. /**
  49674. * Clone the refraction texture.
  49675. * @returns the cloned texture
  49676. */
  49677. clone(): RefractionTexture;
  49678. /**
  49679. * Serialize the texture to a JSON representation you could use in Parse later on
  49680. * @returns the serialized JSON representation
  49681. */
  49682. serialize(): any;
  49683. }
  49684. }
  49685. declare module "babylonjs/Materials/Textures/index" {
  49686. export * from "babylonjs/Materials/Textures/baseTexture";
  49687. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49688. export * from "babylonjs/Materials/Textures/cubeTexture";
  49689. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49690. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  49691. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49692. export * from "babylonjs/Materials/Textures/internalTexture";
  49693. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49694. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49695. export * from "babylonjs/Materials/Textures/Loaders/index";
  49696. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49697. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49698. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49699. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49700. export * from "babylonjs/Materials/Textures/rawTexture";
  49701. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49702. export * from "babylonjs/Materials/Textures/refractionTexture";
  49703. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49704. export * from "babylonjs/Materials/Textures/texture";
  49705. export * from "babylonjs/Materials/Textures/videoTexture";
  49706. }
  49707. declare module "babylonjs/Materials/index" {
  49708. export * from "babylonjs/Materials/Background/index";
  49709. export * from "babylonjs/Materials/colorCurves";
  49710. export * from "babylonjs/Materials/effect";
  49711. export * from "babylonjs/Materials/fresnelParameters";
  49712. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49713. export * from "babylonjs/Materials/material";
  49714. export * from "babylonjs/Materials/materialDefines";
  49715. export * from "babylonjs/Materials/materialHelper";
  49716. export * from "babylonjs/Materials/multiMaterial";
  49717. export * from "babylonjs/Materials/PBR/index";
  49718. export * from "babylonjs/Materials/pushMaterial";
  49719. export * from "babylonjs/Materials/shaderMaterial";
  49720. export * from "babylonjs/Materials/standardMaterial";
  49721. export * from "babylonjs/Materials/Textures/index";
  49722. export * from "babylonjs/Materials/uniformBuffer";
  49723. export * from "babylonjs/Materials/materialFlags";
  49724. }
  49725. declare module "babylonjs/Maths/index" {
  49726. export * from "babylonjs/Maths/math.scalar";
  49727. export * from "babylonjs/Maths/math";
  49728. export * from "babylonjs/Maths/sphericalPolynomial";
  49729. }
  49730. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49731. import { IDisposable } from "babylonjs/scene";
  49732. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49733. /**
  49734. * Configuration for Draco compression
  49735. */
  49736. export interface IDracoCompressionConfiguration {
  49737. /**
  49738. * Configuration for the decoder.
  49739. */
  49740. decoder?: {
  49741. /**
  49742. * The url to the WebAssembly module.
  49743. */
  49744. wasmUrl?: string;
  49745. /**
  49746. * The url to the WebAssembly binary.
  49747. */
  49748. wasmBinaryUrl?: string;
  49749. /**
  49750. * The url to the fallback JavaScript module.
  49751. */
  49752. fallbackUrl?: string;
  49753. };
  49754. }
  49755. /**
  49756. * Draco compression (https://google.github.io/draco/)
  49757. *
  49758. * This class wraps the Draco module.
  49759. *
  49760. * **Encoder**
  49761. *
  49762. * The encoder is not currently implemented.
  49763. *
  49764. * **Decoder**
  49765. *
  49766. * 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.
  49767. *
  49768. * To update the configuration, use the following code:
  49769. * ```javascript
  49770. * DracoCompression.Configuration = {
  49771. * decoder: {
  49772. * wasmUrl: "<url to the WebAssembly library>",
  49773. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49774. * fallbackUrl: "<url to the fallback JavaScript library>",
  49775. * }
  49776. * };
  49777. * ```
  49778. *
  49779. * 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.
  49780. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49781. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49782. *
  49783. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49784. * ```javascript
  49785. * var dracoCompression = new DracoCompression();
  49786. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49787. * [VertexBuffer.PositionKind]: 0
  49788. * });
  49789. * ```
  49790. *
  49791. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49792. */
  49793. export class DracoCompression implements IDisposable {
  49794. private static _DecoderModulePromise;
  49795. /**
  49796. * The configuration. Defaults to the following urls:
  49797. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49798. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49799. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49800. */
  49801. static Configuration: IDracoCompressionConfiguration;
  49802. /**
  49803. * Returns true if the decoder is available.
  49804. */
  49805. static readonly DecoderAvailable: boolean;
  49806. /**
  49807. * Constructor
  49808. */
  49809. constructor();
  49810. /**
  49811. * Stop all async operations and release resources.
  49812. */
  49813. dispose(): void;
  49814. /**
  49815. * Decode Draco compressed mesh data to vertex data.
  49816. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49817. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49818. * @returns A promise that resolves with the decoded vertex data
  49819. */
  49820. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49821. [kind: string]: number;
  49822. }): Promise<VertexData>;
  49823. private static _GetDecoderModule;
  49824. private static _LoadScriptAsync;
  49825. private static _LoadFileAsync;
  49826. }
  49827. }
  49828. declare module "babylonjs/Meshes/Compression/index" {
  49829. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49830. }
  49831. declare module "babylonjs/Meshes/csg" {
  49832. import { Nullable } from "babylonjs/types";
  49833. import { Scene } from "babylonjs/scene";
  49834. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49835. import { Mesh } from "babylonjs/Meshes/mesh";
  49836. import { Material } from "babylonjs/Materials/material";
  49837. /**
  49838. * Class for building Constructive Solid Geometry
  49839. */
  49840. export class CSG {
  49841. private polygons;
  49842. /**
  49843. * The world matrix
  49844. */
  49845. matrix: Matrix;
  49846. /**
  49847. * Stores the position
  49848. */
  49849. position: Vector3;
  49850. /**
  49851. * Stores the rotation
  49852. */
  49853. rotation: Vector3;
  49854. /**
  49855. * Stores the rotation quaternion
  49856. */
  49857. rotationQuaternion: Nullable<Quaternion>;
  49858. /**
  49859. * Stores the scaling vector
  49860. */
  49861. scaling: Vector3;
  49862. /**
  49863. * Convert the Mesh to CSG
  49864. * @param mesh The Mesh to convert to CSG
  49865. * @returns A new CSG from the Mesh
  49866. */
  49867. static FromMesh(mesh: Mesh): CSG;
  49868. /**
  49869. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49870. * @param polygons Polygons used to construct a CSG solid
  49871. */
  49872. private static FromPolygons;
  49873. /**
  49874. * Clones, or makes a deep copy, of the CSG
  49875. * @returns A new CSG
  49876. */
  49877. clone(): CSG;
  49878. /**
  49879. * Unions this CSG with another CSG
  49880. * @param csg The CSG to union against this CSG
  49881. * @returns The unioned CSG
  49882. */
  49883. union(csg: CSG): CSG;
  49884. /**
  49885. * Unions this CSG with another CSG in place
  49886. * @param csg The CSG to union against this CSG
  49887. */
  49888. unionInPlace(csg: CSG): void;
  49889. /**
  49890. * Subtracts this CSG with another CSG
  49891. * @param csg The CSG to subtract against this CSG
  49892. * @returns A new CSG
  49893. */
  49894. subtract(csg: CSG): CSG;
  49895. /**
  49896. * Subtracts this CSG with another CSG in place
  49897. * @param csg The CSG to subtact against this CSG
  49898. */
  49899. subtractInPlace(csg: CSG): void;
  49900. /**
  49901. * Intersect this CSG with another CSG
  49902. * @param csg The CSG to intersect against this CSG
  49903. * @returns A new CSG
  49904. */
  49905. intersect(csg: CSG): CSG;
  49906. /**
  49907. * Intersects this CSG with another CSG in place
  49908. * @param csg The CSG to intersect against this CSG
  49909. */
  49910. intersectInPlace(csg: CSG): void;
  49911. /**
  49912. * Return a new CSG solid with solid and empty space switched. This solid is
  49913. * not modified.
  49914. * @returns A new CSG solid with solid and empty space switched
  49915. */
  49916. inverse(): CSG;
  49917. /**
  49918. * Inverses the CSG in place
  49919. */
  49920. inverseInPlace(): void;
  49921. /**
  49922. * This is used to keep meshes transformations so they can be restored
  49923. * when we build back a Babylon Mesh
  49924. * NB : All CSG operations are performed in world coordinates
  49925. * @param csg The CSG to copy the transform attributes from
  49926. * @returns This CSG
  49927. */
  49928. copyTransformAttributes(csg: CSG): CSG;
  49929. /**
  49930. * Build Raw mesh from CSG
  49931. * Coordinates here are in world space
  49932. * @param name The name of the mesh geometry
  49933. * @param scene The Scene
  49934. * @param keepSubMeshes Specifies if the submeshes should be kept
  49935. * @returns A new Mesh
  49936. */
  49937. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49938. /**
  49939. * Build Mesh from CSG taking material and transforms into account
  49940. * @param name The name of the Mesh
  49941. * @param material The material of the Mesh
  49942. * @param scene The Scene
  49943. * @param keepSubMeshes Specifies if submeshes should be kept
  49944. * @returns The new Mesh
  49945. */
  49946. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49947. }
  49948. }
  49949. declare module "babylonjs/Meshes/trailMesh" {
  49950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49951. import { Mesh } from "babylonjs/Meshes/mesh";
  49952. import { Scene } from "babylonjs/scene";
  49953. /**
  49954. * Class used to create a trail following a mesh
  49955. */
  49956. export class TrailMesh extends Mesh {
  49957. private _generator;
  49958. private _autoStart;
  49959. private _running;
  49960. private _diameter;
  49961. private _length;
  49962. private _sectionPolygonPointsCount;
  49963. private _sectionVectors;
  49964. private _sectionNormalVectors;
  49965. private _beforeRenderObserver;
  49966. /**
  49967. * @constructor
  49968. * @param name The value used by scene.getMeshByName() to do a lookup.
  49969. * @param generator The mesh to generate a trail.
  49970. * @param scene The scene to add this mesh to.
  49971. * @param diameter Diameter of trailing mesh. Default is 1.
  49972. * @param length Length of trailing mesh. Default is 60.
  49973. * @param autoStart Automatically start trailing mesh. Default true.
  49974. */
  49975. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49976. /**
  49977. * "TrailMesh"
  49978. * @returns "TrailMesh"
  49979. */
  49980. getClassName(): string;
  49981. private _createMesh;
  49982. /**
  49983. * Start trailing mesh.
  49984. */
  49985. start(): void;
  49986. /**
  49987. * Stop trailing mesh.
  49988. */
  49989. stop(): void;
  49990. /**
  49991. * Update trailing mesh geometry.
  49992. */
  49993. update(): void;
  49994. /**
  49995. * Returns a new TrailMesh object.
  49996. * @param name is a string, the name given to the new mesh
  49997. * @param newGenerator use new generator object for cloned trail mesh
  49998. * @returns a new mesh
  49999. */
  50000. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50001. /**
  50002. * Serializes this trail mesh
  50003. * @param serializationObject object to write serialization to
  50004. */
  50005. serialize(serializationObject: any): void;
  50006. /**
  50007. * Parses a serialized trail mesh
  50008. * @param parsedMesh the serialized mesh
  50009. * @param scene the scene to create the trail mesh in
  50010. * @returns the created trail mesh
  50011. */
  50012. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50013. }
  50014. }
  50015. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50016. import { Nullable } from "babylonjs/types";
  50017. import { Scene } from "babylonjs/scene";
  50018. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50019. import { Mesh } from "babylonjs/Meshes/mesh";
  50020. /**
  50021. * Class containing static functions to help procedurally build meshes
  50022. */
  50023. export class RibbonBuilder {
  50024. /**
  50025. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50026. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50027. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50028. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50029. * * 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
  50030. * * 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
  50031. * * 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
  50032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50034. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50035. * * 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
  50036. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50037. * * 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
  50038. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50040. * @param name defines the name of the mesh
  50041. * @param options defines the options used to create the mesh
  50042. * @param scene defines the hosting scene
  50043. * @returns the ribbon mesh
  50044. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50045. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50046. */
  50047. static CreateRibbon(name: string, options: {
  50048. pathArray: Vector3[][];
  50049. closeArray?: boolean;
  50050. closePath?: boolean;
  50051. offset?: number;
  50052. updatable?: boolean;
  50053. sideOrientation?: number;
  50054. frontUVs?: Vector4;
  50055. backUVs?: Vector4;
  50056. instance?: Mesh;
  50057. invertUV?: boolean;
  50058. uvs?: Vector2[];
  50059. colors?: Color4[];
  50060. }, scene?: Nullable<Scene>): Mesh;
  50061. }
  50062. }
  50063. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  50064. import { Vector4 } from "babylonjs/Maths/math";
  50065. import { Mesh } from "babylonjs/Meshes/mesh";
  50066. /**
  50067. * Class containing static functions to help procedurally build meshes
  50068. */
  50069. export class TorusKnotBuilder {
  50070. /**
  50071. * Creates a torus knot mesh
  50072. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50073. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50074. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50075. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50079. * @param name defines the name of the mesh
  50080. * @param options defines the options used to create the mesh
  50081. * @param scene defines the hosting scene
  50082. * @returns the torus knot mesh
  50083. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50084. */
  50085. static CreateTorusKnot(name: string, options: {
  50086. radius?: number;
  50087. tube?: number;
  50088. radialSegments?: number;
  50089. tubularSegments?: number;
  50090. p?: number;
  50091. q?: number;
  50092. updatable?: boolean;
  50093. sideOrientation?: number;
  50094. frontUVs?: Vector4;
  50095. backUVs?: Vector4;
  50096. }, scene: any): Mesh;
  50097. }
  50098. }
  50099. declare module "babylonjs/Meshes/polygonMesh" {
  50100. import { Scene } from "babylonjs/scene";
  50101. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50102. import { Mesh } from "babylonjs/Meshes/mesh";
  50103. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50104. /**
  50105. * Polygon
  50106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50107. */
  50108. export class Polygon {
  50109. /**
  50110. * Creates a rectangle
  50111. * @param xmin bottom X coord
  50112. * @param ymin bottom Y coord
  50113. * @param xmax top X coord
  50114. * @param ymax top Y coord
  50115. * @returns points that make the resulting rectation
  50116. */
  50117. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50118. /**
  50119. * Creates a circle
  50120. * @param radius radius of circle
  50121. * @param cx scale in x
  50122. * @param cy scale in y
  50123. * @param numberOfSides number of sides that make up the circle
  50124. * @returns points that make the resulting circle
  50125. */
  50126. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50127. /**
  50128. * Creates a polygon from input string
  50129. * @param input Input polygon data
  50130. * @returns the parsed points
  50131. */
  50132. static Parse(input: string): Vector2[];
  50133. /**
  50134. * Starts building a polygon from x and y coordinates
  50135. * @param x x coordinate
  50136. * @param y y coordinate
  50137. * @returns the started path2
  50138. */
  50139. static StartingAt(x: number, y: number): Path2;
  50140. }
  50141. /**
  50142. * Builds a polygon
  50143. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50144. */
  50145. export class PolygonMeshBuilder {
  50146. private _points;
  50147. private _outlinepoints;
  50148. private _holes;
  50149. private _name;
  50150. private _scene;
  50151. private _epoints;
  50152. private _eholes;
  50153. private _addToepoint;
  50154. /**
  50155. * Babylon reference to the earcut plugin.
  50156. */
  50157. bjsEarcut: any;
  50158. /**
  50159. * Creates a PolygonMeshBuilder
  50160. * @param name name of the builder
  50161. * @param contours Path of the polygon
  50162. * @param scene scene to add to
  50163. * @param earcutInjection can be used to inject your own earcut reference
  50164. */
  50165. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  50166. /**
  50167. * Adds a whole within the polygon
  50168. * @param hole Array of points defining the hole
  50169. * @returns this
  50170. */
  50171. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50172. /**
  50173. * Creates the polygon
  50174. * @param updatable If the mesh should be updatable
  50175. * @param depth The depth of the mesh created
  50176. * @returns the created mesh
  50177. */
  50178. build(updatable?: boolean, depth?: number): Mesh;
  50179. /**
  50180. * Creates the polygon
  50181. * @param depth The depth of the mesh created
  50182. * @returns the created VertexData
  50183. */
  50184. buildVertexData(depth?: number): VertexData;
  50185. /**
  50186. * Adds a side to the polygon
  50187. * @param positions points that make the polygon
  50188. * @param normals normals of the polygon
  50189. * @param uvs uvs of the polygon
  50190. * @param indices indices of the polygon
  50191. * @param bounds bounds of the polygon
  50192. * @param points points of the polygon
  50193. * @param depth depth of the polygon
  50194. * @param flip flip of the polygon
  50195. */
  50196. private addSide;
  50197. }
  50198. }
  50199. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50200. import { Scene } from "babylonjs/scene";
  50201. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50202. import { Mesh } from "babylonjs/Meshes/mesh";
  50203. /**
  50204. * Class containing static functions to help procedurally build meshes
  50205. */
  50206. export class PolygonBuilder {
  50207. /**
  50208. * Creates a polygon mesh
  50209. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50210. * * 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
  50211. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50214. * * Remember you can only change the shape positions, not their number when updating a polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  50219. * @returns the polygon mesh
  50220. */
  50221. static CreatePolygon(name: string, options: {
  50222. shape: Vector3[];
  50223. holes?: Vector3[][];
  50224. depth?: number;
  50225. faceUV?: Vector4[];
  50226. faceColors?: Color4[];
  50227. updatable?: boolean;
  50228. sideOrientation?: number;
  50229. frontUVs?: Vector4;
  50230. backUVs?: Vector4;
  50231. }, scene: Scene, earcutInjection?: any): Mesh;
  50232. /**
  50233. * Creates an extruded polygon mesh, with depth in the Y direction.
  50234. * * 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)
  50235. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50236. * @param name defines the name of the mesh
  50237. * @param options defines the options used to create the mesh
  50238. * @param scene defines the hosting scene
  50239. * @param earcutInjection can be used to inject your own earcut reference
  50240. * @returns the polygon mesh
  50241. */
  50242. static ExtrudePolygon(name: string, options: {
  50243. shape: Vector3[];
  50244. holes?: Vector3[][];
  50245. depth?: number;
  50246. faceUV?: Vector4[];
  50247. faceColors?: Color4[];
  50248. updatable?: boolean;
  50249. sideOrientation?: number;
  50250. frontUVs?: Vector4;
  50251. backUVs?: Vector4;
  50252. }, scene: Scene, earcutInjection?: any): Mesh;
  50253. }
  50254. }
  50255. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50256. import { Nullable } from "babylonjs/types";
  50257. import { Scene } from "babylonjs/scene";
  50258. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50259. import { Mesh } from "babylonjs/Meshes/mesh";
  50260. /**
  50261. * Class containing static functions to help procedurally build meshes
  50262. */
  50263. export class ShapeBuilder {
  50264. /**
  50265. * 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.
  50266. * * 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.
  50267. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50268. * * 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.
  50269. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50270. * * 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
  50271. * * 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
  50272. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50277. * @param name defines the name of the mesh
  50278. * @param options defines the options used to create the mesh
  50279. * @param scene defines the hosting scene
  50280. * @returns the extruded shape mesh
  50281. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50283. */
  50284. static ExtrudeShape(name: string, options: {
  50285. shape: Vector3[];
  50286. path: Vector3[];
  50287. scale?: number;
  50288. rotation?: number;
  50289. cap?: number;
  50290. updatable?: boolean;
  50291. sideOrientation?: number;
  50292. frontUVs?: Vector4;
  50293. backUVs?: Vector4;
  50294. instance?: Mesh;
  50295. invertUV?: boolean;
  50296. }, scene?: Nullable<Scene>): Mesh;
  50297. /**
  50298. * Creates an custom extruded shape mesh.
  50299. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50300. * * 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.
  50301. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50302. * * 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
  50303. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50304. * * 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
  50305. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50306. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50307. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50308. * * 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
  50309. * * 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
  50310. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50312. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50313. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50315. * @param name defines the name of the mesh
  50316. * @param options defines the options used to create the mesh
  50317. * @param scene defines the hosting scene
  50318. * @returns the custom extruded shape mesh
  50319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50320. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50321. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50322. */
  50323. static ExtrudeShapeCustom(name: string, options: {
  50324. shape: Vector3[];
  50325. path: Vector3[];
  50326. scaleFunction?: any;
  50327. rotationFunction?: any;
  50328. ribbonCloseArray?: boolean;
  50329. ribbonClosePath?: boolean;
  50330. cap?: number;
  50331. updatable?: boolean;
  50332. sideOrientation?: number;
  50333. frontUVs?: Vector4;
  50334. backUVs?: Vector4;
  50335. instance?: Mesh;
  50336. invertUV?: boolean;
  50337. }, scene: Scene): Mesh;
  50338. private static _ExtrudeShapeGeneric;
  50339. }
  50340. }
  50341. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50342. import { Scene } from "babylonjs/scene";
  50343. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50344. import { Mesh } from "babylonjs/Meshes/mesh";
  50345. /**
  50346. * Class containing static functions to help procedurally build meshes
  50347. */
  50348. export class LatheBuilder {
  50349. /**
  50350. * Creates lathe mesh.
  50351. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50352. * * 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
  50353. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50354. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50355. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50356. * * 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
  50357. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50358. * * 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
  50359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50361. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50363. * @param name defines the name of the mesh
  50364. * @param options defines the options used to create the mesh
  50365. * @param scene defines the hosting scene
  50366. * @returns the lathe mesh
  50367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50368. */
  50369. static CreateLathe(name: string, options: {
  50370. shape: Vector3[];
  50371. radius?: number;
  50372. tessellation?: number;
  50373. clip?: number;
  50374. arc?: number;
  50375. closed?: boolean;
  50376. updatable?: boolean;
  50377. sideOrientation?: number;
  50378. frontUVs?: Vector4;
  50379. backUVs?: Vector4;
  50380. cap?: number;
  50381. invertUV?: boolean;
  50382. }, scene: Scene): Mesh;
  50383. }
  50384. }
  50385. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50386. import { Scene } from "babylonjs/scene";
  50387. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50388. import { Mesh } from "babylonjs/Meshes/mesh";
  50389. /**
  50390. * Class containing static functions to help procedurally build meshes
  50391. */
  50392. export class TubeBuilder {
  50393. /**
  50394. * Creates a tube mesh.
  50395. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50396. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50397. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50398. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50399. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50400. * * 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)
  50401. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50402. * * 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
  50403. * * 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
  50404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50406. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50408. * @param name defines the name of the mesh
  50409. * @param options defines the options used to create the mesh
  50410. * @param scene defines the hosting scene
  50411. * @returns the tube mesh
  50412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50413. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50414. */
  50415. static CreateTube(name: string, options: {
  50416. path: Vector3[];
  50417. radius?: number;
  50418. tessellation?: number;
  50419. radiusFunction?: {
  50420. (i: number, distance: number): number;
  50421. };
  50422. cap?: number;
  50423. arc?: number;
  50424. updatable?: boolean;
  50425. sideOrientation?: number;
  50426. frontUVs?: Vector4;
  50427. backUVs?: Vector4;
  50428. instance?: Mesh;
  50429. invertUV?: boolean;
  50430. }, scene: Scene): Mesh;
  50431. }
  50432. }
  50433. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50434. import { Scene } from "babylonjs/scene";
  50435. import { Vector4 } from "babylonjs/Maths/math";
  50436. import { Mesh } from "babylonjs/Meshes/mesh";
  50437. /**
  50438. * Class containing static functions to help procedurally build meshes
  50439. */
  50440. export class IcoSphereBuilder {
  50441. /**
  50442. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50443. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50444. * * 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`)
  50445. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50446. * * 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
  50447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50450. * @param name defines the name of the mesh
  50451. * @param options defines the options used to create the mesh
  50452. * @param scene defines the hosting scene
  50453. * @returns the icosahedron mesh
  50454. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50455. */
  50456. static CreateIcoSphere(name: string, options: {
  50457. radius?: number;
  50458. radiusX?: number;
  50459. radiusY?: number;
  50460. radiusZ?: number;
  50461. flat?: boolean;
  50462. subdivisions?: number;
  50463. sideOrientation?: number;
  50464. frontUVs?: Vector4;
  50465. backUVs?: Vector4;
  50466. updatable?: boolean;
  50467. }, scene: Scene): Mesh;
  50468. }
  50469. }
  50470. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50471. import { Vector3 } from "babylonjs/Maths/math";
  50472. import { Mesh } from "babylonjs/Meshes/mesh";
  50473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50474. /**
  50475. * Class containing static functions to help procedurally build meshes
  50476. */
  50477. export class DecalBuilder {
  50478. /**
  50479. * Creates a decal mesh.
  50480. * 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
  50481. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50482. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50483. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50484. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50485. * @param name defines the name of the mesh
  50486. * @param sourceMesh defines the mesh where the decal must be applied
  50487. * @param options defines the options used to create the mesh
  50488. * @param scene defines the hosting scene
  50489. * @returns the decal mesh
  50490. * @see https://doc.babylonjs.com/how_to/decals
  50491. */
  50492. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50493. position?: Vector3;
  50494. normal?: Vector3;
  50495. size?: Vector3;
  50496. angle?: number;
  50497. }): Mesh;
  50498. }
  50499. }
  50500. declare module "babylonjs/Meshes/meshBuilder" {
  50501. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50502. import { Nullable } from "babylonjs/types";
  50503. import { Scene } from "babylonjs/scene";
  50504. import { Mesh } from "babylonjs/Meshes/mesh";
  50505. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50506. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50508. /**
  50509. * Class containing static functions to help procedurally build meshes
  50510. */
  50511. export class MeshBuilder {
  50512. /**
  50513. * Creates a box mesh
  50514. * * The parameter `size` sets the size (float) of each box side (default 1)
  50515. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50516. * * 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)
  50517. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50521. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50522. * @param name defines the name of the mesh
  50523. * @param options defines the options used to create the mesh
  50524. * @param scene defines the hosting scene
  50525. * @returns the box mesh
  50526. */
  50527. static CreateBox(name: string, options: {
  50528. size?: number;
  50529. width?: number;
  50530. height?: number;
  50531. depth?: number;
  50532. faceUV?: Vector4[];
  50533. faceColors?: Color4[];
  50534. sideOrientation?: number;
  50535. frontUVs?: Vector4;
  50536. backUVs?: Vector4;
  50537. updatable?: boolean;
  50538. }, scene?: Nullable<Scene>): Mesh;
  50539. /**
  50540. * Creates a sphere mesh
  50541. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50542. * * 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`)
  50543. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50544. * * 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
  50545. * * 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)
  50546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50549. * @param name defines the name of the mesh
  50550. * @param options defines the options used to create the mesh
  50551. * @param scene defines the hosting scene
  50552. * @returns the sphere mesh
  50553. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50554. */
  50555. static CreateSphere(name: string, options: {
  50556. segments?: number;
  50557. diameter?: number;
  50558. diameterX?: number;
  50559. diameterY?: number;
  50560. diameterZ?: number;
  50561. arc?: number;
  50562. slice?: number;
  50563. sideOrientation?: number;
  50564. frontUVs?: Vector4;
  50565. backUVs?: Vector4;
  50566. updatable?: boolean;
  50567. }, scene: any): Mesh;
  50568. /**
  50569. * Creates a plane polygonal mesh. By default, this is a disc
  50570. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50571. * * 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
  50572. * * 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
  50573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50574. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50576. * @param name defines the name of the mesh
  50577. * @param options defines the options used to create the mesh
  50578. * @param scene defines the hosting scene
  50579. * @returns the plane polygonal mesh
  50580. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50581. */
  50582. static CreateDisc(name: string, options: {
  50583. radius?: number;
  50584. tessellation?: number;
  50585. arc?: number;
  50586. updatable?: boolean;
  50587. sideOrientation?: number;
  50588. frontUVs?: Vector4;
  50589. backUVs?: Vector4;
  50590. }, scene?: Nullable<Scene>): Mesh;
  50591. /**
  50592. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50593. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50594. * * 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`)
  50595. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50596. * * 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
  50597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50600. * @param name defines the name of the mesh
  50601. * @param options defines the options used to create the mesh
  50602. * @param scene defines the hosting scene
  50603. * @returns the icosahedron mesh
  50604. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50605. */
  50606. static CreateIcoSphere(name: string, options: {
  50607. radius?: number;
  50608. radiusX?: number;
  50609. radiusY?: number;
  50610. radiusZ?: number;
  50611. flat?: boolean;
  50612. subdivisions?: number;
  50613. sideOrientation?: number;
  50614. frontUVs?: Vector4;
  50615. backUVs?: Vector4;
  50616. updatable?: boolean;
  50617. }, scene: Scene): Mesh;
  50618. /**
  50619. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50620. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50621. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50622. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50623. * * 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
  50624. * * 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
  50625. * * 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
  50626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50628. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50629. * * 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
  50630. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50631. * * 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
  50632. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50634. * @param name defines the name of the mesh
  50635. * @param options defines the options used to create the mesh
  50636. * @param scene defines the hosting scene
  50637. * @returns the ribbon mesh
  50638. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50640. */
  50641. static CreateRibbon(name: string, options: {
  50642. pathArray: Vector3[][];
  50643. closeArray?: boolean;
  50644. closePath?: boolean;
  50645. offset?: number;
  50646. updatable?: boolean;
  50647. sideOrientation?: number;
  50648. frontUVs?: Vector4;
  50649. backUVs?: Vector4;
  50650. instance?: Mesh;
  50651. invertUV?: boolean;
  50652. uvs?: Vector2[];
  50653. colors?: Color4[];
  50654. }, scene?: Nullable<Scene>): Mesh;
  50655. /**
  50656. * Creates a cylinder or a cone mesh
  50657. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50658. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50659. * * 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.
  50660. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50661. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50662. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50663. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50664. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50665. * * 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).
  50666. * * 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
  50667. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50668. * * 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
  50669. * * 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.
  50670. * * If `enclose` is false, a ring surface is one element.
  50671. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50672. * * 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
  50673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50676. * @param name defines the name of the mesh
  50677. * @param options defines the options used to create the mesh
  50678. * @param scene defines the hosting scene
  50679. * @returns the cylinder mesh
  50680. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50681. */
  50682. static CreateCylinder(name: string, options: {
  50683. height?: number;
  50684. diameterTop?: number;
  50685. diameterBottom?: number;
  50686. diameter?: number;
  50687. tessellation?: number;
  50688. subdivisions?: number;
  50689. arc?: number;
  50690. faceColors?: Color4[];
  50691. faceUV?: Vector4[];
  50692. updatable?: boolean;
  50693. hasRings?: boolean;
  50694. enclose?: boolean;
  50695. sideOrientation?: number;
  50696. frontUVs?: Vector4;
  50697. backUVs?: Vector4;
  50698. }, scene: any): Mesh;
  50699. /**
  50700. * Creates a torus mesh
  50701. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50702. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50703. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50707. * @param name defines the name of the mesh
  50708. * @param options defines the options used to create the mesh
  50709. * @param scene defines the hosting scene
  50710. * @returns the torus mesh
  50711. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50712. */
  50713. static CreateTorus(name: string, options: {
  50714. diameter?: number;
  50715. thickness?: number;
  50716. tessellation?: number;
  50717. updatable?: boolean;
  50718. sideOrientation?: number;
  50719. frontUVs?: Vector4;
  50720. backUVs?: Vector4;
  50721. }, scene: any): Mesh;
  50722. /**
  50723. * Creates a torus knot mesh
  50724. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50725. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50726. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50727. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50731. * @param name defines the name of the mesh
  50732. * @param options defines the options used to create the mesh
  50733. * @param scene defines the hosting scene
  50734. * @returns the torus knot mesh
  50735. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50736. */
  50737. static CreateTorusKnot(name: string, options: {
  50738. radius?: number;
  50739. tube?: number;
  50740. radialSegments?: number;
  50741. tubularSegments?: number;
  50742. p?: number;
  50743. q?: number;
  50744. updatable?: boolean;
  50745. sideOrientation?: number;
  50746. frontUVs?: Vector4;
  50747. backUVs?: Vector4;
  50748. }, scene: any): Mesh;
  50749. /**
  50750. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50751. * * 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
  50752. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50753. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50754. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50755. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50756. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50757. * * 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
  50758. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50761. * @param name defines the name of the new line system
  50762. * @param options defines the options used to create the line system
  50763. * @param scene defines the hosting scene
  50764. * @returns a new line system mesh
  50765. */
  50766. static CreateLineSystem(name: string, options: {
  50767. lines: Vector3[][];
  50768. updatable?: boolean;
  50769. instance?: Nullable<LinesMesh>;
  50770. colors?: Nullable<Color4[][]>;
  50771. useVertexAlpha?: boolean;
  50772. }, scene: Nullable<Scene>): LinesMesh;
  50773. /**
  50774. * Creates a line mesh
  50775. * 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
  50776. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50777. * * The parameter `points` is an array successive Vector3
  50778. * * 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
  50779. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50780. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50781. * * When updating an instance, remember that only point positions can change, not the number of points
  50782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50783. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50784. * @param name defines the name of the new line system
  50785. * @param options defines the options used to create the line system
  50786. * @param scene defines the hosting scene
  50787. * @returns a new line mesh
  50788. */
  50789. static CreateLines(name: string, options: {
  50790. points: Vector3[];
  50791. updatable?: boolean;
  50792. instance?: Nullable<LinesMesh>;
  50793. colors?: Color4[];
  50794. useVertexAlpha?: boolean;
  50795. }, scene?: Nullable<Scene>): LinesMesh;
  50796. /**
  50797. * Creates a dashed line mesh
  50798. * * 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
  50799. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50800. * * The parameter `points` is an array successive Vector3
  50801. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50802. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50803. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50804. * * 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
  50805. * * When updating an instance, remember that only point positions can change, not the number of points
  50806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50807. * @param name defines the name of the mesh
  50808. * @param options defines the options used to create the mesh
  50809. * @param scene defines the hosting scene
  50810. * @returns the dashed line mesh
  50811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50812. */
  50813. static CreateDashedLines(name: string, options: {
  50814. points: Vector3[];
  50815. dashSize?: number;
  50816. gapSize?: number;
  50817. dashNb?: number;
  50818. updatable?: boolean;
  50819. instance?: LinesMesh;
  50820. }, scene?: Nullable<Scene>): LinesMesh;
  50821. /**
  50822. * 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.
  50823. * * 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.
  50824. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50825. * * 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.
  50826. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50827. * * 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
  50828. * * 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
  50829. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50832. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50834. * @param name defines the name of the mesh
  50835. * @param options defines the options used to create the mesh
  50836. * @param scene defines the hosting scene
  50837. * @returns the extruded shape mesh
  50838. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50839. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50840. */
  50841. static ExtrudeShape(name: string, options: {
  50842. shape: Vector3[];
  50843. path: Vector3[];
  50844. scale?: number;
  50845. rotation?: number;
  50846. cap?: number;
  50847. updatable?: boolean;
  50848. sideOrientation?: number;
  50849. frontUVs?: Vector4;
  50850. backUVs?: Vector4;
  50851. instance?: Mesh;
  50852. invertUV?: boolean;
  50853. }, scene?: Nullable<Scene>): Mesh;
  50854. /**
  50855. * Creates an custom extruded shape mesh.
  50856. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50857. * * 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.
  50858. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50859. * * 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
  50860. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50861. * * 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
  50862. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50863. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50864. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50865. * * 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
  50866. * * 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
  50867. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50872. * @param name defines the name of the mesh
  50873. * @param options defines the options used to create the mesh
  50874. * @param scene defines the hosting scene
  50875. * @returns the custom extruded shape mesh
  50876. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50877. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50879. */
  50880. static ExtrudeShapeCustom(name: string, options: {
  50881. shape: Vector3[];
  50882. path: Vector3[];
  50883. scaleFunction?: any;
  50884. rotationFunction?: any;
  50885. ribbonCloseArray?: boolean;
  50886. ribbonClosePath?: boolean;
  50887. cap?: number;
  50888. updatable?: boolean;
  50889. sideOrientation?: number;
  50890. frontUVs?: Vector4;
  50891. backUVs?: Vector4;
  50892. instance?: Mesh;
  50893. invertUV?: boolean;
  50894. }, scene: Scene): Mesh;
  50895. /**
  50896. * Creates lathe mesh.
  50897. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50898. * * 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
  50899. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50900. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50901. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50902. * * 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
  50903. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50904. * * 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
  50905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50907. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50909. * @param name defines the name of the mesh
  50910. * @param options defines the options used to create the mesh
  50911. * @param scene defines the hosting scene
  50912. * @returns the lathe mesh
  50913. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50914. */
  50915. static CreateLathe(name: string, options: {
  50916. shape: Vector3[];
  50917. radius?: number;
  50918. tessellation?: number;
  50919. clip?: number;
  50920. arc?: number;
  50921. closed?: boolean;
  50922. updatable?: boolean;
  50923. sideOrientation?: number;
  50924. frontUVs?: Vector4;
  50925. backUVs?: Vector4;
  50926. cap?: number;
  50927. invertUV?: boolean;
  50928. }, scene: Scene): Mesh;
  50929. /**
  50930. * Creates a plane mesh
  50931. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50932. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50933. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50937. * @param name defines the name of the mesh
  50938. * @param options defines the options used to create the mesh
  50939. * @param scene defines the hosting scene
  50940. * @returns the plane mesh
  50941. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50942. */
  50943. static CreatePlane(name: string, options: {
  50944. size?: number;
  50945. width?: number;
  50946. height?: number;
  50947. sideOrientation?: number;
  50948. frontUVs?: Vector4;
  50949. backUVs?: Vector4;
  50950. updatable?: boolean;
  50951. sourcePlane?: Plane;
  50952. }, scene: Scene): Mesh;
  50953. /**
  50954. * Creates a ground mesh
  50955. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50956. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50958. * @param name defines the name of the mesh
  50959. * @param options defines the options used to create the mesh
  50960. * @param scene defines the hosting scene
  50961. * @returns the ground mesh
  50962. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50963. */
  50964. static CreateGround(name: string, options: {
  50965. width?: number;
  50966. height?: number;
  50967. subdivisions?: number;
  50968. subdivisionsX?: number;
  50969. subdivisionsY?: number;
  50970. updatable?: boolean;
  50971. }, scene: any): Mesh;
  50972. /**
  50973. * Creates a tiled ground mesh
  50974. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50975. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50976. * * 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
  50977. * * 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
  50978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50979. * @param name defines the name of the mesh
  50980. * @param options defines the options used to create the mesh
  50981. * @param scene defines the hosting scene
  50982. * @returns the tiled ground mesh
  50983. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50984. */
  50985. static CreateTiledGround(name: string, options: {
  50986. xmin: number;
  50987. zmin: number;
  50988. xmax: number;
  50989. zmax: number;
  50990. subdivisions?: {
  50991. w: number;
  50992. h: number;
  50993. };
  50994. precision?: {
  50995. w: number;
  50996. h: number;
  50997. };
  50998. updatable?: boolean;
  50999. }, scene: Scene): Mesh;
  51000. /**
  51001. * Creates a ground mesh from a height map
  51002. * * The parameter `url` sets the URL of the height map image resource.
  51003. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51004. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51005. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51006. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51007. * * 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.
  51008. * * 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).
  51009. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51011. * @param name defines the name of the mesh
  51012. * @param url defines the url to the height map
  51013. * @param options defines the options used to create the mesh
  51014. * @param scene defines the hosting scene
  51015. * @returns the ground mesh
  51016. * @see https://doc.babylonjs.com/babylon101/height_map
  51017. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51018. */
  51019. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51020. width?: number;
  51021. height?: number;
  51022. subdivisions?: number;
  51023. minHeight?: number;
  51024. maxHeight?: number;
  51025. colorFilter?: Color3;
  51026. alphaFilter?: number;
  51027. updatable?: boolean;
  51028. onReady?: (mesh: GroundMesh) => void;
  51029. }, scene: Scene): GroundMesh;
  51030. /**
  51031. * Creates a polygon mesh
  51032. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51033. * * 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
  51034. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51037. * * Remember you can only change the shape positions, not their number when updating a polygon
  51038. * @param name defines the name of the mesh
  51039. * @param options defines the options used to create the mesh
  51040. * @param scene defines the hosting scene
  51041. * @param earcutInjection can be used to inject your own earcut reference
  51042. * @returns the polygon mesh
  51043. */
  51044. static CreatePolygon(name: string, options: {
  51045. shape: Vector3[];
  51046. holes?: Vector3[][];
  51047. depth?: number;
  51048. faceUV?: Vector4[];
  51049. faceColors?: Color4[];
  51050. updatable?: boolean;
  51051. sideOrientation?: number;
  51052. frontUVs?: Vector4;
  51053. backUVs?: Vector4;
  51054. }, scene: Scene, earcutInjection?: any): Mesh;
  51055. /**
  51056. * Creates an extruded polygon mesh, with depth in the Y direction.
  51057. * * 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)
  51058. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51059. * @param name defines the name of the mesh
  51060. * @param options defines the options used to create the mesh
  51061. * @param scene defines the hosting scene
  51062. * @param earcutInjection can be used to inject your own earcut reference
  51063. * @returns the polygon mesh
  51064. */
  51065. static ExtrudePolygon(name: string, options: {
  51066. shape: Vector3[];
  51067. holes?: Vector3[][];
  51068. depth?: number;
  51069. faceUV?: Vector4[];
  51070. faceColors?: Color4[];
  51071. updatable?: boolean;
  51072. sideOrientation?: number;
  51073. frontUVs?: Vector4;
  51074. backUVs?: Vector4;
  51075. }, scene: Scene, earcutInjection?: any): Mesh;
  51076. /**
  51077. * Creates a tube mesh.
  51078. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51079. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51080. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51081. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51082. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51083. * * 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)
  51084. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51085. * * 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
  51086. * * 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
  51087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51091. * @param name defines the name of the mesh
  51092. * @param options defines the options used to create the mesh
  51093. * @param scene defines the hosting scene
  51094. * @returns the tube mesh
  51095. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51096. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51097. */
  51098. static CreateTube(name: string, options: {
  51099. path: Vector3[];
  51100. radius?: number;
  51101. tessellation?: number;
  51102. radiusFunction?: {
  51103. (i: number, distance: number): number;
  51104. };
  51105. cap?: number;
  51106. arc?: number;
  51107. updatable?: boolean;
  51108. sideOrientation?: number;
  51109. frontUVs?: Vector4;
  51110. backUVs?: Vector4;
  51111. instance?: Mesh;
  51112. invertUV?: boolean;
  51113. }, scene: Scene): Mesh;
  51114. /**
  51115. * Creates a polyhedron mesh
  51116. * * 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
  51117. * * The parameter `size` (positive float, default 1) sets the polygon size
  51118. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51119. * * 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`
  51120. * * 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
  51121. * * 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)`)
  51122. * * 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
  51123. * * 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
  51124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51127. * @param name defines the name of the mesh
  51128. * @param options defines the options used to create the mesh
  51129. * @param scene defines the hosting scene
  51130. * @returns the polyhedron mesh
  51131. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51132. */
  51133. static CreatePolyhedron(name: string, options: {
  51134. type?: number;
  51135. size?: number;
  51136. sizeX?: number;
  51137. sizeY?: number;
  51138. sizeZ?: number;
  51139. custom?: any;
  51140. faceUV?: Vector4[];
  51141. faceColors?: Color4[];
  51142. flat?: boolean;
  51143. updatable?: boolean;
  51144. sideOrientation?: number;
  51145. frontUVs?: Vector4;
  51146. backUVs?: Vector4;
  51147. }, scene: Scene): Mesh;
  51148. /**
  51149. * Creates a decal mesh.
  51150. * 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
  51151. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51152. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51153. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51154. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51155. * @param name defines the name of the mesh
  51156. * @param sourceMesh defines the mesh where the decal must be applied
  51157. * @param options defines the options used to create the mesh
  51158. * @param scene defines the hosting scene
  51159. * @returns the decal mesh
  51160. * @see https://doc.babylonjs.com/how_to/decals
  51161. */
  51162. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51163. position?: Vector3;
  51164. normal?: Vector3;
  51165. size?: Vector3;
  51166. angle?: number;
  51167. }): Mesh;
  51168. }
  51169. }
  51170. declare module "babylonjs/Meshes/meshSimplification" {
  51171. import { Mesh } from "babylonjs/Meshes/mesh";
  51172. /**
  51173. * A simplifier interface for future simplification implementations
  51174. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51175. */
  51176. export interface ISimplifier {
  51177. /**
  51178. * Simplification of a given mesh according to the given settings.
  51179. * Since this requires computation, it is assumed that the function runs async.
  51180. * @param settings The settings of the simplification, including quality and distance
  51181. * @param successCallback A callback that will be called after the mesh was simplified.
  51182. * @param errorCallback in case of an error, this callback will be called. optional.
  51183. */
  51184. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51185. }
  51186. /**
  51187. * Expected simplification settings.
  51188. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51189. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51190. */
  51191. export interface ISimplificationSettings {
  51192. /**
  51193. * Gets or sets the expected quality
  51194. */
  51195. quality: number;
  51196. /**
  51197. * Gets or sets the distance when this optimized version should be used
  51198. */
  51199. distance: number;
  51200. /**
  51201. * Gets an already optimized mesh
  51202. */
  51203. optimizeMesh?: boolean;
  51204. }
  51205. /**
  51206. * Class used to specify simplification options
  51207. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51208. */
  51209. export class SimplificationSettings implements ISimplificationSettings {
  51210. /** expected quality */
  51211. quality: number;
  51212. /** distance when this optimized version should be used */
  51213. distance: number;
  51214. /** already optimized mesh */
  51215. optimizeMesh?: boolean | undefined;
  51216. /**
  51217. * Creates a SimplificationSettings
  51218. * @param quality expected quality
  51219. * @param distance distance when this optimized version should be used
  51220. * @param optimizeMesh already optimized mesh
  51221. */
  51222. constructor(
  51223. /** expected quality */
  51224. quality: number,
  51225. /** distance when this optimized version should be used */
  51226. distance: number,
  51227. /** already optimized mesh */
  51228. optimizeMesh?: boolean | undefined);
  51229. }
  51230. /**
  51231. * Interface used to define a simplification task
  51232. */
  51233. export interface ISimplificationTask {
  51234. /**
  51235. * Array of settings
  51236. */
  51237. settings: Array<ISimplificationSettings>;
  51238. /**
  51239. * Simplification type
  51240. */
  51241. simplificationType: SimplificationType;
  51242. /**
  51243. * Mesh to simplify
  51244. */
  51245. mesh: Mesh;
  51246. /**
  51247. * Callback called on success
  51248. */
  51249. successCallback?: () => void;
  51250. /**
  51251. * Defines if parallel processing can be used
  51252. */
  51253. parallelProcessing: boolean;
  51254. }
  51255. /**
  51256. * Queue used to order the simplification tasks
  51257. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51258. */
  51259. export class SimplificationQueue {
  51260. private _simplificationArray;
  51261. /**
  51262. * Gets a boolean indicating that the process is still running
  51263. */
  51264. running: boolean;
  51265. /**
  51266. * Creates a new queue
  51267. */
  51268. constructor();
  51269. /**
  51270. * Adds a new simplification task
  51271. * @param task defines a task to add
  51272. */
  51273. addTask(task: ISimplificationTask): void;
  51274. /**
  51275. * Execute next task
  51276. */
  51277. executeNext(): void;
  51278. /**
  51279. * Execute a simplification task
  51280. * @param task defines the task to run
  51281. */
  51282. runSimplification(task: ISimplificationTask): void;
  51283. private getSimplifier;
  51284. }
  51285. /**
  51286. * The implemented types of simplification
  51287. * At the moment only Quadratic Error Decimation is implemented
  51288. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51289. */
  51290. export enum SimplificationType {
  51291. /** Quadratic error decimation */
  51292. QUADRATIC = 0
  51293. }
  51294. }
  51295. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51296. import { Scene } from "babylonjs/scene";
  51297. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51298. import { ISceneComponent } from "babylonjs/sceneComponent";
  51299. module "babylonjs/scene" {
  51300. interface Scene {
  51301. /** @hidden (Backing field) */
  51302. _simplificationQueue: SimplificationQueue;
  51303. /**
  51304. * Gets or sets the simplification queue attached to the scene
  51305. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51306. */
  51307. simplificationQueue: SimplificationQueue;
  51308. }
  51309. }
  51310. module "babylonjs/Meshes/mesh" {
  51311. interface Mesh {
  51312. /**
  51313. * Simplify the mesh according to the given array of settings.
  51314. * Function will return immediately and will simplify async
  51315. * @param settings a collection of simplification settings
  51316. * @param parallelProcessing should all levels calculate parallel or one after the other
  51317. * @param simplificationType the type of simplification to run
  51318. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51319. * @returns the current mesh
  51320. */
  51321. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51322. }
  51323. }
  51324. /**
  51325. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51326. * created in a scene
  51327. */
  51328. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51329. /**
  51330. * The component name helpfull to identify the component in the list of scene components.
  51331. */
  51332. readonly name: string;
  51333. /**
  51334. * The scene the component belongs to.
  51335. */
  51336. scene: Scene;
  51337. /**
  51338. * Creates a new instance of the component for the given scene
  51339. * @param scene Defines the scene to register the component in
  51340. */
  51341. constructor(scene: Scene);
  51342. /**
  51343. * Registers the component in a given scene
  51344. */
  51345. register(): void;
  51346. /**
  51347. * Rebuilds the elements related to this component in case of
  51348. * context lost for instance.
  51349. */
  51350. rebuild(): void;
  51351. /**
  51352. * Disposes the component and the associated ressources
  51353. */
  51354. dispose(): void;
  51355. private _beforeCameraUpdate;
  51356. }
  51357. }
  51358. declare module "babylonjs/Meshes/Builders/index" {
  51359. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51360. export * from "babylonjs/Meshes/Builders/discBuilder";
  51361. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51362. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51363. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51364. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51365. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51366. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51367. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51368. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51369. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51370. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51371. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51372. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51373. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51374. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51375. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51376. }
  51377. declare module "babylonjs/Meshes/index" {
  51378. export * from "babylonjs/Meshes/abstractMesh";
  51379. export * from "babylonjs/Meshes/buffer";
  51380. export * from "babylonjs/Meshes/Compression/index";
  51381. export * from "babylonjs/Meshes/csg";
  51382. export * from "babylonjs/Meshes/geometry";
  51383. export * from "babylonjs/Meshes/groundMesh";
  51384. export * from "babylonjs/Meshes/trailMesh";
  51385. export * from "babylonjs/Meshes/instancedMesh";
  51386. export * from "babylonjs/Meshes/linesMesh";
  51387. export * from "babylonjs/Meshes/mesh";
  51388. export * from "babylonjs/Meshes/mesh.vertexData";
  51389. export * from "babylonjs/Meshes/meshBuilder";
  51390. export * from "babylonjs/Meshes/meshSimplification";
  51391. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51392. export * from "babylonjs/Meshes/polygonMesh";
  51393. export * from "babylonjs/Meshes/subMesh";
  51394. export * from "babylonjs/Meshes/transformNode";
  51395. export * from "babylonjs/Meshes/Builders/index";
  51396. }
  51397. declare module "babylonjs/Morph/index" {
  51398. export * from "babylonjs/Morph/morphTarget";
  51399. export * from "babylonjs/Morph/morphTargetManager";
  51400. }
  51401. declare module "babylonjs/Offline/database" {
  51402. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51403. /**
  51404. * Class used to enable access to IndexedDB
  51405. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51406. */
  51407. export class Database implements IOfflineProvider {
  51408. private _callbackManifestChecked;
  51409. private _currentSceneUrl;
  51410. private _db;
  51411. private _enableSceneOffline;
  51412. private _enableTexturesOffline;
  51413. private _manifestVersionFound;
  51414. private _mustUpdateRessources;
  51415. private _hasReachedQuota;
  51416. private _isSupported;
  51417. private _idbFactory;
  51418. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51419. private static IsUASupportingBlobStorage;
  51420. /**
  51421. * Gets a boolean indicating if Database storate is enabled (off by default)
  51422. */
  51423. static IDBStorageEnabled: boolean;
  51424. /**
  51425. * Gets a boolean indicating if scene must be saved in the database
  51426. */
  51427. readonly enableSceneOffline: boolean;
  51428. /**
  51429. * Gets a boolean indicating if textures must be saved in the database
  51430. */
  51431. readonly enableTexturesOffline: boolean;
  51432. /**
  51433. * Creates a new Database
  51434. * @param urlToScene defines the url to load the scene
  51435. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51436. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51437. */
  51438. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51439. private static _ParseURL;
  51440. private static _ReturnFullUrlLocation;
  51441. private _checkManifestFile;
  51442. /**
  51443. * Open the database and make it available
  51444. * @param successCallback defines the callback to call on success
  51445. * @param errorCallback defines the callback to call on error
  51446. */
  51447. open(successCallback: () => void, errorCallback: () => void): void;
  51448. /**
  51449. * Loads an image from the database
  51450. * @param url defines the url to load from
  51451. * @param image defines the target DOM image
  51452. */
  51453. loadImage(url: string, image: HTMLImageElement): void;
  51454. private _loadImageFromDBAsync;
  51455. private _saveImageIntoDBAsync;
  51456. private _checkVersionFromDB;
  51457. private _loadVersionFromDBAsync;
  51458. private _saveVersionIntoDBAsync;
  51459. /**
  51460. * Loads a file from database
  51461. * @param url defines the URL to load from
  51462. * @param sceneLoaded defines a callback to call on success
  51463. * @param progressCallBack defines a callback to call when progress changed
  51464. * @param errorCallback defines a callback to call on error
  51465. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51466. */
  51467. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51468. private _loadFileAsync;
  51469. private _saveFileAsync;
  51470. /**
  51471. * Validates if xhr data is correct
  51472. * @param xhr defines the request to validate
  51473. * @param dataType defines the expected data type
  51474. * @returns true if data is correct
  51475. */
  51476. private static _ValidateXHRData;
  51477. }
  51478. }
  51479. declare module "babylonjs/Offline/index" {
  51480. export * from "babylonjs/Offline/database";
  51481. export * from "babylonjs/Offline/IOfflineProvider";
  51482. }
  51483. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51484. /** @hidden */
  51485. export var gpuUpdateParticlesPixelShader: {
  51486. name: string;
  51487. shader: string;
  51488. };
  51489. }
  51490. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51491. /** @hidden */
  51492. export var gpuUpdateParticlesVertexShader: {
  51493. name: string;
  51494. shader: string;
  51495. };
  51496. }
  51497. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51498. /** @hidden */
  51499. export var clipPlaneFragmentDeclaration2: {
  51500. name: string;
  51501. shader: string;
  51502. };
  51503. }
  51504. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51505. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51506. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51507. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51508. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51509. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51510. /** @hidden */
  51511. export var gpuRenderParticlesPixelShader: {
  51512. name: string;
  51513. shader: string;
  51514. };
  51515. }
  51516. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51517. /** @hidden */
  51518. export var clipPlaneVertexDeclaration2: {
  51519. name: string;
  51520. shader: string;
  51521. };
  51522. }
  51523. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51524. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51525. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51526. /** @hidden */
  51527. export var gpuRenderParticlesVertexShader: {
  51528. name: string;
  51529. shader: string;
  51530. };
  51531. }
  51532. declare module "babylonjs/Particles/gpuParticleSystem" {
  51533. import { Nullable } from "babylonjs/types";
  51534. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51535. import { Observable } from "babylonjs/Misc/observable";
  51536. import { Color4, Color3 } from "babylonjs/Maths/math";
  51537. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51538. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51539. import { Scene, IDisposable } from "babylonjs/scene";
  51540. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51541. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51542. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51543. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51544. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51545. /**
  51546. * This represents a GPU particle system in Babylon
  51547. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51548. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51549. */
  51550. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51551. /**
  51552. * The layer mask we are rendering the particles through.
  51553. */
  51554. layerMask: number;
  51555. private _capacity;
  51556. private _activeCount;
  51557. private _currentActiveCount;
  51558. private _accumulatedCount;
  51559. private _renderEffect;
  51560. private _updateEffect;
  51561. private _buffer0;
  51562. private _buffer1;
  51563. private _spriteBuffer;
  51564. private _updateVAO;
  51565. private _renderVAO;
  51566. private _targetIndex;
  51567. private _sourceBuffer;
  51568. private _targetBuffer;
  51569. private _engine;
  51570. private _currentRenderId;
  51571. private _started;
  51572. private _stopped;
  51573. private _timeDelta;
  51574. private _randomTexture;
  51575. private _randomTexture2;
  51576. private _attributesStrideSize;
  51577. private _updateEffectOptions;
  51578. private _randomTextureSize;
  51579. private _actualFrame;
  51580. private readonly _rawTextureWidth;
  51581. /**
  51582. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51583. */
  51584. static readonly IsSupported: boolean;
  51585. /**
  51586. * An event triggered when the system is disposed.
  51587. */
  51588. onDisposeObservable: Observable<GPUParticleSystem>;
  51589. /**
  51590. * Gets the maximum number of particles active at the same time.
  51591. * @returns The max number of active particles.
  51592. */
  51593. getCapacity(): number;
  51594. /**
  51595. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51596. * to override the particles.
  51597. */
  51598. forceDepthWrite: boolean;
  51599. /**
  51600. * Gets or set the number of active particles
  51601. */
  51602. activeParticleCount: number;
  51603. private _preWarmDone;
  51604. /**
  51605. * Is this system ready to be used/rendered
  51606. * @return true if the system is ready
  51607. */
  51608. isReady(): boolean;
  51609. /**
  51610. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51611. * @returns True if it has been started, otherwise false.
  51612. */
  51613. isStarted(): boolean;
  51614. /**
  51615. * Starts the particle system and begins to emit
  51616. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51617. */
  51618. start(delay?: number): void;
  51619. /**
  51620. * Stops the particle system.
  51621. */
  51622. stop(): void;
  51623. /**
  51624. * Remove all active particles
  51625. */
  51626. reset(): void;
  51627. /**
  51628. * Returns the string "GPUParticleSystem"
  51629. * @returns a string containing the class name
  51630. */
  51631. getClassName(): string;
  51632. private _colorGradientsTexture;
  51633. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51634. /**
  51635. * Adds a new color gradient
  51636. * @param gradient defines the gradient to use (between 0 and 1)
  51637. * @param color1 defines the color to affect to the specified gradient
  51638. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51639. * @returns the current particle system
  51640. */
  51641. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51642. /**
  51643. * Remove a specific color gradient
  51644. * @param gradient defines the gradient to remove
  51645. * @returns the current particle system
  51646. */
  51647. removeColorGradient(gradient: number): GPUParticleSystem;
  51648. private _angularSpeedGradientsTexture;
  51649. private _sizeGradientsTexture;
  51650. private _velocityGradientsTexture;
  51651. private _limitVelocityGradientsTexture;
  51652. private _dragGradientsTexture;
  51653. private _addFactorGradient;
  51654. /**
  51655. * Adds a new size gradient
  51656. * @param gradient defines the gradient to use (between 0 and 1)
  51657. * @param factor defines the size factor to affect to the specified gradient
  51658. * @returns the current particle system
  51659. */
  51660. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51661. /**
  51662. * Remove a specific size gradient
  51663. * @param gradient defines the gradient to remove
  51664. * @returns the current particle system
  51665. */
  51666. removeSizeGradient(gradient: number): GPUParticleSystem;
  51667. /**
  51668. * Adds a new angular speed gradient
  51669. * @param gradient defines the gradient to use (between 0 and 1)
  51670. * @param factor defines the angular speed to affect to the specified gradient
  51671. * @returns the current particle system
  51672. */
  51673. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51674. /**
  51675. * Remove a specific angular speed gradient
  51676. * @param gradient defines the gradient to remove
  51677. * @returns the current particle system
  51678. */
  51679. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51680. /**
  51681. * Adds a new velocity gradient
  51682. * @param gradient defines the gradient to use (between 0 and 1)
  51683. * @param factor defines the velocity to affect to the specified gradient
  51684. * @returns the current particle system
  51685. */
  51686. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51687. /**
  51688. * Remove a specific velocity gradient
  51689. * @param gradient defines the gradient to remove
  51690. * @returns the current particle system
  51691. */
  51692. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51693. /**
  51694. * Adds a new limit velocity gradient
  51695. * @param gradient defines the gradient to use (between 0 and 1)
  51696. * @param factor defines the limit velocity value to affect to the specified gradient
  51697. * @returns the current particle system
  51698. */
  51699. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51700. /**
  51701. * Remove a specific limit velocity gradient
  51702. * @param gradient defines the gradient to remove
  51703. * @returns the current particle system
  51704. */
  51705. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51706. /**
  51707. * Adds a new drag gradient
  51708. * @param gradient defines the gradient to use (between 0 and 1)
  51709. * @param factor defines the drag value to affect to the specified gradient
  51710. * @returns the current particle system
  51711. */
  51712. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51713. /**
  51714. * Remove a specific drag gradient
  51715. * @param gradient defines the gradient to remove
  51716. * @returns the current particle system
  51717. */
  51718. removeDragGradient(gradient: number): GPUParticleSystem;
  51719. /**
  51720. * Not supported by GPUParticleSystem
  51721. * @param gradient defines the gradient to use (between 0 and 1)
  51722. * @param factor defines the emit rate value to affect to the specified gradient
  51723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51724. * @returns the current particle system
  51725. */
  51726. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51727. /**
  51728. * Not supported by GPUParticleSystem
  51729. * @param gradient defines the gradient to remove
  51730. * @returns the current particle system
  51731. */
  51732. removeEmitRateGradient(gradient: number): IParticleSystem;
  51733. /**
  51734. * Not supported by GPUParticleSystem
  51735. * @param gradient defines the gradient to use (between 0 and 1)
  51736. * @param factor defines the start size value to affect to the specified gradient
  51737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51738. * @returns the current particle system
  51739. */
  51740. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51741. /**
  51742. * Not supported by GPUParticleSystem
  51743. * @param gradient defines the gradient to remove
  51744. * @returns the current particle system
  51745. */
  51746. removeStartSizeGradient(gradient: number): IParticleSystem;
  51747. /**
  51748. * Not supported by GPUParticleSystem
  51749. * @param gradient defines the gradient to use (between 0 and 1)
  51750. * @param min defines the color remap minimal range
  51751. * @param max defines the color remap maximal range
  51752. * @returns the current particle system
  51753. */
  51754. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51755. /**
  51756. * Not supported by GPUParticleSystem
  51757. * @param gradient defines the gradient to remove
  51758. * @returns the current particle system
  51759. */
  51760. removeColorRemapGradient(): IParticleSystem;
  51761. /**
  51762. * Not supported by GPUParticleSystem
  51763. * @param gradient defines the gradient to use (between 0 and 1)
  51764. * @param min defines the alpha remap minimal range
  51765. * @param max defines the alpha remap maximal range
  51766. * @returns the current particle system
  51767. */
  51768. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51769. /**
  51770. * Not supported by GPUParticleSystem
  51771. * @param gradient defines the gradient to remove
  51772. * @returns the current particle system
  51773. */
  51774. removeAlphaRemapGradient(): IParticleSystem;
  51775. /**
  51776. * Not supported by GPUParticleSystem
  51777. * @param gradient defines the gradient to use (between 0 and 1)
  51778. * @param color defines the color to affect to the specified gradient
  51779. * @returns the current particle system
  51780. */
  51781. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51782. /**
  51783. * Not supported by GPUParticleSystem
  51784. * @param gradient defines the gradient to remove
  51785. * @returns the current particle system
  51786. */
  51787. removeRampGradient(): IParticleSystem;
  51788. /**
  51789. * Not supported by GPUParticleSystem
  51790. * @returns the list of ramp gradients
  51791. */
  51792. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51793. /**
  51794. * Not supported by GPUParticleSystem
  51795. * Gets or sets a boolean indicating that ramp gradients must be used
  51796. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51797. */
  51798. useRampGradients: boolean;
  51799. /**
  51800. * Not supported by GPUParticleSystem
  51801. * @param gradient defines the gradient to use (between 0 and 1)
  51802. * @param factor defines the life time factor to affect to the specified gradient
  51803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51804. * @returns the current particle system
  51805. */
  51806. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51807. /**
  51808. * Not supported by GPUParticleSystem
  51809. * @param gradient defines the gradient to remove
  51810. * @returns the current particle system
  51811. */
  51812. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51813. /**
  51814. * Instantiates a GPU particle system.
  51815. * 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.
  51816. * @param name The name of the particle system
  51817. * @param options The options used to create the system
  51818. * @param scene The scene the particle system belongs to
  51819. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51820. */
  51821. constructor(name: string, options: Partial<{
  51822. capacity: number;
  51823. randomTextureSize: number;
  51824. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51825. protected _reset(): void;
  51826. private _createUpdateVAO;
  51827. private _createRenderVAO;
  51828. private _initialize;
  51829. /** @hidden */
  51830. _recreateUpdateEffect(): void;
  51831. /** @hidden */
  51832. _recreateRenderEffect(): void;
  51833. /**
  51834. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51835. * @param preWarm defines if we are in the pre-warmimg phase
  51836. */
  51837. animate(preWarm?: boolean): void;
  51838. private _createFactorGradientTexture;
  51839. private _createSizeGradientTexture;
  51840. private _createAngularSpeedGradientTexture;
  51841. private _createVelocityGradientTexture;
  51842. private _createLimitVelocityGradientTexture;
  51843. private _createDragGradientTexture;
  51844. private _createColorGradientTexture;
  51845. /**
  51846. * Renders the particle system in its current state
  51847. * @param preWarm defines if the system should only update the particles but not render them
  51848. * @returns the current number of particles
  51849. */
  51850. render(preWarm?: boolean): number;
  51851. /**
  51852. * Rebuilds the particle system
  51853. */
  51854. rebuild(): void;
  51855. private _releaseBuffers;
  51856. private _releaseVAOs;
  51857. /**
  51858. * Disposes the particle system and free the associated resources
  51859. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51860. */
  51861. dispose(disposeTexture?: boolean): void;
  51862. /**
  51863. * Clones the particle system.
  51864. * @param name The name of the cloned object
  51865. * @param newEmitter The new emitter to use
  51866. * @returns the cloned particle system
  51867. */
  51868. clone(name: string, newEmitter: any): GPUParticleSystem;
  51869. /**
  51870. * Serializes the particle system to a JSON object.
  51871. * @returns the JSON object
  51872. */
  51873. serialize(): any;
  51874. /**
  51875. * Parses a JSON object to create a GPU particle system.
  51876. * @param parsedParticleSystem The JSON object to parse
  51877. * @param scene The scene to create the particle system in
  51878. * @param rootUrl The root url to use to load external dependencies like texture
  51879. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51880. * @returns the parsed GPU particle system
  51881. */
  51882. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51883. }
  51884. }
  51885. declare module "babylonjs/Particles/particleSystemSet" {
  51886. import { Nullable } from "babylonjs/types";
  51887. import { Color3 } from "babylonjs/Maths/math";
  51888. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51890. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51891. import { Scene, IDisposable } from "babylonjs/scene";
  51892. /**
  51893. * Represents a set of particle systems working together to create a specific effect
  51894. */
  51895. export class ParticleSystemSet implements IDisposable {
  51896. private _emitterCreationOptions;
  51897. private _emitterNode;
  51898. /**
  51899. * Gets the particle system list
  51900. */
  51901. systems: IParticleSystem[];
  51902. /**
  51903. * Gets the emitter node used with this set
  51904. */
  51905. readonly emitterNode: Nullable<TransformNode>;
  51906. /**
  51907. * Creates a new emitter mesh as a sphere
  51908. * @param options defines the options used to create the sphere
  51909. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51910. * @param scene defines the hosting scene
  51911. */
  51912. setEmitterAsSphere(options: {
  51913. diameter: number;
  51914. segments: number;
  51915. color: Color3;
  51916. }, renderingGroupId: number, scene: Scene): void;
  51917. /**
  51918. * Starts all particle systems of the set
  51919. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51920. */
  51921. start(emitter?: AbstractMesh): void;
  51922. /**
  51923. * Release all associated resources
  51924. */
  51925. dispose(): void;
  51926. /**
  51927. * Serialize the set into a JSON compatible object
  51928. * @returns a JSON compatible representation of the set
  51929. */
  51930. serialize(): any;
  51931. /**
  51932. * Parse a new ParticleSystemSet from a serialized source
  51933. * @param data defines a JSON compatible representation of the set
  51934. * @param scene defines the hosting scene
  51935. * @param gpu defines if we want GPU particles or CPU particles
  51936. * @returns a new ParticleSystemSet
  51937. */
  51938. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51939. }
  51940. }
  51941. declare module "babylonjs/Particles/particleHelper" {
  51942. import { Nullable } from "babylonjs/types";
  51943. import { Scene } from "babylonjs/scene";
  51944. import { Vector3 } from "babylonjs/Maths/math";
  51945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51946. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51947. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51948. /**
  51949. * This class is made for on one-liner static method to help creating particle system set.
  51950. */
  51951. export class ParticleHelper {
  51952. /**
  51953. * Gets or sets base Assets URL
  51954. */
  51955. static BaseAssetsUrl: string;
  51956. /**
  51957. * Create a default particle system that you can tweak
  51958. * @param emitter defines the emitter to use
  51959. * @param capacity defines the system capacity (default is 500 particles)
  51960. * @param scene defines the hosting scene
  51961. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51962. * @returns the new Particle system
  51963. */
  51964. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51965. /**
  51966. * This is the main static method (one-liner) of this helper to create different particle systems
  51967. * @param type This string represents the type to the particle system to create
  51968. * @param scene The scene where the particle system should live
  51969. * @param gpu If the system will use gpu
  51970. * @returns the ParticleSystemSet created
  51971. */
  51972. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51973. /**
  51974. * Static function used to export a particle system to a ParticleSystemSet variable.
  51975. * Please note that the emitter shape is not exported
  51976. * @param systems defines the particle systems to export
  51977. * @returns the created particle system set
  51978. */
  51979. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51980. }
  51981. }
  51982. declare module "babylonjs/Particles/particleSystemComponent" {
  51983. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51984. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51985. import "babylonjs/Shaders/particles.vertex";
  51986. module "babylonjs/Engines/engine" {
  51987. interface Engine {
  51988. /**
  51989. * Create an effect to use with particle systems.
  51990. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51991. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51992. * @param uniformsNames defines a list of attribute names
  51993. * @param samplers defines an array of string used to represent textures
  51994. * @param defines defines the string containing the defines to use to compile the shaders
  51995. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51996. * @param onCompiled defines a function to call when the effect creation is successful
  51997. * @param onError defines a function to call when the effect creation has failed
  51998. * @returns the new Effect
  51999. */
  52000. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52001. }
  52002. }
  52003. module "babylonjs/Meshes/mesh" {
  52004. interface Mesh {
  52005. /**
  52006. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52007. * @returns an array of IParticleSystem
  52008. */
  52009. getEmittedParticleSystems(): IParticleSystem[];
  52010. /**
  52011. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52012. * @returns an array of IParticleSystem
  52013. */
  52014. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52015. }
  52016. }
  52017. /**
  52018. * @hidden
  52019. */
  52020. export var _IDoNeedToBeInTheBuild: number;
  52021. }
  52022. declare module "babylonjs/Particles/index" {
  52023. export * from "babylonjs/Particles/baseParticleSystem";
  52024. export * from "babylonjs/Particles/EmitterTypes/index";
  52025. export * from "babylonjs/Particles/gpuParticleSystem";
  52026. export * from "babylonjs/Particles/IParticleSystem";
  52027. export * from "babylonjs/Particles/particle";
  52028. export * from "babylonjs/Particles/particleHelper";
  52029. export * from "babylonjs/Particles/particleSystem";
  52030. export * from "babylonjs/Particles/particleSystemComponent";
  52031. export * from "babylonjs/Particles/particleSystemSet";
  52032. export * from "babylonjs/Particles/solidParticle";
  52033. export * from "babylonjs/Particles/solidParticleSystem";
  52034. export * from "babylonjs/Particles/subEmitter";
  52035. }
  52036. declare module "babylonjs/Physics/physicsEngineComponent" {
  52037. import { Nullable } from "babylonjs/types";
  52038. import { Observable, Observer } from "babylonjs/Misc/observable";
  52039. import { Vector3 } from "babylonjs/Maths/math";
  52040. import { Mesh } from "babylonjs/Meshes/mesh";
  52041. import { ISceneComponent } from "babylonjs/sceneComponent";
  52042. import { Scene } from "babylonjs/scene";
  52043. import { Node } from "babylonjs/node";
  52044. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52045. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52046. module "babylonjs/scene" {
  52047. interface Scene {
  52048. /** @hidden (Backing field) */
  52049. _physicsEngine: Nullable<IPhysicsEngine>;
  52050. /**
  52051. * Gets the current physics engine
  52052. * @returns a IPhysicsEngine or null if none attached
  52053. */
  52054. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52055. /**
  52056. * Enables physics to the current scene
  52057. * @param gravity defines the scene's gravity for the physics engine
  52058. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52059. * @return a boolean indicating if the physics engine was initialized
  52060. */
  52061. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52062. /**
  52063. * Disables and disposes the physics engine associated with the scene
  52064. */
  52065. disablePhysicsEngine(): void;
  52066. /**
  52067. * Gets a boolean indicating if there is an active physics engine
  52068. * @returns a boolean indicating if there is an active physics engine
  52069. */
  52070. isPhysicsEnabled(): boolean;
  52071. /**
  52072. * Deletes a physics compound impostor
  52073. * @param compound defines the compound to delete
  52074. */
  52075. deleteCompoundImpostor(compound: any): void;
  52076. /**
  52077. * An event triggered when physic simulation is about to be run
  52078. */
  52079. onBeforePhysicsObservable: Observable<Scene>;
  52080. /**
  52081. * An event triggered when physic simulation has been done
  52082. */
  52083. onAfterPhysicsObservable: Observable<Scene>;
  52084. }
  52085. }
  52086. module "babylonjs/Meshes/abstractMesh" {
  52087. interface AbstractMesh {
  52088. /** @hidden */
  52089. _physicsImpostor: Nullable<PhysicsImpostor>;
  52090. /**
  52091. * Gets or sets impostor used for physic simulation
  52092. * @see http://doc.babylonjs.com/features/physics_engine
  52093. */
  52094. physicsImpostor: Nullable<PhysicsImpostor>;
  52095. /**
  52096. * Gets the current physics impostor
  52097. * @see http://doc.babylonjs.com/features/physics_engine
  52098. * @returns a physics impostor or null
  52099. */
  52100. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52101. /** Apply a physic impulse to the mesh
  52102. * @param force defines the force to apply
  52103. * @param contactPoint defines where to apply the force
  52104. * @returns the current mesh
  52105. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52106. */
  52107. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52108. /**
  52109. * Creates a physic joint between two meshes
  52110. * @param otherMesh defines the other mesh to use
  52111. * @param pivot1 defines the pivot to use on this mesh
  52112. * @param pivot2 defines the pivot to use on the other mesh
  52113. * @param options defines additional options (can be plugin dependent)
  52114. * @returns the current mesh
  52115. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52116. */
  52117. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52118. /** @hidden */
  52119. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52120. }
  52121. }
  52122. /**
  52123. * Defines the physics engine scene component responsible to manage a physics engine
  52124. */
  52125. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52126. /**
  52127. * The component name helpful to identify the component in the list of scene components.
  52128. */
  52129. readonly name: string;
  52130. /**
  52131. * The scene the component belongs to.
  52132. */
  52133. scene: Scene;
  52134. /**
  52135. * Creates a new instance of the component for the given scene
  52136. * @param scene Defines the scene to register the component in
  52137. */
  52138. constructor(scene: Scene);
  52139. /**
  52140. * Registers the component in a given scene
  52141. */
  52142. register(): void;
  52143. /**
  52144. * Rebuilds the elements related to this component in case of
  52145. * context lost for instance.
  52146. */
  52147. rebuild(): void;
  52148. /**
  52149. * Disposes the component and the associated ressources
  52150. */
  52151. dispose(): void;
  52152. }
  52153. }
  52154. declare module "babylonjs/Physics/physicsHelper" {
  52155. import { Nullable } from "babylonjs/types";
  52156. import { Vector3 } from "babylonjs/Maths/math";
  52157. import { Mesh } from "babylonjs/Meshes/mesh";
  52158. import { Ray } from "babylonjs/Culling/ray";
  52159. import { Scene } from "babylonjs/scene";
  52160. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52161. /**
  52162. * A helper for physics simulations
  52163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52164. */
  52165. export class PhysicsHelper {
  52166. private _scene;
  52167. private _physicsEngine;
  52168. /**
  52169. * Initializes the Physics helper
  52170. * @param scene Babylon.js scene
  52171. */
  52172. constructor(scene: Scene);
  52173. /**
  52174. * Applies a radial explosion impulse
  52175. * @param origin the origin of the explosion
  52176. * @param radius the explosion radius
  52177. * @param strength the explosion strength
  52178. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52179. * @returns A physics radial explosion event, or null
  52180. */
  52181. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52182. /**
  52183. * Applies a radial explosion force
  52184. * @param origin the origin of the explosion
  52185. * @param radius the explosion radius
  52186. * @param strength the explosion strength
  52187. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52188. * @returns A physics radial explosion event, or null
  52189. */
  52190. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52191. /**
  52192. * Creates a gravitational field
  52193. * @param origin the origin of the explosion
  52194. * @param radius the explosion radius
  52195. * @param strength the explosion strength
  52196. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52197. * @returns A physics gravitational field event, or null
  52198. */
  52199. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52200. /**
  52201. * Creates a physics updraft event
  52202. * @param origin the origin of the updraft
  52203. * @param radius the radius of the updraft
  52204. * @param strength the strength of the updraft
  52205. * @param height the height of the updraft
  52206. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52207. * @returns A physics updraft event, or null
  52208. */
  52209. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52210. /**
  52211. * Creates a physics vortex event
  52212. * @param origin the of the vortex
  52213. * @param radius the radius of the vortex
  52214. * @param strength the strength of the vortex
  52215. * @param height the height of the vortex
  52216. * @returns a Physics vortex event, or null
  52217. * A physics vortex event or null
  52218. */
  52219. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  52220. }
  52221. /**
  52222. * Represents a physics radial explosion event
  52223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52224. */
  52225. export class PhysicsRadialExplosionEvent {
  52226. private _scene;
  52227. private _sphere;
  52228. private _sphereOptions;
  52229. private _rays;
  52230. private _dataFetched;
  52231. /**
  52232. * Initializes a radial explosioin event
  52233. * @param scene BabylonJS scene
  52234. */
  52235. constructor(scene: Scene);
  52236. /**
  52237. * Returns the data related to the radial explosion event (sphere & rays).
  52238. * @returns The radial explosion event data
  52239. */
  52240. getData(): PhysicsRadialExplosionEventData;
  52241. /**
  52242. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52243. * @param impostor A physics imposter
  52244. * @param origin the origin of the explosion
  52245. * @param radius the explosion radius
  52246. * @param strength the explosion strength
  52247. * @param falloff possible options: Constant & Linear
  52248. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52249. */
  52250. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  52251. /**
  52252. * Disposes the sphere.
  52253. * @param force Specifies if the sphere should be disposed by force
  52254. */
  52255. dispose(force?: boolean): void;
  52256. /*** Helpers ***/
  52257. private _prepareSphere;
  52258. private _intersectsWithSphere;
  52259. }
  52260. /**
  52261. * Represents a gravitational field event
  52262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52263. */
  52264. export class PhysicsGravitationalFieldEvent {
  52265. private _physicsHelper;
  52266. private _scene;
  52267. private _origin;
  52268. private _radius;
  52269. private _strength;
  52270. private _falloff;
  52271. private _tickCallback;
  52272. private _sphere;
  52273. private _dataFetched;
  52274. /**
  52275. * Initializes the physics gravitational field event
  52276. * @param physicsHelper A physics helper
  52277. * @param scene BabylonJS scene
  52278. * @param origin The origin position of the gravitational field event
  52279. * @param radius The radius of the gravitational field event
  52280. * @param strength The strength of the gravitational field event
  52281. * @param falloff The falloff for the gravitational field event
  52282. */
  52283. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  52284. /**
  52285. * Returns the data related to the gravitational field event (sphere).
  52286. * @returns A gravitational field event
  52287. */
  52288. getData(): PhysicsGravitationalFieldEventData;
  52289. /**
  52290. * Enables the gravitational field.
  52291. */
  52292. enable(): void;
  52293. /**
  52294. * Disables the gravitational field.
  52295. */
  52296. disable(): void;
  52297. /**
  52298. * Disposes the sphere.
  52299. * @param force The force to dispose from the gravitational field event
  52300. */
  52301. dispose(force?: boolean): void;
  52302. private _tick;
  52303. }
  52304. /**
  52305. * Represents a physics updraft event
  52306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52307. */
  52308. export class PhysicsUpdraftEvent {
  52309. private _scene;
  52310. private _origin;
  52311. private _radius;
  52312. private _strength;
  52313. private _height;
  52314. private _updraftMode;
  52315. private _physicsEngine;
  52316. private _originTop;
  52317. private _originDirection;
  52318. private _tickCallback;
  52319. private _cylinder;
  52320. private _cylinderPosition;
  52321. private _dataFetched;
  52322. /**
  52323. * Initializes the physics updraft event
  52324. * @param _scene BabylonJS scene
  52325. * @param _origin The origin position of the updraft
  52326. * @param _radius The radius of the updraft
  52327. * @param _strength The strength of the updraft
  52328. * @param _height The height of the updraft
  52329. * @param _updraftMode The mode of the updraft
  52330. */
  52331. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  52332. /**
  52333. * Returns the data related to the updraft event (cylinder).
  52334. * @returns A physics updraft event
  52335. */
  52336. getData(): PhysicsUpdraftEventData;
  52337. /**
  52338. * Enables the updraft.
  52339. */
  52340. enable(): void;
  52341. /**
  52342. * Disables the cortex.
  52343. */
  52344. disable(): void;
  52345. /**
  52346. * Disposes the sphere.
  52347. * @param force Specifies if the updraft should be disposed by force
  52348. */
  52349. dispose(force?: boolean): void;
  52350. private getImpostorForceAndContactPoint;
  52351. private _tick;
  52352. /*** Helpers ***/
  52353. private _prepareCylinder;
  52354. private _intersectsWithCylinder;
  52355. }
  52356. /**
  52357. * Represents a physics vortex event
  52358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52359. */
  52360. export class PhysicsVortexEvent {
  52361. private _scene;
  52362. private _origin;
  52363. private _radius;
  52364. private _strength;
  52365. private _height;
  52366. private _physicsEngine;
  52367. private _originTop;
  52368. private _centripetalForceThreshold;
  52369. private _updraftMultiplier;
  52370. private _tickCallback;
  52371. private _cylinder;
  52372. private _cylinderPosition;
  52373. private _dataFetched;
  52374. /**
  52375. * Initializes the physics vortex event
  52376. * @param _scene The BabylonJS scene
  52377. * @param _origin The origin position of the vortex
  52378. * @param _radius The radius of the vortex
  52379. * @param _strength The strength of the vortex
  52380. * @param _height The height of the vortex
  52381. */
  52382. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  52383. /**
  52384. * Returns the data related to the vortex event (cylinder).
  52385. * @returns The physics vortex event data
  52386. */
  52387. getData(): PhysicsVortexEventData;
  52388. /**
  52389. * Enables the vortex.
  52390. */
  52391. enable(): void;
  52392. /**
  52393. * Disables the cortex.
  52394. */
  52395. disable(): void;
  52396. /**
  52397. * Disposes the sphere.
  52398. * @param force
  52399. */
  52400. dispose(force?: boolean): void;
  52401. private getImpostorForceAndContactPoint;
  52402. private _tick;
  52403. /*** Helpers ***/
  52404. private _prepareCylinder;
  52405. private _intersectsWithCylinder;
  52406. }
  52407. /**
  52408. * The strenght of the force in correspondence to the distance of the affected object
  52409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52410. */
  52411. export enum PhysicsRadialImpulseFalloff {
  52412. /** Defines that impulse is constant in strength across it's whole radius */
  52413. Constant = 0,
  52414. /** DEfines that impulse gets weaker if it's further from the origin */
  52415. Linear = 1
  52416. }
  52417. /**
  52418. * The strength of the force in correspondence to the distance of the affected object
  52419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52420. */
  52421. export enum PhysicsUpdraftMode {
  52422. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52423. Center = 0,
  52424. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52425. Perpendicular = 1
  52426. }
  52427. /**
  52428. * Interface for a physics force and contact point
  52429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52430. */
  52431. export interface PhysicsForceAndContactPoint {
  52432. /**
  52433. * The force applied at the contact point
  52434. */
  52435. force: Vector3;
  52436. /**
  52437. * The contact point
  52438. */
  52439. contactPoint: Vector3;
  52440. }
  52441. /**
  52442. * Interface for radial explosion event data
  52443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52444. */
  52445. export interface PhysicsRadialExplosionEventData {
  52446. /**
  52447. * A sphere used for the radial explosion event
  52448. */
  52449. sphere: Mesh;
  52450. /**
  52451. * An array of rays for the radial explosion event
  52452. */
  52453. rays: Array<Ray>;
  52454. }
  52455. /**
  52456. * Interface for gravitational field event data
  52457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52458. */
  52459. export interface PhysicsGravitationalFieldEventData {
  52460. /**
  52461. * A sphere mesh used for the gravitational field event
  52462. */
  52463. sphere: Mesh;
  52464. }
  52465. /**
  52466. * Interface for updraft event data
  52467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52468. */
  52469. export interface PhysicsUpdraftEventData {
  52470. /**
  52471. * A cylinder used for the updraft event
  52472. */
  52473. cylinder: Mesh;
  52474. }
  52475. /**
  52476. * Interface for vortex event data
  52477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52478. */
  52479. export interface PhysicsVortexEventData {
  52480. /**
  52481. * A cylinder used for the vortex event
  52482. */
  52483. cylinder: Mesh;
  52484. }
  52485. }
  52486. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52487. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52488. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52489. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52490. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52491. import { Nullable } from "babylonjs/types";
  52492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52493. /**
  52494. * AmmoJS Physics plugin
  52495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52496. * @see https://github.com/kripken/ammo.js/
  52497. */
  52498. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52499. private _useDeltaForWorldStep;
  52500. /**
  52501. * Reference to the Ammo library
  52502. */
  52503. bjsAMMO: any;
  52504. /**
  52505. * Created ammoJS world which physics bodies are added to
  52506. */
  52507. world: any;
  52508. /**
  52509. * Name of the plugin
  52510. */
  52511. name: string;
  52512. private _timeStep;
  52513. private _fixedTimeStep;
  52514. private _maxSteps;
  52515. private _tmpQuaternion;
  52516. private _tmpAmmoTransform;
  52517. private _tmpAmmoQuaternion;
  52518. private _tmpAmmoConcreteContactResultCallback;
  52519. private _collisionConfiguration;
  52520. private _dispatcher;
  52521. private _overlappingPairCache;
  52522. private _solver;
  52523. private _tmpAmmoVectorA;
  52524. private _tmpAmmoVectorB;
  52525. private _tmpAmmoVectorC;
  52526. private _tmpContactCallbackResult;
  52527. private static readonly DISABLE_COLLISION_FLAG;
  52528. private static readonly KINEMATIC_FLAG;
  52529. private static readonly DISABLE_DEACTIVATION_FLAG;
  52530. /**
  52531. * Initializes the ammoJS plugin
  52532. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52533. * @param ammoInjection can be used to inject your own ammo reference
  52534. */
  52535. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52536. /**
  52537. * Sets the gravity of the physics world (m/(s^2))
  52538. * @param gravity Gravity to set
  52539. */
  52540. setGravity(gravity: Vector3): void;
  52541. /**
  52542. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52543. * @param timeStep timestep to use in seconds
  52544. */
  52545. setTimeStep(timeStep: number): void;
  52546. /**
  52547. * 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)
  52548. * @param fixedTimeStep fixedTimeStep to use in seconds
  52549. */
  52550. setFixedTimeStep(fixedTimeStep: number): void;
  52551. /**
  52552. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52553. * @param maxSteps the maximum number of steps by the physics engine per frame
  52554. */
  52555. setMaxSteps(maxSteps: number): void;
  52556. /**
  52557. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52558. * @returns the current timestep in seconds
  52559. */
  52560. getTimeStep(): number;
  52561. private _isImpostorInContact;
  52562. private _isImpostorPairInContact;
  52563. private _stepSimulation;
  52564. /**
  52565. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52566. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52567. * After the step the babylon meshes are set to the position of the physics imposters
  52568. * @param delta amount of time to step forward
  52569. * @param impostors array of imposters to update before/after the step
  52570. */
  52571. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52572. private _tmpVector;
  52573. private _tmpMatrix;
  52574. /**
  52575. * Applies an implulse on the imposter
  52576. * @param impostor imposter to apply impulse
  52577. * @param force amount of force to be applied to the imposter
  52578. * @param contactPoint the location to apply the impulse on the imposter
  52579. */
  52580. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52581. /**
  52582. * Applies a force on the imposter
  52583. * @param impostor imposter to apply force
  52584. * @param force amount of force to be applied to the imposter
  52585. * @param contactPoint the location to apply the force on the imposter
  52586. */
  52587. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52588. /**
  52589. * Creates a physics body using the plugin
  52590. * @param impostor the imposter to create the physics body on
  52591. */
  52592. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52593. /**
  52594. * Removes the physics body from the imposter and disposes of the body's memory
  52595. * @param impostor imposter to remove the physics body from
  52596. */
  52597. removePhysicsBody(impostor: PhysicsImpostor): void;
  52598. /**
  52599. * Generates a joint
  52600. * @param impostorJoint the imposter joint to create the joint with
  52601. */
  52602. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52603. /**
  52604. * Removes a joint
  52605. * @param impostorJoint the imposter joint to remove the joint from
  52606. */
  52607. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52608. private _addMeshVerts;
  52609. private _createShape;
  52610. /**
  52611. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52612. * @param impostor imposter containing the physics body and babylon object
  52613. */
  52614. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52615. /**
  52616. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52617. * @param impostor imposter containing the physics body and babylon object
  52618. * @param newPosition new position
  52619. * @param newRotation new rotation
  52620. */
  52621. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52622. /**
  52623. * If this plugin is supported
  52624. * @returns true if its supported
  52625. */
  52626. isSupported(): boolean;
  52627. /**
  52628. * Sets the linear velocity of the physics body
  52629. * @param impostor imposter to set the velocity on
  52630. * @param velocity velocity to set
  52631. */
  52632. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52633. /**
  52634. * Sets the angular velocity of the physics body
  52635. * @param impostor imposter to set the velocity on
  52636. * @param velocity velocity to set
  52637. */
  52638. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52639. /**
  52640. * gets the linear velocity
  52641. * @param impostor imposter to get linear velocity from
  52642. * @returns linear velocity
  52643. */
  52644. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52645. /**
  52646. * gets the angular velocity
  52647. * @param impostor imposter to get angular velocity from
  52648. * @returns angular velocity
  52649. */
  52650. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52651. /**
  52652. * Sets the mass of physics body
  52653. * @param impostor imposter to set the mass on
  52654. * @param mass mass to set
  52655. */
  52656. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52657. /**
  52658. * Gets the mass of the physics body
  52659. * @param impostor imposter to get the mass from
  52660. * @returns mass
  52661. */
  52662. getBodyMass(impostor: PhysicsImpostor): number;
  52663. /**
  52664. * Gets friction of the impostor
  52665. * @param impostor impostor to get friction from
  52666. * @returns friction value
  52667. */
  52668. getBodyFriction(impostor: PhysicsImpostor): number;
  52669. /**
  52670. * Sets friction of the impostor
  52671. * @param impostor impostor to set friction on
  52672. * @param friction friction value
  52673. */
  52674. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52675. /**
  52676. * Gets restitution of the impostor
  52677. * @param impostor impostor to get restitution from
  52678. * @returns restitution value
  52679. */
  52680. getBodyRestitution(impostor: PhysicsImpostor): number;
  52681. /**
  52682. * Sets resitution of the impostor
  52683. * @param impostor impostor to set resitution on
  52684. * @param restitution resitution value
  52685. */
  52686. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52687. /**
  52688. * Sleeps the physics body and stops it from being active
  52689. * @param impostor impostor to sleep
  52690. */
  52691. sleepBody(impostor: PhysicsImpostor): void;
  52692. /**
  52693. * Activates the physics body
  52694. * @param impostor impostor to activate
  52695. */
  52696. wakeUpBody(impostor: PhysicsImpostor): void;
  52697. /**
  52698. * Updates the distance parameters of the joint
  52699. * @param joint joint to update
  52700. * @param maxDistance maximum distance of the joint
  52701. * @param minDistance minimum distance of the joint
  52702. */
  52703. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52704. /**
  52705. * Sets a motor on the joint
  52706. * @param joint joint to set motor on
  52707. * @param speed speed of the motor
  52708. * @param maxForce maximum force of the motor
  52709. * @param motorIndex index of the motor
  52710. */
  52711. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52712. /**
  52713. * Sets the motors limit
  52714. * @param joint joint to set limit on
  52715. * @param upperLimit upper limit
  52716. * @param lowerLimit lower limit
  52717. */
  52718. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52719. /**
  52720. * Syncs the position and rotation of a mesh with the impostor
  52721. * @param mesh mesh to sync
  52722. * @param impostor impostor to update the mesh with
  52723. */
  52724. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52725. /**
  52726. * Gets the radius of the impostor
  52727. * @param impostor impostor to get radius from
  52728. * @returns the radius
  52729. */
  52730. getRadius(impostor: PhysicsImpostor): number;
  52731. /**
  52732. * Gets the box size of the impostor
  52733. * @param impostor impostor to get box size from
  52734. * @param result the resulting box size
  52735. */
  52736. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52737. /**
  52738. * Disposes of the impostor
  52739. */
  52740. dispose(): void;
  52741. }
  52742. }
  52743. declare module "babylonjs/Physics/Plugins/index" {
  52744. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52745. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52746. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52747. }
  52748. declare module "babylonjs/Physics/index" {
  52749. export * from "babylonjs/Physics/IPhysicsEngine";
  52750. export * from "babylonjs/Physics/physicsEngine";
  52751. export * from "babylonjs/Physics/physicsEngineComponent";
  52752. export * from "babylonjs/Physics/physicsHelper";
  52753. export * from "babylonjs/Physics/physicsImpostor";
  52754. export * from "babylonjs/Physics/physicsJoint";
  52755. export * from "babylonjs/Physics/Plugins/index";
  52756. }
  52757. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52758. /** @hidden */
  52759. export var blackAndWhitePixelShader: {
  52760. name: string;
  52761. shader: string;
  52762. };
  52763. }
  52764. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52765. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52766. import { Camera } from "babylonjs/Cameras/camera";
  52767. import { Engine } from "babylonjs/Engines/engine";
  52768. import "babylonjs/Shaders/blackAndWhite.fragment";
  52769. /**
  52770. * Post process used to render in black and white
  52771. */
  52772. export class BlackAndWhitePostProcess extends PostProcess {
  52773. /**
  52774. * Linear about to convert he result to black and white (default: 1)
  52775. */
  52776. degree: number;
  52777. /**
  52778. * Creates a black and white post process
  52779. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52780. * @param name The name of the effect.
  52781. * @param options The required width/height ratio to downsize to before computing the render pass.
  52782. * @param camera The camera to apply the render pass to.
  52783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52784. * @param engine The engine which the post process will be applied. (default: current engine)
  52785. * @param reusable If the post process can be reused on the same frame. (default: false)
  52786. */
  52787. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52788. }
  52789. }
  52790. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52791. import { Nullable } from "babylonjs/types";
  52792. import { Camera } from "babylonjs/Cameras/camera";
  52793. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52794. import { Engine } from "babylonjs/Engines/engine";
  52795. /**
  52796. * This represents a set of one or more post processes in Babylon.
  52797. * A post process can be used to apply a shader to a texture after it is rendered.
  52798. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52799. */
  52800. export class PostProcessRenderEffect {
  52801. private _postProcesses;
  52802. private _getPostProcesses;
  52803. private _singleInstance;
  52804. private _cameras;
  52805. private _indicesForCamera;
  52806. /**
  52807. * Name of the effect
  52808. * @hidden
  52809. */
  52810. _name: string;
  52811. /**
  52812. * Instantiates a post process render effect.
  52813. * A post process can be used to apply a shader to a texture after it is rendered.
  52814. * @param engine The engine the effect is tied to
  52815. * @param name The name of the effect
  52816. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52817. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52818. */
  52819. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52820. /**
  52821. * Checks if all the post processes in the effect are supported.
  52822. */
  52823. readonly isSupported: boolean;
  52824. /**
  52825. * Updates the current state of the effect
  52826. * @hidden
  52827. */
  52828. _update(): void;
  52829. /**
  52830. * Attaches the effect on cameras
  52831. * @param cameras The camera to attach to.
  52832. * @hidden
  52833. */
  52834. _attachCameras(cameras: Camera): void;
  52835. /**
  52836. * Attaches the effect on cameras
  52837. * @param cameras The camera to attach to.
  52838. * @hidden
  52839. */
  52840. _attachCameras(cameras: Camera[]): void;
  52841. /**
  52842. * Detatches the effect on cameras
  52843. * @param cameras The camera to detatch from.
  52844. * @hidden
  52845. */
  52846. _detachCameras(cameras: Camera): void;
  52847. /**
  52848. * Detatches the effect on cameras
  52849. * @param cameras The camera to detatch from.
  52850. * @hidden
  52851. */
  52852. _detachCameras(cameras: Camera[]): void;
  52853. /**
  52854. * Enables the effect on given cameras
  52855. * @param cameras The camera to enable.
  52856. * @hidden
  52857. */
  52858. _enable(cameras: Camera): void;
  52859. /**
  52860. * Enables the effect on given cameras
  52861. * @param cameras The camera to enable.
  52862. * @hidden
  52863. */
  52864. _enable(cameras: Nullable<Camera[]>): void;
  52865. /**
  52866. * Disables the effect on the given cameras
  52867. * @param cameras The camera to disable.
  52868. * @hidden
  52869. */
  52870. _disable(cameras: Camera): void;
  52871. /**
  52872. * Disables the effect on the given cameras
  52873. * @param cameras The camera to disable.
  52874. * @hidden
  52875. */
  52876. _disable(cameras: Nullable<Camera[]>): void;
  52877. /**
  52878. * Gets a list of the post processes contained in the effect.
  52879. * @param camera The camera to get the post processes on.
  52880. * @returns The list of the post processes in the effect.
  52881. */
  52882. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52883. }
  52884. }
  52885. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52886. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52887. /** @hidden */
  52888. export var extractHighlightsPixelShader: {
  52889. name: string;
  52890. shader: string;
  52891. };
  52892. }
  52893. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52894. import { Nullable } from "babylonjs/types";
  52895. import { Camera } from "babylonjs/Cameras/camera";
  52896. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52897. import { Engine } from "babylonjs/Engines/engine";
  52898. import "babylonjs/Shaders/extractHighlights.fragment";
  52899. /**
  52900. * 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.
  52901. */
  52902. export class ExtractHighlightsPostProcess extends PostProcess {
  52903. /**
  52904. * The luminance threshold, pixels below this value will be set to black.
  52905. */
  52906. threshold: number;
  52907. /** @hidden */
  52908. _exposure: number;
  52909. /**
  52910. * Post process which has the input texture to be used when performing highlight extraction
  52911. * @hidden
  52912. */
  52913. _inputPostProcess: Nullable<PostProcess>;
  52914. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52915. }
  52916. }
  52917. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52918. /** @hidden */
  52919. export var bloomMergePixelShader: {
  52920. name: string;
  52921. shader: string;
  52922. };
  52923. }
  52924. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52925. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52926. import { Nullable } from "babylonjs/types";
  52927. import { Engine } from "babylonjs/Engines/engine";
  52928. import { Camera } from "babylonjs/Cameras/camera";
  52929. import "babylonjs/Shaders/bloomMerge.fragment";
  52930. /**
  52931. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52932. */
  52933. export class BloomMergePostProcess extends PostProcess {
  52934. /** Weight of the bloom to be added to the original input. */
  52935. weight: number;
  52936. /**
  52937. * Creates a new instance of @see BloomMergePostProcess
  52938. * @param name The name of the effect.
  52939. * @param originalFromInput Post process which's input will be used for the merge.
  52940. * @param blurred Blurred highlights post process which's output will be used.
  52941. * @param weight Weight of the bloom to be added to the original input.
  52942. * @param options The required width/height ratio to downsize to before computing the render pass.
  52943. * @param camera The camera to apply the render pass to.
  52944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52945. * @param engine The engine which the post process will be applied. (default: current engine)
  52946. * @param reusable If the post process can be reused on the same frame. (default: false)
  52947. * @param textureType Type of textures used when performing the post process. (default: 0)
  52948. * @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)
  52949. */
  52950. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52951. /** Weight of the bloom to be added to the original input. */
  52952. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52953. }
  52954. }
  52955. declare module "babylonjs/PostProcesses/bloomEffect" {
  52956. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52957. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52958. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52959. import { Camera } from "babylonjs/Cameras/camera";
  52960. import { Scene } from "babylonjs/scene";
  52961. /**
  52962. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52963. */
  52964. export class BloomEffect extends PostProcessRenderEffect {
  52965. private bloomScale;
  52966. /**
  52967. * @hidden Internal
  52968. */
  52969. _effects: Array<PostProcess>;
  52970. /**
  52971. * @hidden Internal
  52972. */
  52973. _downscale: ExtractHighlightsPostProcess;
  52974. private _blurX;
  52975. private _blurY;
  52976. private _merge;
  52977. /**
  52978. * The luminance threshold to find bright areas of the image to bloom.
  52979. */
  52980. threshold: number;
  52981. /**
  52982. * The strength of the bloom.
  52983. */
  52984. weight: number;
  52985. /**
  52986. * Specifies the size of the bloom blur kernel, relative to the final output size
  52987. */
  52988. kernel: number;
  52989. /**
  52990. * Creates a new instance of @see BloomEffect
  52991. * @param scene The scene the effect belongs to.
  52992. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52993. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52994. * @param bloomWeight The the strength of bloom.
  52995. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52996. * @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)
  52997. */
  52998. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52999. /**
  53000. * Disposes each of the internal effects for a given camera.
  53001. * @param camera The camera to dispose the effect on.
  53002. */
  53003. disposeEffects(camera: Camera): void;
  53004. /**
  53005. * @hidden Internal
  53006. */
  53007. _updateEffects(): void;
  53008. /**
  53009. * Internal
  53010. * @returns if all the contained post processes are ready.
  53011. * @hidden
  53012. */
  53013. _isReady(): boolean;
  53014. }
  53015. }
  53016. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  53017. /** @hidden */
  53018. export var chromaticAberrationPixelShader: {
  53019. name: string;
  53020. shader: string;
  53021. };
  53022. }
  53023. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  53024. import { Vector2 } from "babylonjs/Maths/math";
  53025. import { Nullable } from "babylonjs/types";
  53026. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53027. import { Camera } from "babylonjs/Cameras/camera";
  53028. import { Engine } from "babylonjs/Engines/engine";
  53029. import "babylonjs/Shaders/chromaticAberration.fragment";
  53030. /**
  53031. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53032. */
  53033. export class ChromaticAberrationPostProcess extends PostProcess {
  53034. /**
  53035. * The amount of seperation of rgb channels (default: 30)
  53036. */
  53037. aberrationAmount: number;
  53038. /**
  53039. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53040. */
  53041. radialIntensity: number;
  53042. /**
  53043. * 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))
  53044. */
  53045. direction: Vector2;
  53046. /**
  53047. * 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))
  53048. */
  53049. centerPosition: Vector2;
  53050. /**
  53051. * Creates a new instance ChromaticAberrationPostProcess
  53052. * @param name The name of the effect.
  53053. * @param screenWidth The width of the screen to apply the effect on.
  53054. * @param screenHeight The height of the screen to apply the effect on.
  53055. * @param options The required width/height ratio to downsize to before computing the render pass.
  53056. * @param camera The camera to apply the render pass to.
  53057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53058. * @param engine The engine which the post process will be applied. (default: current engine)
  53059. * @param reusable If the post process can be reused on the same frame. (default: false)
  53060. * @param textureType Type of textures used when performing the post process. (default: 0)
  53061. * @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)
  53062. */
  53063. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53064. }
  53065. }
  53066. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  53067. /** @hidden */
  53068. export var circleOfConfusionPixelShader: {
  53069. name: string;
  53070. shader: string;
  53071. };
  53072. }
  53073. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  53074. import { Nullable } from "babylonjs/types";
  53075. import { Engine } from "babylonjs/Engines/engine";
  53076. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53077. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53078. import { Camera } from "babylonjs/Cameras/camera";
  53079. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53080. /**
  53081. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53082. */
  53083. export class CircleOfConfusionPostProcess extends PostProcess {
  53084. /**
  53085. * 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.
  53086. */
  53087. lensSize: number;
  53088. /**
  53089. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53090. */
  53091. fStop: number;
  53092. /**
  53093. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53094. */
  53095. focusDistance: number;
  53096. /**
  53097. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53098. */
  53099. focalLength: number;
  53100. private _depthTexture;
  53101. /**
  53102. * Creates a new instance CircleOfConfusionPostProcess
  53103. * @param name The name of the effect.
  53104. * @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.
  53105. * @param options The required width/height ratio to downsize to before computing the render pass.
  53106. * @param camera The camera to apply the render pass to.
  53107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53108. * @param engine The engine which the post process will be applied. (default: current engine)
  53109. * @param reusable If the post process can be reused on the same frame. (default: false)
  53110. * @param textureType Type of textures used when performing the post process. (default: 0)
  53111. * @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)
  53112. */
  53113. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53114. /**
  53115. * 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.
  53116. */
  53117. depthTexture: RenderTargetTexture;
  53118. }
  53119. }
  53120. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53121. /** @hidden */
  53122. export var colorCorrectionPixelShader: {
  53123. name: string;
  53124. shader: string;
  53125. };
  53126. }
  53127. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53128. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53129. import { Engine } from "babylonjs/Engines/engine";
  53130. import { Camera } from "babylonjs/Cameras/camera";
  53131. import "babylonjs/Shaders/colorCorrection.fragment";
  53132. /**
  53133. *
  53134. * This post-process allows the modification of rendered colors by using
  53135. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53136. *
  53137. * The object needs to be provided an url to a texture containing the color
  53138. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53139. * Use an image editing software to tweak the LUT to match your needs.
  53140. *
  53141. * For an example of a color LUT, see here:
  53142. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53143. * For explanations on color grading, see here:
  53144. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53145. *
  53146. */
  53147. export class ColorCorrectionPostProcess extends PostProcess {
  53148. private _colorTableTexture;
  53149. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53150. }
  53151. }
  53152. declare module "babylonjs/Shaders/convolution.fragment" {
  53153. /** @hidden */
  53154. export var convolutionPixelShader: {
  53155. name: string;
  53156. shader: string;
  53157. };
  53158. }
  53159. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53160. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53161. import { Nullable } from "babylonjs/types";
  53162. import { Camera } from "babylonjs/Cameras/camera";
  53163. import { Engine } from "babylonjs/Engines/engine";
  53164. import "babylonjs/Shaders/convolution.fragment";
  53165. /**
  53166. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53167. * input texture to perform effects such as edge detection or sharpening
  53168. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53169. */
  53170. export class ConvolutionPostProcess extends PostProcess {
  53171. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53172. kernel: number[];
  53173. /**
  53174. * Creates a new instance ConvolutionPostProcess
  53175. * @param name The name of the effect.
  53176. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53177. * @param options The required width/height ratio to downsize to before computing the render pass.
  53178. * @param camera The camera to apply the render pass to.
  53179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53180. * @param engine The engine which the post process will be applied. (default: current engine)
  53181. * @param reusable If the post process can be reused on the same frame. (default: false)
  53182. * @param textureType Type of textures used when performing the post process. (default: 0)
  53183. */
  53184. constructor(name: string,
  53185. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53186. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53187. /**
  53188. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53189. */
  53190. static EdgeDetect0Kernel: number[];
  53191. /**
  53192. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53193. */
  53194. static EdgeDetect1Kernel: number[];
  53195. /**
  53196. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53197. */
  53198. static EdgeDetect2Kernel: number[];
  53199. /**
  53200. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53201. */
  53202. static SharpenKernel: number[];
  53203. /**
  53204. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53205. */
  53206. static EmbossKernel: number[];
  53207. /**
  53208. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53209. */
  53210. static GaussianKernel: number[];
  53211. }
  53212. }
  53213. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53214. import { Nullable } from "babylonjs/types";
  53215. import { Vector2 } from "babylonjs/Maths/math";
  53216. import { Camera } from "babylonjs/Cameras/camera";
  53217. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53218. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53219. import { Engine } from "babylonjs/Engines/engine";
  53220. import { Scene } from "babylonjs/scene";
  53221. /**
  53222. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53223. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53224. * based on samples that have a large difference in distance than the center pixel.
  53225. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53226. */
  53227. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53228. direction: Vector2;
  53229. /**
  53230. * Creates a new instance CircleOfConfusionPostProcess
  53231. * @param name The name of the effect.
  53232. * @param scene The scene the effect belongs to.
  53233. * @param direction The direction the blur should be applied.
  53234. * @param kernel The size of the kernel used to blur.
  53235. * @param options The required width/height ratio to downsize to before computing the render pass.
  53236. * @param camera The camera to apply the render pass to.
  53237. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53238. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53240. * @param engine The engine which the post process will be applied. (default: current engine)
  53241. * @param reusable If the post process can be reused on the same frame. (default: false)
  53242. * @param textureType Type of textures used when performing the post process. (default: 0)
  53243. * @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)
  53244. */
  53245. 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);
  53246. }
  53247. }
  53248. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53249. /** @hidden */
  53250. export var depthOfFieldMergePixelShader: {
  53251. name: string;
  53252. shader: string;
  53253. };
  53254. }
  53255. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53256. import { Nullable } from "babylonjs/types";
  53257. import { Camera } from "babylonjs/Cameras/camera";
  53258. import { Effect } from "babylonjs/Materials/effect";
  53259. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53260. import { Engine } from "babylonjs/Engines/engine";
  53261. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53262. /**
  53263. * Options to be set when merging outputs from the default pipeline.
  53264. */
  53265. export class DepthOfFieldMergePostProcessOptions {
  53266. /**
  53267. * The original image to merge on top of
  53268. */
  53269. originalFromInput: PostProcess;
  53270. /**
  53271. * Parameters to perform the merge of the depth of field effect
  53272. */
  53273. depthOfField?: {
  53274. circleOfConfusion: PostProcess;
  53275. blurSteps: Array<PostProcess>;
  53276. };
  53277. /**
  53278. * Parameters to perform the merge of bloom effect
  53279. */
  53280. bloom?: {
  53281. blurred: PostProcess;
  53282. weight: number;
  53283. };
  53284. }
  53285. /**
  53286. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53287. */
  53288. export class DepthOfFieldMergePostProcess extends PostProcess {
  53289. private blurSteps;
  53290. /**
  53291. * Creates a new instance of DepthOfFieldMergePostProcess
  53292. * @param name The name of the effect.
  53293. * @param originalFromInput Post process which's input will be used for the merge.
  53294. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53295. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53296. * @param options The required width/height ratio to downsize to before computing the render pass.
  53297. * @param camera The camera to apply the render pass to.
  53298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53299. * @param engine The engine which the post process will be applied. (default: current engine)
  53300. * @param reusable If the post process can be reused on the same frame. (default: false)
  53301. * @param textureType Type of textures used when performing the post process. (default: 0)
  53302. * @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)
  53303. */
  53304. 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);
  53305. /**
  53306. * Updates the effect with the current post process compile time values and recompiles the shader.
  53307. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53308. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53309. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53310. * @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
  53311. * @param onCompiled Called when the shader has been compiled.
  53312. * @param onError Called if there is an error when compiling a shader.
  53313. */
  53314. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53315. }
  53316. }
  53317. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53318. import { Nullable } from "babylonjs/types";
  53319. import { Camera } from "babylonjs/Cameras/camera";
  53320. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53321. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53322. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53323. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53324. import { Scene } from "babylonjs/scene";
  53325. /**
  53326. * Specifies the level of max blur that should be applied when using the depth of field effect
  53327. */
  53328. export enum DepthOfFieldEffectBlurLevel {
  53329. /**
  53330. * Subtle blur
  53331. */
  53332. Low = 0,
  53333. /**
  53334. * Medium blur
  53335. */
  53336. Medium = 1,
  53337. /**
  53338. * Large blur
  53339. */
  53340. High = 2
  53341. }
  53342. /**
  53343. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53344. */
  53345. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53346. private _circleOfConfusion;
  53347. /**
  53348. * @hidden Internal, blurs from high to low
  53349. */
  53350. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53351. private _depthOfFieldBlurY;
  53352. private _dofMerge;
  53353. /**
  53354. * @hidden Internal post processes in depth of field effect
  53355. */
  53356. _effects: Array<PostProcess>;
  53357. /**
  53358. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53359. */
  53360. focalLength: number;
  53361. /**
  53362. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53363. */
  53364. fStop: number;
  53365. /**
  53366. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53367. */
  53368. focusDistance: number;
  53369. /**
  53370. * 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.
  53371. */
  53372. lensSize: number;
  53373. /**
  53374. * Creates a new instance DepthOfFieldEffect
  53375. * @param scene The scene the effect belongs to.
  53376. * @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.
  53377. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53378. * @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)
  53379. */
  53380. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53381. /**
  53382. * 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.
  53383. */
  53384. depthTexture: RenderTargetTexture;
  53385. /**
  53386. * Disposes each of the internal effects for a given camera.
  53387. * @param camera The camera to dispose the effect on.
  53388. */
  53389. disposeEffects(camera: Camera): void;
  53390. /**
  53391. * @hidden Internal
  53392. */
  53393. _updateEffects(): void;
  53394. /**
  53395. * Internal
  53396. * @returns if all the contained post processes are ready.
  53397. * @hidden
  53398. */
  53399. _isReady(): boolean;
  53400. }
  53401. }
  53402. declare module "babylonjs/Shaders/displayPass.fragment" {
  53403. /** @hidden */
  53404. export var displayPassPixelShader: {
  53405. name: string;
  53406. shader: string;
  53407. };
  53408. }
  53409. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53410. import { Nullable } from "babylonjs/types";
  53411. import { Camera } from "babylonjs/Cameras/camera";
  53412. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53413. import { Engine } from "babylonjs/Engines/engine";
  53414. import "babylonjs/Shaders/displayPass.fragment";
  53415. /**
  53416. * DisplayPassPostProcess which produces an output the same as it's input
  53417. */
  53418. export class DisplayPassPostProcess extends PostProcess {
  53419. /**
  53420. * Creates the DisplayPassPostProcess
  53421. * @param name The name of the effect.
  53422. * @param options The required width/height ratio to downsize to before computing the render pass.
  53423. * @param camera The camera to apply the render pass to.
  53424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53425. * @param engine The engine which the post process will be applied. (default: current engine)
  53426. * @param reusable If the post process can be reused on the same frame. (default: false)
  53427. */
  53428. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53429. }
  53430. }
  53431. declare module "babylonjs/Shaders/filter.fragment" {
  53432. /** @hidden */
  53433. export var filterPixelShader: {
  53434. name: string;
  53435. shader: string;
  53436. };
  53437. }
  53438. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53439. import { Nullable } from "babylonjs/types";
  53440. import { Matrix } from "babylonjs/Maths/math";
  53441. import { Camera } from "babylonjs/Cameras/camera";
  53442. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53443. import { Engine } from "babylonjs/Engines/engine";
  53444. import "babylonjs/Shaders/filter.fragment";
  53445. /**
  53446. * Applies a kernel filter to the image
  53447. */
  53448. export class FilterPostProcess extends PostProcess {
  53449. /** The matrix to be applied to the image */
  53450. kernelMatrix: Matrix;
  53451. /**
  53452. *
  53453. * @param name The name of the effect.
  53454. * @param kernelMatrix The matrix to be applied to the image
  53455. * @param options The required width/height ratio to downsize to before computing the render pass.
  53456. * @param camera The camera to apply the render pass to.
  53457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53458. * @param engine The engine which the post process will be applied. (default: current engine)
  53459. * @param reusable If the post process can be reused on the same frame. (default: false)
  53460. */
  53461. constructor(name: string,
  53462. /** The matrix to be applied to the image */
  53463. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53464. }
  53465. }
  53466. declare module "babylonjs/Shaders/fxaa.fragment" {
  53467. /** @hidden */
  53468. export var fxaaPixelShader: {
  53469. name: string;
  53470. shader: string;
  53471. };
  53472. }
  53473. declare module "babylonjs/Shaders/fxaa.vertex" {
  53474. /** @hidden */
  53475. export var fxaaVertexShader: {
  53476. name: string;
  53477. shader: string;
  53478. };
  53479. }
  53480. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53481. import { Nullable } from "babylonjs/types";
  53482. import { Camera } from "babylonjs/Cameras/camera";
  53483. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53484. import { Engine } from "babylonjs/Engines/engine";
  53485. import "babylonjs/Shaders/fxaa.fragment";
  53486. import "babylonjs/Shaders/fxaa.vertex";
  53487. /**
  53488. * Fxaa post process
  53489. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53490. */
  53491. export class FxaaPostProcess extends PostProcess {
  53492. /** @hidden */
  53493. texelWidth: number;
  53494. /** @hidden */
  53495. texelHeight: number;
  53496. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53497. private _getDefines;
  53498. }
  53499. }
  53500. declare module "babylonjs/Shaders/grain.fragment" {
  53501. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53502. /** @hidden */
  53503. export var grainPixelShader: {
  53504. name: string;
  53505. shader: string;
  53506. };
  53507. }
  53508. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53509. import { Nullable } from "babylonjs/types";
  53510. import { Camera } from "babylonjs/Cameras/camera";
  53511. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53512. import { Engine } from "babylonjs/Engines/engine";
  53513. import "babylonjs/Shaders/grain.fragment";
  53514. /**
  53515. * The GrainPostProcess adds noise to the image at mid luminance levels
  53516. */
  53517. export class GrainPostProcess extends PostProcess {
  53518. /**
  53519. * The intensity of the grain added (default: 30)
  53520. */
  53521. intensity: number;
  53522. /**
  53523. * If the grain should be randomized on every frame
  53524. */
  53525. animated: boolean;
  53526. /**
  53527. * Creates a new instance of @see GrainPostProcess
  53528. * @param name The name of the effect.
  53529. * @param options The required width/height ratio to downsize to before computing the render pass.
  53530. * @param camera The camera to apply the render pass to.
  53531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53532. * @param engine The engine which the post process will be applied. (default: current engine)
  53533. * @param reusable If the post process can be reused on the same frame. (default: false)
  53534. * @param textureType Type of textures used when performing the post process. (default: 0)
  53535. * @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)
  53536. */
  53537. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53538. }
  53539. }
  53540. declare module "babylonjs/Shaders/highlights.fragment" {
  53541. /** @hidden */
  53542. export var highlightsPixelShader: {
  53543. name: string;
  53544. shader: string;
  53545. };
  53546. }
  53547. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53548. import { Nullable } from "babylonjs/types";
  53549. import { Camera } from "babylonjs/Cameras/camera";
  53550. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53551. import { Engine } from "babylonjs/Engines/engine";
  53552. import "babylonjs/Shaders/highlights.fragment";
  53553. /**
  53554. * Extracts highlights from the image
  53555. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53556. */
  53557. export class HighlightsPostProcess extends PostProcess {
  53558. /**
  53559. * Extracts highlights from the image
  53560. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53561. * @param name The name of the effect.
  53562. * @param options The required width/height ratio to downsize to before computing the render pass.
  53563. * @param camera The camera to apply the render pass to.
  53564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53565. * @param engine The engine which the post process will be applied. (default: current engine)
  53566. * @param reusable If the post process can be reused on the same frame. (default: false)
  53567. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53568. */
  53569. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53570. }
  53571. }
  53572. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53573. /** @hidden */
  53574. export var mrtFragmentDeclaration: {
  53575. name: string;
  53576. shader: string;
  53577. };
  53578. }
  53579. declare module "babylonjs/Shaders/geometry.fragment" {
  53580. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53581. /** @hidden */
  53582. export var geometryPixelShader: {
  53583. name: string;
  53584. shader: string;
  53585. };
  53586. }
  53587. declare module "babylonjs/Shaders/geometry.vertex" {
  53588. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53589. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53590. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53591. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53592. /** @hidden */
  53593. export var geometryVertexShader: {
  53594. name: string;
  53595. shader: string;
  53596. };
  53597. }
  53598. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53599. import { Matrix } from "babylonjs/Maths/math";
  53600. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53601. import { Mesh } from "babylonjs/Meshes/mesh";
  53602. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53603. import { Effect } from "babylonjs/Materials/effect";
  53604. import { Scene } from "babylonjs/scene";
  53605. import "babylonjs/Shaders/geometry.fragment";
  53606. import "babylonjs/Shaders/geometry.vertex";
  53607. /**
  53608. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53609. */
  53610. export class GeometryBufferRenderer {
  53611. /**
  53612. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53613. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53614. */
  53615. static readonly POSITION_TEXTURE_TYPE: number;
  53616. /**
  53617. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53618. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53619. */
  53620. static readonly VELOCITY_TEXTURE_TYPE: number;
  53621. /**
  53622. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53623. * in order to compute objects velocities when enableVelocity is set to "true"
  53624. * @hidden
  53625. */
  53626. _previousTransformationMatrices: {
  53627. [index: number]: Matrix;
  53628. };
  53629. private _scene;
  53630. private _multiRenderTarget;
  53631. private _ratio;
  53632. private _enablePosition;
  53633. private _enableVelocity;
  53634. private _positionIndex;
  53635. private _velocityIndex;
  53636. protected _effect: Effect;
  53637. protected _cachedDefines: string;
  53638. /**
  53639. * Set the render list (meshes to be rendered) used in the G buffer.
  53640. */
  53641. renderList: Mesh[];
  53642. /**
  53643. * Gets wether or not G buffer are supported by the running hardware.
  53644. * This requires draw buffer supports
  53645. */
  53646. readonly isSupported: boolean;
  53647. /**
  53648. * Returns the index of the given texture type in the G-Buffer textures array
  53649. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53650. * @returns the index of the given texture type in the G-Buffer textures array
  53651. */
  53652. getTextureIndex(textureType: number): number;
  53653. /**
  53654. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53655. */
  53656. /**
  53657. * Sets whether or not objects positions are enabled for the G buffer.
  53658. */
  53659. enablePosition: boolean;
  53660. /**
  53661. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53662. */
  53663. /**
  53664. * Sets wether or not objects velocities are enabled for the G buffer.
  53665. */
  53666. enableVelocity: boolean;
  53667. /**
  53668. * Gets the scene associated with the buffer.
  53669. */
  53670. readonly scene: Scene;
  53671. /**
  53672. * Gets the ratio used by the buffer during its creation.
  53673. * How big is the buffer related to the main canvas.
  53674. */
  53675. readonly ratio: number;
  53676. /** @hidden */
  53677. static _SceneComponentInitialization: (scene: Scene) => void;
  53678. /**
  53679. * Creates a new G Buffer for the scene
  53680. * @param scene The scene the buffer belongs to
  53681. * @param ratio How big is the buffer related to the main canvas.
  53682. */
  53683. constructor(scene: Scene, ratio?: number);
  53684. /**
  53685. * Checks wether everything is ready to render a submesh to the G buffer.
  53686. * @param subMesh the submesh to check readiness for
  53687. * @param useInstances is the mesh drawn using instance or not
  53688. * @returns true if ready otherwise false
  53689. */
  53690. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53691. /**
  53692. * Gets the current underlying G Buffer.
  53693. * @returns the buffer
  53694. */
  53695. getGBuffer(): MultiRenderTarget;
  53696. /**
  53697. * Gets the number of samples used to render the buffer (anti aliasing).
  53698. */
  53699. /**
  53700. * Sets the number of samples used to render the buffer (anti aliasing).
  53701. */
  53702. samples: number;
  53703. /**
  53704. * Disposes the renderer and frees up associated resources.
  53705. */
  53706. dispose(): void;
  53707. protected _createRenderTargets(): void;
  53708. }
  53709. }
  53710. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53711. import { Nullable } from "babylonjs/types";
  53712. import { Scene } from "babylonjs/scene";
  53713. import { ISceneComponent } from "babylonjs/sceneComponent";
  53714. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53715. module "babylonjs/scene" {
  53716. interface Scene {
  53717. /** @hidden (Backing field) */
  53718. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53719. /**
  53720. * Gets or Sets the current geometry buffer associated to the scene.
  53721. */
  53722. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53723. /**
  53724. * Enables a GeometryBufferRender and associates it with the scene
  53725. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53726. * @returns the GeometryBufferRenderer
  53727. */
  53728. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53729. /**
  53730. * Disables the GeometryBufferRender associated with the scene
  53731. */
  53732. disableGeometryBufferRenderer(): void;
  53733. }
  53734. }
  53735. /**
  53736. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53737. * in several rendering techniques.
  53738. */
  53739. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53740. /**
  53741. * The component name helpful to identify the component in the list of scene components.
  53742. */
  53743. readonly name: string;
  53744. /**
  53745. * The scene the component belongs to.
  53746. */
  53747. scene: Scene;
  53748. /**
  53749. * Creates a new instance of the component for the given scene
  53750. * @param scene Defines the scene to register the component in
  53751. */
  53752. constructor(scene: Scene);
  53753. /**
  53754. * Registers the component in a given scene
  53755. */
  53756. register(): void;
  53757. /**
  53758. * Rebuilds the elements related to this component in case of
  53759. * context lost for instance.
  53760. */
  53761. rebuild(): void;
  53762. /**
  53763. * Disposes the component and the associated ressources
  53764. */
  53765. dispose(): void;
  53766. private _gatherRenderTargets;
  53767. }
  53768. }
  53769. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53770. /** @hidden */
  53771. export var motionBlurPixelShader: {
  53772. name: string;
  53773. shader: string;
  53774. };
  53775. }
  53776. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53777. import { Nullable } from "babylonjs/types";
  53778. import { Camera } from "babylonjs/Cameras/camera";
  53779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53780. import { Scene } from "babylonjs/scene";
  53781. import "babylonjs/Animations/animatable";
  53782. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53783. import "babylonjs/Shaders/motionBlur.fragment";
  53784. import { Engine } from "babylonjs/Engines/engine";
  53785. /**
  53786. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53787. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53788. * As an example, all you have to do is to create the post-process:
  53789. * var mb = new BABYLON.MotionBlurPostProcess(
  53790. * 'mb', // The name of the effect.
  53791. * scene, // The scene containing the objects to blur according to their velocity.
  53792. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53793. * camera // The camera to apply the render pass to.
  53794. * );
  53795. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53796. */
  53797. export class MotionBlurPostProcess extends PostProcess {
  53798. /**
  53799. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53800. */
  53801. motionStrength: number;
  53802. /**
  53803. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53804. */
  53805. /**
  53806. * Sets the number of iterations to be used for motion blur quality
  53807. */
  53808. motionBlurSamples: number;
  53809. private _motionBlurSamples;
  53810. private _geometryBufferRenderer;
  53811. /**
  53812. * Creates a new instance MotionBlurPostProcess
  53813. * @param name The name of the effect.
  53814. * @param scene The scene containing the objects to blur according to their velocity.
  53815. * @param options The required width/height ratio to downsize to before computing the render pass.
  53816. * @param camera The camera to apply the render pass to.
  53817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53818. * @param engine The engine which the post process will be applied. (default: current engine)
  53819. * @param reusable If the post process can be reused on the same frame. (default: false)
  53820. * @param textureType Type of textures used when performing the post process. (default: 0)
  53821. * @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)
  53822. */
  53823. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53824. /**
  53825. * Disposes the post process.
  53826. * @param camera The camera to dispose the post process on.
  53827. */
  53828. dispose(camera?: Camera): void;
  53829. }
  53830. }
  53831. declare module "babylonjs/Shaders/refraction.fragment" {
  53832. /** @hidden */
  53833. export var refractionPixelShader: {
  53834. name: string;
  53835. shader: string;
  53836. };
  53837. }
  53838. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53839. import { Color3 } from "babylonjs/Maths/math";
  53840. import { Camera } from "babylonjs/Cameras/camera";
  53841. import { Texture } from "babylonjs/Materials/Textures/texture";
  53842. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53843. import { Engine } from "babylonjs/Engines/engine";
  53844. import "babylonjs/Shaders/refraction.fragment";
  53845. /**
  53846. * Post process which applies a refractin texture
  53847. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53848. */
  53849. export class RefractionPostProcess extends PostProcess {
  53850. /** the base color of the refraction (used to taint the rendering) */
  53851. color: Color3;
  53852. /** simulated refraction depth */
  53853. depth: number;
  53854. /** the coefficient of the base color (0 to remove base color tainting) */
  53855. colorLevel: number;
  53856. private _refTexture;
  53857. private _ownRefractionTexture;
  53858. /**
  53859. * Gets or sets the refraction texture
  53860. * Please note that you are responsible for disposing the texture if you set it manually
  53861. */
  53862. refractionTexture: Texture;
  53863. /**
  53864. * Initializes the RefractionPostProcess
  53865. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53866. * @param name The name of the effect.
  53867. * @param refractionTextureUrl Url of the refraction texture to use
  53868. * @param color the base color of the refraction (used to taint the rendering)
  53869. * @param depth simulated refraction depth
  53870. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53871. * @param camera The camera to apply the render pass to.
  53872. * @param options The required width/height ratio to downsize to before computing the render pass.
  53873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53874. * @param engine The engine which the post process will be applied. (default: current engine)
  53875. * @param reusable If the post process can be reused on the same frame. (default: false)
  53876. */
  53877. constructor(name: string, refractionTextureUrl: string,
  53878. /** the base color of the refraction (used to taint the rendering) */
  53879. color: Color3,
  53880. /** simulated refraction depth */
  53881. depth: number,
  53882. /** the coefficient of the base color (0 to remove base color tainting) */
  53883. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53884. /**
  53885. * Disposes of the post process
  53886. * @param camera Camera to dispose post process on
  53887. */
  53888. dispose(camera: Camera): void;
  53889. }
  53890. }
  53891. declare module "babylonjs/Shaders/sharpen.fragment" {
  53892. /** @hidden */
  53893. export var sharpenPixelShader: {
  53894. name: string;
  53895. shader: string;
  53896. };
  53897. }
  53898. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53899. import { Nullable } from "babylonjs/types";
  53900. import { Camera } from "babylonjs/Cameras/camera";
  53901. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53902. import "babylonjs/Shaders/sharpen.fragment";
  53903. import { Engine } from "babylonjs/Engines/engine";
  53904. /**
  53905. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53906. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53907. */
  53908. export class SharpenPostProcess extends PostProcess {
  53909. /**
  53910. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53911. */
  53912. colorAmount: number;
  53913. /**
  53914. * How much sharpness should be applied (default: 0.3)
  53915. */
  53916. edgeAmount: number;
  53917. /**
  53918. * Creates a new instance ConvolutionPostProcess
  53919. * @param name The name of the effect.
  53920. * @param options The required width/height ratio to downsize to before computing the render pass.
  53921. * @param camera The camera to apply the render pass to.
  53922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53923. * @param engine The engine which the post process will be applied. (default: current engine)
  53924. * @param reusable If the post process can be reused on the same frame. (default: false)
  53925. * @param textureType Type of textures used when performing the post process. (default: 0)
  53926. * @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)
  53927. */
  53928. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53929. }
  53930. }
  53931. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53932. import { Nullable } from "babylonjs/types";
  53933. import { Camera } from "babylonjs/Cameras/camera";
  53934. import { Engine } from "babylonjs/Engines/engine";
  53935. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53936. /**
  53937. * PostProcessRenderPipeline
  53938. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53939. */
  53940. export class PostProcessRenderPipeline {
  53941. private engine;
  53942. private _renderEffects;
  53943. private _renderEffectsForIsolatedPass;
  53944. /**
  53945. * @hidden
  53946. */
  53947. protected _cameras: Camera[];
  53948. /** @hidden */
  53949. _name: string;
  53950. /**
  53951. * Gets pipeline name
  53952. */
  53953. readonly name: string;
  53954. /**
  53955. * Initializes a PostProcessRenderPipeline
  53956. * @param engine engine to add the pipeline to
  53957. * @param name name of the pipeline
  53958. */
  53959. constructor(engine: Engine, name: string);
  53960. /**
  53961. * Gets the class name
  53962. * @returns "PostProcessRenderPipeline"
  53963. */
  53964. getClassName(): string;
  53965. /**
  53966. * If all the render effects in the pipeline are supported
  53967. */
  53968. readonly isSupported: boolean;
  53969. /**
  53970. * Adds an effect to the pipeline
  53971. * @param renderEffect the effect to add
  53972. */
  53973. addEffect(renderEffect: PostProcessRenderEffect): void;
  53974. /** @hidden */
  53975. _rebuild(): void;
  53976. /** @hidden */
  53977. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53978. /** @hidden */
  53979. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53980. /** @hidden */
  53981. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53982. /** @hidden */
  53983. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53984. /** @hidden */
  53985. _attachCameras(cameras: Camera, unique: boolean): void;
  53986. /** @hidden */
  53987. _attachCameras(cameras: Camera[], unique: boolean): void;
  53988. /** @hidden */
  53989. _detachCameras(cameras: Camera): void;
  53990. /** @hidden */
  53991. _detachCameras(cameras: Nullable<Camera[]>): void;
  53992. /** @hidden */
  53993. _update(): void;
  53994. /** @hidden */
  53995. _reset(): void;
  53996. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53997. /**
  53998. * Disposes of the pipeline
  53999. */
  54000. dispose(): void;
  54001. }
  54002. }
  54003. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54004. import { Camera } from "babylonjs/Cameras/camera";
  54005. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54006. /**
  54007. * PostProcessRenderPipelineManager class
  54008. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54009. */
  54010. export class PostProcessRenderPipelineManager {
  54011. private _renderPipelines;
  54012. /**
  54013. * Initializes a PostProcessRenderPipelineManager
  54014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54015. */
  54016. constructor();
  54017. /**
  54018. * Gets the list of supported render pipelines
  54019. */
  54020. readonly supportedPipelines: PostProcessRenderPipeline[];
  54021. /**
  54022. * Adds a pipeline to the manager
  54023. * @param renderPipeline The pipeline to add
  54024. */
  54025. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54026. /**
  54027. * Attaches a camera to the pipeline
  54028. * @param renderPipelineName The name of the pipeline to attach to
  54029. * @param cameras the camera to attach
  54030. * @param unique if the camera can be attached multiple times to the pipeline
  54031. */
  54032. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54033. /**
  54034. * Detaches a camera from the pipeline
  54035. * @param renderPipelineName The name of the pipeline to detach from
  54036. * @param cameras the camera to detach
  54037. */
  54038. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54039. /**
  54040. * Enables an effect by name on a pipeline
  54041. * @param renderPipelineName the name of the pipeline to enable the effect in
  54042. * @param renderEffectName the name of the effect to enable
  54043. * @param cameras the cameras that the effect should be enabled on
  54044. */
  54045. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54046. /**
  54047. * Disables an effect by name on a pipeline
  54048. * @param renderPipelineName the name of the pipeline to disable the effect in
  54049. * @param renderEffectName the name of the effect to disable
  54050. * @param cameras the cameras that the effect should be disabled on
  54051. */
  54052. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54053. /**
  54054. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54055. */
  54056. update(): void;
  54057. /** @hidden */
  54058. _rebuild(): void;
  54059. /**
  54060. * Disposes of the manager and pipelines
  54061. */
  54062. dispose(): void;
  54063. }
  54064. }
  54065. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54066. import { ISceneComponent } from "babylonjs/sceneComponent";
  54067. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54068. import { Scene } from "babylonjs/scene";
  54069. module "babylonjs/scene" {
  54070. interface Scene {
  54071. /** @hidden (Backing field) */
  54072. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54073. /**
  54074. * Gets the postprocess render pipeline manager
  54075. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54076. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54077. */
  54078. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54079. }
  54080. }
  54081. /**
  54082. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54083. */
  54084. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54085. /**
  54086. * The component name helpfull to identify the component in the list of scene components.
  54087. */
  54088. readonly name: string;
  54089. /**
  54090. * The scene the component belongs to.
  54091. */
  54092. scene: Scene;
  54093. /**
  54094. * Creates a new instance of the component for the given scene
  54095. * @param scene Defines the scene to register the component in
  54096. */
  54097. constructor(scene: Scene);
  54098. /**
  54099. * Registers the component in a given scene
  54100. */
  54101. register(): void;
  54102. /**
  54103. * Rebuilds the elements related to this component in case of
  54104. * context lost for instance.
  54105. */
  54106. rebuild(): void;
  54107. /**
  54108. * Disposes the component and the associated ressources
  54109. */
  54110. dispose(): void;
  54111. private _gatherRenderTargets;
  54112. }
  54113. }
  54114. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54115. import { IAnimatable } from "babylonjs/Misc/tools";
  54116. import { Camera } from "babylonjs/Cameras/camera";
  54117. import { IDisposable } from "babylonjs/scene";
  54118. import { Scene } from "babylonjs/scene";
  54119. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54120. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54121. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54122. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54123. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54124. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54125. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54126. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54127. import { Animation } from "babylonjs/Animations/animation";
  54128. /**
  54129. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54130. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54131. */
  54132. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54133. private _scene;
  54134. private _camerasToBeAttached;
  54135. /**
  54136. * ID of the sharpen post process,
  54137. */
  54138. private readonly SharpenPostProcessId;
  54139. /**
  54140. * @ignore
  54141. * ID of the image processing post process;
  54142. */
  54143. readonly ImageProcessingPostProcessId: string;
  54144. /**
  54145. * @ignore
  54146. * ID of the Fast Approximate Anti-Aliasing post process;
  54147. */
  54148. readonly FxaaPostProcessId: string;
  54149. /**
  54150. * ID of the chromatic aberration post process,
  54151. */
  54152. private readonly ChromaticAberrationPostProcessId;
  54153. /**
  54154. * ID of the grain post process
  54155. */
  54156. private readonly GrainPostProcessId;
  54157. /**
  54158. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54159. */
  54160. sharpen: SharpenPostProcess;
  54161. private _sharpenEffect;
  54162. private bloom;
  54163. /**
  54164. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54165. */
  54166. depthOfField: DepthOfFieldEffect;
  54167. /**
  54168. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54169. */
  54170. fxaa: FxaaPostProcess;
  54171. /**
  54172. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54173. */
  54174. imageProcessing: ImageProcessingPostProcess;
  54175. /**
  54176. * Chromatic aberration post process which will shift rgb colors in the image
  54177. */
  54178. chromaticAberration: ChromaticAberrationPostProcess;
  54179. private _chromaticAberrationEffect;
  54180. /**
  54181. * Grain post process which add noise to the image
  54182. */
  54183. grain: GrainPostProcess;
  54184. private _grainEffect;
  54185. /**
  54186. * Glow post process which adds a glow to emissive areas of the image
  54187. */
  54188. private _glowLayer;
  54189. /**
  54190. * Animations which can be used to tweak settings over a period of time
  54191. */
  54192. animations: Animation[];
  54193. private _imageProcessingConfigurationObserver;
  54194. private _sharpenEnabled;
  54195. private _bloomEnabled;
  54196. private _depthOfFieldEnabled;
  54197. private _depthOfFieldBlurLevel;
  54198. private _fxaaEnabled;
  54199. private _imageProcessingEnabled;
  54200. private _defaultPipelineTextureType;
  54201. private _bloomScale;
  54202. private _chromaticAberrationEnabled;
  54203. private _grainEnabled;
  54204. private _buildAllowed;
  54205. /**
  54206. * Gets active scene
  54207. */
  54208. readonly scene: Scene;
  54209. /**
  54210. * Enable or disable the sharpen process from the pipeline
  54211. */
  54212. sharpenEnabled: boolean;
  54213. private _resizeObserver;
  54214. private _hardwareScaleLevel;
  54215. private _bloomKernel;
  54216. /**
  54217. * Specifies the size of the bloom blur kernel, relative to the final output size
  54218. */
  54219. bloomKernel: number;
  54220. /**
  54221. * Specifies the weight of the bloom in the final rendering
  54222. */
  54223. private _bloomWeight;
  54224. /**
  54225. * Specifies the luma threshold for the area that will be blurred by the bloom
  54226. */
  54227. private _bloomThreshold;
  54228. private _hdr;
  54229. /**
  54230. * The strength of the bloom.
  54231. */
  54232. bloomWeight: number;
  54233. /**
  54234. * The strength of the bloom.
  54235. */
  54236. bloomThreshold: number;
  54237. /**
  54238. * The scale of the bloom, lower value will provide better performance.
  54239. */
  54240. bloomScale: number;
  54241. /**
  54242. * Enable or disable the bloom from the pipeline
  54243. */
  54244. bloomEnabled: boolean;
  54245. private _rebuildBloom;
  54246. /**
  54247. * If the depth of field is enabled.
  54248. */
  54249. depthOfFieldEnabled: boolean;
  54250. /**
  54251. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54252. */
  54253. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54254. /**
  54255. * If the anti aliasing is enabled.
  54256. */
  54257. fxaaEnabled: boolean;
  54258. private _samples;
  54259. /**
  54260. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54261. */
  54262. samples: number;
  54263. /**
  54264. * If image processing is enabled.
  54265. */
  54266. imageProcessingEnabled: boolean;
  54267. /**
  54268. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54269. */
  54270. glowLayerEnabled: boolean;
  54271. /**
  54272. * Enable or disable the chromaticAberration process from the pipeline
  54273. */
  54274. chromaticAberrationEnabled: boolean;
  54275. /**
  54276. * Enable or disable the grain process from the pipeline
  54277. */
  54278. grainEnabled: boolean;
  54279. /**
  54280. * @constructor
  54281. * @param name - The rendering pipeline name (default: "")
  54282. * @param hdr - If high dynamic range textures should be used (default: true)
  54283. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54284. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54285. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54286. */
  54287. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54288. /**
  54289. * Get the class name
  54290. * @returns "DefaultRenderingPipeline"
  54291. */
  54292. getClassName(): string;
  54293. /**
  54294. * Force the compilation of the entire pipeline.
  54295. */
  54296. prepare(): void;
  54297. private _hasCleared;
  54298. private _prevPostProcess;
  54299. private _prevPrevPostProcess;
  54300. private _setAutoClearAndTextureSharing;
  54301. private _depthOfFieldSceneObserver;
  54302. private _buildPipeline;
  54303. private _disposePostProcesses;
  54304. /**
  54305. * Adds a camera to the pipeline
  54306. * @param camera the camera to be added
  54307. */
  54308. addCamera(camera: Camera): void;
  54309. /**
  54310. * Removes a camera from the pipeline
  54311. * @param camera the camera to remove
  54312. */
  54313. removeCamera(camera: Camera): void;
  54314. /**
  54315. * Dispose of the pipeline and stop all post processes
  54316. */
  54317. dispose(): void;
  54318. /**
  54319. * Serialize the rendering pipeline (Used when exporting)
  54320. * @returns the serialized object
  54321. */
  54322. serialize(): any;
  54323. /**
  54324. * Parse the serialized pipeline
  54325. * @param source Source pipeline.
  54326. * @param scene The scene to load the pipeline to.
  54327. * @param rootUrl The URL of the serialized pipeline.
  54328. * @returns An instantiated pipeline from the serialized object.
  54329. */
  54330. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54331. }
  54332. }
  54333. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54334. /** @hidden */
  54335. export var lensHighlightsPixelShader: {
  54336. name: string;
  54337. shader: string;
  54338. };
  54339. }
  54340. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54341. /** @hidden */
  54342. export var depthOfFieldPixelShader: {
  54343. name: string;
  54344. shader: string;
  54345. };
  54346. }
  54347. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54348. import { Camera } from "babylonjs/Cameras/camera";
  54349. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54350. import { Scene } from "babylonjs/scene";
  54351. import "babylonjs/Shaders/chromaticAberration.fragment";
  54352. import "babylonjs/Shaders/lensHighlights.fragment";
  54353. import "babylonjs/Shaders/depthOfField.fragment";
  54354. /**
  54355. * BABYLON.JS Chromatic Aberration GLSL Shader
  54356. * Author: Olivier Guyot
  54357. * Separates very slightly R, G and B colors on the edges of the screen
  54358. * Inspired by Francois Tarlier & Martins Upitis
  54359. */
  54360. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54361. /**
  54362. * @ignore
  54363. * The chromatic aberration PostProcess id in the pipeline
  54364. */
  54365. LensChromaticAberrationEffect: string;
  54366. /**
  54367. * @ignore
  54368. * The highlights enhancing PostProcess id in the pipeline
  54369. */
  54370. HighlightsEnhancingEffect: string;
  54371. /**
  54372. * @ignore
  54373. * The depth-of-field PostProcess id in the pipeline
  54374. */
  54375. LensDepthOfFieldEffect: string;
  54376. private _scene;
  54377. private _depthTexture;
  54378. private _grainTexture;
  54379. private _chromaticAberrationPostProcess;
  54380. private _highlightsPostProcess;
  54381. private _depthOfFieldPostProcess;
  54382. private _edgeBlur;
  54383. private _grainAmount;
  54384. private _chromaticAberration;
  54385. private _distortion;
  54386. private _highlightsGain;
  54387. private _highlightsThreshold;
  54388. private _dofDistance;
  54389. private _dofAperture;
  54390. private _dofDarken;
  54391. private _dofPentagon;
  54392. private _blurNoise;
  54393. /**
  54394. * @constructor
  54395. *
  54396. * Effect parameters are as follow:
  54397. * {
  54398. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54399. * edge_blur: number; // from 0 to x (1 for realism)
  54400. * distortion: number; // from 0 to x (1 for realism)
  54401. * grain_amount: number; // from 0 to 1
  54402. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54403. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54404. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54405. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54406. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54407. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54408. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54409. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54410. * }
  54411. * Note: if an effect parameter is unset, effect is disabled
  54412. *
  54413. * @param name The rendering pipeline name
  54414. * @param parameters - An object containing all parameters (see above)
  54415. * @param scene The scene linked to this pipeline
  54416. * @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)
  54417. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54418. */
  54419. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54420. /**
  54421. * Get the class name
  54422. * @returns "LensRenderingPipeline"
  54423. */
  54424. getClassName(): string;
  54425. /**
  54426. * Gets associated scene
  54427. */
  54428. readonly scene: Scene;
  54429. /**
  54430. * Gets or sets the edge blur
  54431. */
  54432. edgeBlur: number;
  54433. /**
  54434. * Gets or sets the grain amount
  54435. */
  54436. grainAmount: number;
  54437. /**
  54438. * Gets or sets the chromatic aberration amount
  54439. */
  54440. chromaticAberration: number;
  54441. /**
  54442. * Gets or sets the depth of field aperture
  54443. */
  54444. dofAperture: number;
  54445. /**
  54446. * Gets or sets the edge distortion
  54447. */
  54448. edgeDistortion: number;
  54449. /**
  54450. * Gets or sets the depth of field distortion
  54451. */
  54452. dofDistortion: number;
  54453. /**
  54454. * Gets or sets the darken out of focus amount
  54455. */
  54456. darkenOutOfFocus: number;
  54457. /**
  54458. * Gets or sets a boolean indicating if blur noise is enabled
  54459. */
  54460. blurNoise: boolean;
  54461. /**
  54462. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  54463. */
  54464. pentagonBokeh: boolean;
  54465. /**
  54466. * Gets or sets the highlight grain amount
  54467. */
  54468. highlightsGain: number;
  54469. /**
  54470. * Gets or sets the highlight threshold
  54471. */
  54472. highlightsThreshold: number;
  54473. /**
  54474. * Sets the amount of blur at the edges
  54475. * @param amount blur amount
  54476. */
  54477. setEdgeBlur(amount: number): void;
  54478. /**
  54479. * Sets edge blur to 0
  54480. */
  54481. disableEdgeBlur(): void;
  54482. /**
  54483. * Sets the amout of grain
  54484. * @param amount Amount of grain
  54485. */
  54486. setGrainAmount(amount: number): void;
  54487. /**
  54488. * Set grain amount to 0
  54489. */
  54490. disableGrain(): void;
  54491. /**
  54492. * Sets the chromatic aberration amount
  54493. * @param amount amount of chromatic aberration
  54494. */
  54495. setChromaticAberration(amount: number): void;
  54496. /**
  54497. * Sets chromatic aberration amount to 0
  54498. */
  54499. disableChromaticAberration(): void;
  54500. /**
  54501. * Sets the EdgeDistortion amount
  54502. * @param amount amount of EdgeDistortion
  54503. */
  54504. setEdgeDistortion(amount: number): void;
  54505. /**
  54506. * Sets edge distortion to 0
  54507. */
  54508. disableEdgeDistortion(): void;
  54509. /**
  54510. * Sets the FocusDistance amount
  54511. * @param amount amount of FocusDistance
  54512. */
  54513. setFocusDistance(amount: number): void;
  54514. /**
  54515. * Disables depth of field
  54516. */
  54517. disableDepthOfField(): void;
  54518. /**
  54519. * Sets the Aperture amount
  54520. * @param amount amount of Aperture
  54521. */
  54522. setAperture(amount: number): void;
  54523. /**
  54524. * Sets the DarkenOutOfFocus amount
  54525. * @param amount amount of DarkenOutOfFocus
  54526. */
  54527. setDarkenOutOfFocus(amount: number): void;
  54528. private _pentagonBokehIsEnabled;
  54529. /**
  54530. * Creates a pentagon bokeh effect
  54531. */
  54532. enablePentagonBokeh(): void;
  54533. /**
  54534. * Disables the pentagon bokeh effect
  54535. */
  54536. disablePentagonBokeh(): void;
  54537. /**
  54538. * Enables noise blur
  54539. */
  54540. enableNoiseBlur(): void;
  54541. /**
  54542. * Disables noise blur
  54543. */
  54544. disableNoiseBlur(): void;
  54545. /**
  54546. * Sets the HighlightsGain amount
  54547. * @param amount amount of HighlightsGain
  54548. */
  54549. setHighlightsGain(amount: number): void;
  54550. /**
  54551. * Sets the HighlightsThreshold amount
  54552. * @param amount amount of HighlightsThreshold
  54553. */
  54554. setHighlightsThreshold(amount: number): void;
  54555. /**
  54556. * Disables highlights
  54557. */
  54558. disableHighlights(): void;
  54559. /**
  54560. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54561. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54562. */
  54563. dispose(disableDepthRender?: boolean): void;
  54564. private _createChromaticAberrationPostProcess;
  54565. private _createHighlightsPostProcess;
  54566. private _createDepthOfFieldPostProcess;
  54567. private _createGrainTexture;
  54568. }
  54569. }
  54570. declare module "babylonjs/Shaders/ssao2.fragment" {
  54571. /** @hidden */
  54572. export var ssao2PixelShader: {
  54573. name: string;
  54574. shader: string;
  54575. };
  54576. }
  54577. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  54578. /** @hidden */
  54579. export var ssaoCombinePixelShader: {
  54580. name: string;
  54581. shader: string;
  54582. };
  54583. }
  54584. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  54585. import { Camera } from "babylonjs/Cameras/camera";
  54586. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54587. import { Scene } from "babylonjs/scene";
  54588. import "babylonjs/Shaders/ssao2.fragment";
  54589. import "babylonjs/Shaders/ssaoCombine.fragment";
  54590. /**
  54591. * Render pipeline to produce ssao effect
  54592. */
  54593. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54594. /**
  54595. * @ignore
  54596. * The PassPostProcess id in the pipeline that contains the original scene color
  54597. */
  54598. SSAOOriginalSceneColorEffect: string;
  54599. /**
  54600. * @ignore
  54601. * The SSAO PostProcess id in the pipeline
  54602. */
  54603. SSAORenderEffect: string;
  54604. /**
  54605. * @ignore
  54606. * The horizontal blur PostProcess id in the pipeline
  54607. */
  54608. SSAOBlurHRenderEffect: string;
  54609. /**
  54610. * @ignore
  54611. * The vertical blur PostProcess id in the pipeline
  54612. */
  54613. SSAOBlurVRenderEffect: string;
  54614. /**
  54615. * @ignore
  54616. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54617. */
  54618. SSAOCombineRenderEffect: string;
  54619. /**
  54620. * The output strength of the SSAO post-process. Default value is 1.0.
  54621. */
  54622. totalStrength: number;
  54623. /**
  54624. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54625. */
  54626. maxZ: number;
  54627. /**
  54628. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54629. */
  54630. minZAspect: number;
  54631. private _samples;
  54632. /**
  54633. * Number of samples used for the SSAO calculations. Default value is 8
  54634. */
  54635. samples: number;
  54636. private _textureSamples;
  54637. /**
  54638. * Number of samples to use for antialiasing
  54639. */
  54640. textureSamples: number;
  54641. /**
  54642. * Ratio object used for SSAO ratio and blur ratio
  54643. */
  54644. private _ratio;
  54645. /**
  54646. * Dynamically generated sphere sampler.
  54647. */
  54648. private _sampleSphere;
  54649. /**
  54650. * Blur filter offsets
  54651. */
  54652. private _samplerOffsets;
  54653. private _expensiveBlur;
  54654. /**
  54655. * If bilateral blur should be used
  54656. */
  54657. expensiveBlur: boolean;
  54658. /**
  54659. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54660. */
  54661. radius: number;
  54662. /**
  54663. * The base color of the SSAO post-process
  54664. * The final result is "base + ssao" between [0, 1]
  54665. */
  54666. base: number;
  54667. /**
  54668. * Support test.
  54669. */
  54670. static readonly IsSupported: boolean;
  54671. private _scene;
  54672. private _depthTexture;
  54673. private _normalTexture;
  54674. private _randomTexture;
  54675. private _originalColorPostProcess;
  54676. private _ssaoPostProcess;
  54677. private _blurHPostProcess;
  54678. private _blurVPostProcess;
  54679. private _ssaoCombinePostProcess;
  54680. private _firstUpdate;
  54681. /**
  54682. * Gets active scene
  54683. */
  54684. readonly scene: Scene;
  54685. /**
  54686. * @constructor
  54687. * @param name The rendering pipeline name
  54688. * @param scene The scene linked to this pipeline
  54689. * @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 }
  54690. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54691. */
  54692. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54693. /**
  54694. * Get the class name
  54695. * @returns "SSAO2RenderingPipeline"
  54696. */
  54697. getClassName(): string;
  54698. /**
  54699. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54700. */
  54701. dispose(disableGeometryBufferRenderer?: boolean): void;
  54702. private _createBlurPostProcess;
  54703. /** @hidden */
  54704. _rebuild(): void;
  54705. private _bits;
  54706. private _radicalInverse_VdC;
  54707. private _hammersley;
  54708. private _hemisphereSample_uniform;
  54709. private _generateHemisphere;
  54710. private _createSSAOPostProcess;
  54711. private _createSSAOCombinePostProcess;
  54712. private _createRandomTexture;
  54713. /**
  54714. * Serialize the rendering pipeline (Used when exporting)
  54715. * @returns the serialized object
  54716. */
  54717. serialize(): any;
  54718. /**
  54719. * Parse the serialized pipeline
  54720. * @param source Source pipeline.
  54721. * @param scene The scene to load the pipeline to.
  54722. * @param rootUrl The URL of the serialized pipeline.
  54723. * @returns An instantiated pipeline from the serialized object.
  54724. */
  54725. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54726. }
  54727. }
  54728. declare module "babylonjs/Shaders/ssao.fragment" {
  54729. /** @hidden */
  54730. export var ssaoPixelShader: {
  54731. name: string;
  54732. shader: string;
  54733. };
  54734. }
  54735. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54736. import { Camera } from "babylonjs/Cameras/camera";
  54737. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54738. import { Scene } from "babylonjs/scene";
  54739. import "babylonjs/Shaders/ssao.fragment";
  54740. import "babylonjs/Shaders/ssaoCombine.fragment";
  54741. /**
  54742. * Render pipeline to produce ssao effect
  54743. */
  54744. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54745. /**
  54746. * @ignore
  54747. * The PassPostProcess id in the pipeline that contains the original scene color
  54748. */
  54749. SSAOOriginalSceneColorEffect: string;
  54750. /**
  54751. * @ignore
  54752. * The SSAO PostProcess id in the pipeline
  54753. */
  54754. SSAORenderEffect: string;
  54755. /**
  54756. * @ignore
  54757. * The horizontal blur PostProcess id in the pipeline
  54758. */
  54759. SSAOBlurHRenderEffect: string;
  54760. /**
  54761. * @ignore
  54762. * The vertical blur PostProcess id in the pipeline
  54763. */
  54764. SSAOBlurVRenderEffect: string;
  54765. /**
  54766. * @ignore
  54767. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54768. */
  54769. SSAOCombineRenderEffect: string;
  54770. /**
  54771. * The output strength of the SSAO post-process. Default value is 1.0.
  54772. */
  54773. totalStrength: number;
  54774. /**
  54775. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54776. */
  54777. radius: number;
  54778. /**
  54779. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54780. * Must not be equal to fallOff and superior to fallOff.
  54781. * Default value is 0.0075
  54782. */
  54783. area: number;
  54784. /**
  54785. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54786. * Must not be equal to area and inferior to area.
  54787. * Default value is 0.000001
  54788. */
  54789. fallOff: number;
  54790. /**
  54791. * The base color of the SSAO post-process
  54792. * The final result is "base + ssao" between [0, 1]
  54793. */
  54794. base: number;
  54795. private _scene;
  54796. private _depthTexture;
  54797. private _randomTexture;
  54798. private _originalColorPostProcess;
  54799. private _ssaoPostProcess;
  54800. private _blurHPostProcess;
  54801. private _blurVPostProcess;
  54802. private _ssaoCombinePostProcess;
  54803. private _firstUpdate;
  54804. /**
  54805. * Gets active scene
  54806. */
  54807. readonly scene: Scene;
  54808. /**
  54809. * @constructor
  54810. * @param name - The rendering pipeline name
  54811. * @param scene - The scene linked to this pipeline
  54812. * @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 }
  54813. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54814. */
  54815. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54816. /**
  54817. * Get the class name
  54818. * @returns "SSAORenderingPipeline"
  54819. */
  54820. getClassName(): string;
  54821. /**
  54822. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54823. */
  54824. dispose(disableDepthRender?: boolean): void;
  54825. private _createBlurPostProcess;
  54826. /** @hidden */
  54827. _rebuild(): void;
  54828. private _createSSAOPostProcess;
  54829. private _createSSAOCombinePostProcess;
  54830. private _createRandomTexture;
  54831. }
  54832. }
  54833. declare module "babylonjs/Shaders/standard.fragment" {
  54834. /** @hidden */
  54835. export var standardPixelShader: {
  54836. name: string;
  54837. shader: string;
  54838. };
  54839. }
  54840. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54841. import { Nullable } from "babylonjs/types";
  54842. import { IAnimatable } from "babylonjs/Misc/tools";
  54843. import { Camera } from "babylonjs/Cameras/camera";
  54844. import { Texture } from "babylonjs/Materials/Textures/texture";
  54845. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54846. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54847. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54848. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54849. import { IDisposable } from "babylonjs/scene";
  54850. import { SpotLight } from "babylonjs/Lights/spotLight";
  54851. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54852. import { Scene } from "babylonjs/scene";
  54853. import { Animation } from "babylonjs/Animations/animation";
  54854. import "babylonjs/Shaders/standard.fragment";
  54855. /**
  54856. * Standard rendering pipeline
  54857. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54858. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54859. */
  54860. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54861. /**
  54862. * Public members
  54863. */
  54864. /**
  54865. * Post-process which contains the original scene color before the pipeline applies all the effects
  54866. */
  54867. originalPostProcess: Nullable<PostProcess>;
  54868. /**
  54869. * Post-process used to down scale an image x4
  54870. */
  54871. downSampleX4PostProcess: Nullable<PostProcess>;
  54872. /**
  54873. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54874. */
  54875. brightPassPostProcess: Nullable<PostProcess>;
  54876. /**
  54877. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54878. */
  54879. blurHPostProcesses: PostProcess[];
  54880. /**
  54881. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54882. */
  54883. blurVPostProcesses: PostProcess[];
  54884. /**
  54885. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54886. */
  54887. textureAdderPostProcess: Nullable<PostProcess>;
  54888. /**
  54889. * Post-process used to create volumetric lighting effect
  54890. */
  54891. volumetricLightPostProcess: Nullable<PostProcess>;
  54892. /**
  54893. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54894. */
  54895. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54896. /**
  54897. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54898. */
  54899. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54900. /**
  54901. * Post-process used to merge the volumetric light effect and the real scene color
  54902. */
  54903. volumetricLightMergePostProces: Nullable<PostProcess>;
  54904. /**
  54905. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54906. */
  54907. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54908. /**
  54909. * Base post-process used to calculate the average luminance of the final image for HDR
  54910. */
  54911. luminancePostProcess: Nullable<PostProcess>;
  54912. /**
  54913. * Post-processes used to create down sample post-processes in order to get
  54914. * the average luminance of the final image for HDR
  54915. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54916. */
  54917. luminanceDownSamplePostProcesses: PostProcess[];
  54918. /**
  54919. * Post-process used to create a HDR effect (light adaptation)
  54920. */
  54921. hdrPostProcess: Nullable<PostProcess>;
  54922. /**
  54923. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54924. */
  54925. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54926. /**
  54927. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54928. */
  54929. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54930. /**
  54931. * Post-process used to merge the final HDR post-process and the real scene color
  54932. */
  54933. hdrFinalPostProcess: Nullable<PostProcess>;
  54934. /**
  54935. * Post-process used to create a lens flare effect
  54936. */
  54937. lensFlarePostProcess: Nullable<PostProcess>;
  54938. /**
  54939. * Post-process that merges the result of the lens flare post-process and the real scene color
  54940. */
  54941. lensFlareComposePostProcess: Nullable<PostProcess>;
  54942. /**
  54943. * Post-process used to create a motion blur effect
  54944. */
  54945. motionBlurPostProcess: Nullable<PostProcess>;
  54946. /**
  54947. * Post-process used to create a depth of field effect
  54948. */
  54949. depthOfFieldPostProcess: Nullable<PostProcess>;
  54950. /**
  54951. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54952. */
  54953. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54954. /**
  54955. * Represents the brightness threshold in order to configure the illuminated surfaces
  54956. */
  54957. brightThreshold: number;
  54958. /**
  54959. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54960. */
  54961. blurWidth: number;
  54962. /**
  54963. * Sets if the blur for highlighted surfaces must be only horizontal
  54964. */
  54965. horizontalBlur: boolean;
  54966. /**
  54967. * Sets the overall exposure used by the pipeline
  54968. */
  54969. exposure: number;
  54970. /**
  54971. * Texture used typically to simulate "dirty" on camera lens
  54972. */
  54973. lensTexture: Nullable<Texture>;
  54974. /**
  54975. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54976. */
  54977. volumetricLightCoefficient: number;
  54978. /**
  54979. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54980. */
  54981. volumetricLightPower: number;
  54982. /**
  54983. * Used the set the blur intensity to smooth the volumetric lights
  54984. */
  54985. volumetricLightBlurScale: number;
  54986. /**
  54987. * Light (spot or directional) used to generate the volumetric lights rays
  54988. * The source light must have a shadow generate so the pipeline can get its
  54989. * depth map
  54990. */
  54991. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54992. /**
  54993. * For eye adaptation, represents the minimum luminance the eye can see
  54994. */
  54995. hdrMinimumLuminance: number;
  54996. /**
  54997. * For eye adaptation, represents the decrease luminance speed
  54998. */
  54999. hdrDecreaseRate: number;
  55000. /**
  55001. * For eye adaptation, represents the increase luminance speed
  55002. */
  55003. hdrIncreaseRate: number;
  55004. /**
  55005. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55006. */
  55007. lensColorTexture: Nullable<Texture>;
  55008. /**
  55009. * The overall strengh for the lens flare effect
  55010. */
  55011. lensFlareStrength: number;
  55012. /**
  55013. * Dispersion coefficient for lens flare ghosts
  55014. */
  55015. lensFlareGhostDispersal: number;
  55016. /**
  55017. * Main lens flare halo width
  55018. */
  55019. lensFlareHaloWidth: number;
  55020. /**
  55021. * Based on the lens distortion effect, defines how much the lens flare result
  55022. * is distorted
  55023. */
  55024. lensFlareDistortionStrength: number;
  55025. /**
  55026. * Lens star texture must be used to simulate rays on the flares and is available
  55027. * in the documentation
  55028. */
  55029. lensStarTexture: Nullable<Texture>;
  55030. /**
  55031. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55032. * flare effect by taking account of the dirt texture
  55033. */
  55034. lensFlareDirtTexture: Nullable<Texture>;
  55035. /**
  55036. * Represents the focal length for the depth of field effect
  55037. */
  55038. depthOfFieldDistance: number;
  55039. /**
  55040. * Represents the blur intensity for the blurred part of the depth of field effect
  55041. */
  55042. depthOfFieldBlurWidth: number;
  55043. /**
  55044. * For motion blur, defines how much the image is blurred by the movement
  55045. */
  55046. motionStrength: number;
  55047. /**
  55048. * List of animations for the pipeline (IAnimatable implementation)
  55049. */
  55050. animations: Animation[];
  55051. /**
  55052. * Private members
  55053. */
  55054. private _scene;
  55055. private _currentDepthOfFieldSource;
  55056. private _basePostProcess;
  55057. private _hdrCurrentLuminance;
  55058. private _floatTextureType;
  55059. private _ratio;
  55060. private _bloomEnabled;
  55061. private _depthOfFieldEnabled;
  55062. private _vlsEnabled;
  55063. private _lensFlareEnabled;
  55064. private _hdrEnabled;
  55065. private _motionBlurEnabled;
  55066. private _fxaaEnabled;
  55067. private _motionBlurSamples;
  55068. private _volumetricLightStepsCount;
  55069. private _samples;
  55070. /**
  55071. * @ignore
  55072. * Specifies if the bloom pipeline is enabled
  55073. */
  55074. BloomEnabled: boolean;
  55075. /**
  55076. * @ignore
  55077. * Specifies if the depth of field pipeline is enabed
  55078. */
  55079. DepthOfFieldEnabled: boolean;
  55080. /**
  55081. * @ignore
  55082. * Specifies if the lens flare pipeline is enabed
  55083. */
  55084. LensFlareEnabled: boolean;
  55085. /**
  55086. * @ignore
  55087. * Specifies if the HDR pipeline is enabled
  55088. */
  55089. HDREnabled: boolean;
  55090. /**
  55091. * @ignore
  55092. * Specifies if the volumetric lights scattering effect is enabled
  55093. */
  55094. VLSEnabled: boolean;
  55095. /**
  55096. * @ignore
  55097. * Specifies if the motion blur effect is enabled
  55098. */
  55099. MotionBlurEnabled: boolean;
  55100. /**
  55101. * Specifies if anti-aliasing is enabled
  55102. */
  55103. fxaaEnabled: boolean;
  55104. /**
  55105. * Specifies the number of steps used to calculate the volumetric lights
  55106. * Typically in interval [50, 200]
  55107. */
  55108. volumetricLightStepsCount: number;
  55109. /**
  55110. * Specifies the number of samples used for the motion blur effect
  55111. * Typically in interval [16, 64]
  55112. */
  55113. motionBlurSamples: number;
  55114. /**
  55115. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55116. */
  55117. samples: number;
  55118. /**
  55119. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55120. * @constructor
  55121. * @param name The rendering pipeline name
  55122. * @param scene The scene linked to this pipeline
  55123. * @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)
  55124. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55125. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55126. */
  55127. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55128. private _buildPipeline;
  55129. private _createDownSampleX4PostProcess;
  55130. private _createBrightPassPostProcess;
  55131. private _createBlurPostProcesses;
  55132. private _createTextureAdderPostProcess;
  55133. private _createVolumetricLightPostProcess;
  55134. private _createLuminancePostProcesses;
  55135. private _createHdrPostProcess;
  55136. private _createLensFlarePostProcess;
  55137. private _createDepthOfFieldPostProcess;
  55138. private _createMotionBlurPostProcess;
  55139. private _getDepthTexture;
  55140. private _disposePostProcesses;
  55141. /**
  55142. * Dispose of the pipeline and stop all post processes
  55143. */
  55144. dispose(): void;
  55145. /**
  55146. * Serialize the rendering pipeline (Used when exporting)
  55147. * @returns the serialized object
  55148. */
  55149. serialize(): any;
  55150. /**
  55151. * Parse the serialized pipeline
  55152. * @param source Source pipeline.
  55153. * @param scene The scene to load the pipeline to.
  55154. * @param rootUrl The URL of the serialized pipeline.
  55155. * @returns An instantiated pipeline from the serialized object.
  55156. */
  55157. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55158. /**
  55159. * Luminance steps
  55160. */
  55161. static LuminanceSteps: number;
  55162. }
  55163. }
  55164. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55165. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55166. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55167. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55168. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55169. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55170. }
  55171. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55172. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55173. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55174. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55175. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55176. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55177. }
  55178. declare module "babylonjs/Shaders/tonemap.fragment" {
  55179. /** @hidden */
  55180. export var tonemapPixelShader: {
  55181. name: string;
  55182. shader: string;
  55183. };
  55184. }
  55185. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55186. import { Camera } from "babylonjs/Cameras/camera";
  55187. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55188. import "babylonjs/Shaders/tonemap.fragment";
  55189. import { Engine } from "babylonjs/Engines/engine";
  55190. /** Defines operator used for tonemapping */
  55191. export enum TonemappingOperator {
  55192. /** Hable */
  55193. Hable = 0,
  55194. /** Reinhard */
  55195. Reinhard = 1,
  55196. /** HejiDawson */
  55197. HejiDawson = 2,
  55198. /** Photographic */
  55199. Photographic = 3
  55200. }
  55201. /**
  55202. * Defines a post process to apply tone mapping
  55203. */
  55204. export class TonemapPostProcess extends PostProcess {
  55205. private _operator;
  55206. /** Defines the required exposure adjustement */
  55207. exposureAdjustment: number;
  55208. /**
  55209. * Creates a new TonemapPostProcess
  55210. * @param name defines the name of the postprocess
  55211. * @param _operator defines the operator to use
  55212. * @param exposureAdjustment defines the required exposure adjustement
  55213. * @param camera defines the camera to use (can be null)
  55214. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55215. * @param engine defines the hosting engine (can be ignore if camera is set)
  55216. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55217. */
  55218. constructor(name: string, _operator: TonemappingOperator,
  55219. /** Defines the required exposure adjustement */
  55220. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55221. }
  55222. }
  55223. declare module "babylonjs/Shaders/depth.vertex" {
  55224. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55225. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55226. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55227. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55228. /** @hidden */
  55229. export var depthVertexShader: {
  55230. name: string;
  55231. shader: string;
  55232. };
  55233. }
  55234. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55235. /** @hidden */
  55236. export var volumetricLightScatteringPixelShader: {
  55237. name: string;
  55238. shader: string;
  55239. };
  55240. }
  55241. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55242. /** @hidden */
  55243. export var volumetricLightScatteringPassPixelShader: {
  55244. name: string;
  55245. shader: string;
  55246. };
  55247. }
  55248. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55249. import { Vector3 } from "babylonjs/Maths/math";
  55250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55251. import { Mesh } from "babylonjs/Meshes/mesh";
  55252. import { Camera } from "babylonjs/Cameras/camera";
  55253. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55254. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55255. import { Scene } from "babylonjs/scene";
  55256. import "babylonjs/Meshes/Builders/planeBuilder";
  55257. import "babylonjs/Shaders/depth.vertex";
  55258. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55259. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55260. import { Engine } from "babylonjs/Engines/engine";
  55261. /**
  55262. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55263. */
  55264. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55265. private _volumetricLightScatteringPass;
  55266. private _volumetricLightScatteringRTT;
  55267. private _viewPort;
  55268. private _screenCoordinates;
  55269. private _cachedDefines;
  55270. /**
  55271. * If not undefined, the mesh position is computed from the attached node position
  55272. */
  55273. attachedNode: {
  55274. position: Vector3;
  55275. };
  55276. /**
  55277. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55278. */
  55279. customMeshPosition: Vector3;
  55280. /**
  55281. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55282. */
  55283. useCustomMeshPosition: boolean;
  55284. /**
  55285. * If the post-process should inverse the light scattering direction
  55286. */
  55287. invert: boolean;
  55288. /**
  55289. * The internal mesh used by the post-process
  55290. */
  55291. mesh: Mesh;
  55292. /**
  55293. * @hidden
  55294. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55295. */
  55296. useDiffuseColor: boolean;
  55297. /**
  55298. * Array containing the excluded meshes not rendered in the internal pass
  55299. */
  55300. excludedMeshes: AbstractMesh[];
  55301. /**
  55302. * Controls the overall intensity of the post-process
  55303. */
  55304. exposure: number;
  55305. /**
  55306. * Dissipates each sample's contribution in range [0, 1]
  55307. */
  55308. decay: number;
  55309. /**
  55310. * Controls the overall intensity of each sample
  55311. */
  55312. weight: number;
  55313. /**
  55314. * Controls the density of each sample
  55315. */
  55316. density: number;
  55317. /**
  55318. * @constructor
  55319. * @param name The post-process name
  55320. * @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)
  55321. * @param camera The camera that the post-process will be attached to
  55322. * @param mesh The mesh used to create the light scattering
  55323. * @param samples The post-process quality, default 100
  55324. * @param samplingModeThe post-process filtering mode
  55325. * @param engine The babylon engine
  55326. * @param reusable If the post-process is reusable
  55327. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55328. */
  55329. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55330. /**
  55331. * Returns the string "VolumetricLightScatteringPostProcess"
  55332. * @returns "VolumetricLightScatteringPostProcess"
  55333. */
  55334. getClassName(): string;
  55335. private _isReady;
  55336. /**
  55337. * Sets the new light position for light scattering effect
  55338. * @param position The new custom light position
  55339. */
  55340. setCustomMeshPosition(position: Vector3): void;
  55341. /**
  55342. * Returns the light position for light scattering effect
  55343. * @return Vector3 The custom light position
  55344. */
  55345. getCustomMeshPosition(): Vector3;
  55346. /**
  55347. * Disposes the internal assets and detaches the post-process from the camera
  55348. */
  55349. dispose(camera: Camera): void;
  55350. /**
  55351. * Returns the render target texture used by the post-process
  55352. * @return the render target texture used by the post-process
  55353. */
  55354. getPass(): RenderTargetTexture;
  55355. private _meshExcluded;
  55356. private _createPass;
  55357. private _updateMeshScreenCoordinates;
  55358. /**
  55359. * Creates a default mesh for the Volumeric Light Scattering post-process
  55360. * @param name The mesh name
  55361. * @param scene The scene where to create the mesh
  55362. * @return the default mesh
  55363. */
  55364. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55365. }
  55366. }
  55367. declare module "babylonjs/PostProcesses/index" {
  55368. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55369. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55370. export * from "babylonjs/PostProcesses/bloomEffect";
  55371. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55372. export * from "babylonjs/PostProcesses/blurPostProcess";
  55373. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55374. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55375. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55376. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55377. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55378. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55379. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55380. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55381. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55382. export * from "babylonjs/PostProcesses/filterPostProcess";
  55383. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55384. export * from "babylonjs/PostProcesses/grainPostProcess";
  55385. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55386. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55387. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55388. export * from "babylonjs/PostProcesses/passPostProcess";
  55389. export * from "babylonjs/PostProcesses/postProcess";
  55390. export * from "babylonjs/PostProcesses/postProcessManager";
  55391. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55392. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55393. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55394. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55395. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55396. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55397. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55398. }
  55399. declare module "babylonjs/Probes/index" {
  55400. export * from "babylonjs/Probes/reflectionProbe";
  55401. }
  55402. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55403. import { Scene } from "babylonjs/scene";
  55404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55405. import { Color3 } from "babylonjs/Maths/math";
  55406. import { SmartArray } from "babylonjs/Misc/smartArray";
  55407. import { ISceneComponent } from "babylonjs/sceneComponent";
  55408. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55409. import "babylonjs/Meshes/Builders/boxBuilder";
  55410. import "babylonjs/Shaders/color.fragment";
  55411. import "babylonjs/Shaders/color.vertex";
  55412. module "babylonjs/scene" {
  55413. interface Scene {
  55414. /** @hidden (Backing field) */
  55415. _boundingBoxRenderer: BoundingBoxRenderer;
  55416. /** @hidden (Backing field) */
  55417. _forceShowBoundingBoxes: boolean;
  55418. /**
  55419. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55420. */
  55421. forceShowBoundingBoxes: boolean;
  55422. /**
  55423. * Gets the bounding box renderer associated with the scene
  55424. * @returns a BoundingBoxRenderer
  55425. */
  55426. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55427. }
  55428. }
  55429. module "babylonjs/Meshes/abstractMesh" {
  55430. interface AbstractMesh {
  55431. /** @hidden (Backing field) */
  55432. _showBoundingBox: boolean;
  55433. /**
  55434. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55435. */
  55436. showBoundingBox: boolean;
  55437. }
  55438. }
  55439. /**
  55440. * Component responsible of rendering the bounding box of the meshes in a scene.
  55441. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55442. */
  55443. export class BoundingBoxRenderer implements ISceneComponent {
  55444. /**
  55445. * The component name helpfull to identify the component in the list of scene components.
  55446. */
  55447. readonly name: string;
  55448. /**
  55449. * The scene the component belongs to.
  55450. */
  55451. scene: Scene;
  55452. /**
  55453. * Color of the bounding box lines placed in front of an object
  55454. */
  55455. frontColor: Color3;
  55456. /**
  55457. * Color of the bounding box lines placed behind an object
  55458. */
  55459. backColor: Color3;
  55460. /**
  55461. * Defines if the renderer should show the back lines or not
  55462. */
  55463. showBackLines: boolean;
  55464. /**
  55465. * @hidden
  55466. */
  55467. renderList: SmartArray<BoundingBox>;
  55468. private _colorShader;
  55469. private _vertexBuffers;
  55470. private _indexBuffer;
  55471. /**
  55472. * Instantiates a new bounding box renderer in a scene.
  55473. * @param scene the scene the renderer renders in
  55474. */
  55475. constructor(scene: Scene);
  55476. /**
  55477. * Registers the component in a given scene
  55478. */
  55479. register(): void;
  55480. private _evaluateSubMesh;
  55481. private _activeMesh;
  55482. private _prepareRessources;
  55483. private _createIndexBuffer;
  55484. /**
  55485. * Rebuilds the elements related to this component in case of
  55486. * context lost for instance.
  55487. */
  55488. rebuild(): void;
  55489. /**
  55490. * @hidden
  55491. */
  55492. reset(): void;
  55493. /**
  55494. * Render the bounding boxes of a specific rendering group
  55495. * @param renderingGroupId defines the rendering group to render
  55496. */
  55497. render(renderingGroupId: number): void;
  55498. /**
  55499. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55500. * @param mesh Define the mesh to render the occlusion bounding box for
  55501. */
  55502. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55503. /**
  55504. * Dispose and release the resources attached to this renderer.
  55505. */
  55506. dispose(): void;
  55507. }
  55508. }
  55509. declare module "babylonjs/Shaders/depth.fragment" {
  55510. /** @hidden */
  55511. export var depthPixelShader: {
  55512. name: string;
  55513. shader: string;
  55514. };
  55515. }
  55516. declare module "babylonjs/Rendering/depthRenderer" {
  55517. import { Nullable } from "babylonjs/types";
  55518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55519. import { Scene } from "babylonjs/scene";
  55520. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55521. import { Camera } from "babylonjs/Cameras/camera";
  55522. import "babylonjs/Shaders/depth.fragment";
  55523. import "babylonjs/Shaders/depth.vertex";
  55524. /**
  55525. * This represents a depth renderer in Babylon.
  55526. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55527. */
  55528. export class DepthRenderer {
  55529. private _scene;
  55530. private _depthMap;
  55531. private _effect;
  55532. private _cachedDefines;
  55533. private _camera;
  55534. /**
  55535. * Specifiess that the depth renderer will only be used within
  55536. * the camera it is created for.
  55537. * This can help forcing its rendering during the camera processing.
  55538. */
  55539. useOnlyInActiveCamera: boolean;
  55540. /** @hidden */
  55541. static _SceneComponentInitialization: (scene: Scene) => void;
  55542. /**
  55543. * Instantiates a depth renderer
  55544. * @param scene The scene the renderer belongs to
  55545. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55546. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55547. */
  55548. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55549. /**
  55550. * Creates the depth rendering effect and checks if the effect is ready.
  55551. * @param subMesh The submesh to be used to render the depth map of
  55552. * @param useInstances If multiple world instances should be used
  55553. * @returns if the depth renderer is ready to render the depth map
  55554. */
  55555. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55556. /**
  55557. * Gets the texture which the depth map will be written to.
  55558. * @returns The depth map texture
  55559. */
  55560. getDepthMap(): RenderTargetTexture;
  55561. /**
  55562. * Disposes of the depth renderer.
  55563. */
  55564. dispose(): void;
  55565. }
  55566. }
  55567. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55568. import { Nullable } from "babylonjs/types";
  55569. import { Scene } from "babylonjs/scene";
  55570. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55571. import { Camera } from "babylonjs/Cameras/camera";
  55572. import { ISceneComponent } from "babylonjs/sceneComponent";
  55573. module "babylonjs/scene" {
  55574. interface Scene {
  55575. /** @hidden (Backing field) */
  55576. _depthRenderer: {
  55577. [id: string]: DepthRenderer;
  55578. };
  55579. /**
  55580. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55581. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55582. * @returns the created depth renderer
  55583. */
  55584. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55585. /**
  55586. * Disables a depth renderer for a given camera
  55587. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55588. */
  55589. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55590. }
  55591. }
  55592. /**
  55593. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55594. * in several rendering techniques.
  55595. */
  55596. export class DepthRendererSceneComponent implements ISceneComponent {
  55597. /**
  55598. * The component name helpfull to identify the component in the list of scene components.
  55599. */
  55600. readonly name: string;
  55601. /**
  55602. * The scene the component belongs to.
  55603. */
  55604. scene: Scene;
  55605. /**
  55606. * Creates a new instance of the component for the given scene
  55607. * @param scene Defines the scene to register the component in
  55608. */
  55609. constructor(scene: Scene);
  55610. /**
  55611. * Registers the component in a given scene
  55612. */
  55613. register(): void;
  55614. /**
  55615. * Rebuilds the elements related to this component in case of
  55616. * context lost for instance.
  55617. */
  55618. rebuild(): void;
  55619. /**
  55620. * Disposes the component and the associated ressources
  55621. */
  55622. dispose(): void;
  55623. private _gatherRenderTargets;
  55624. private _gatherActiveCameraRenderTargets;
  55625. }
  55626. }
  55627. declare module "babylonjs/Shaders/outline.fragment" {
  55628. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55629. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55630. /** @hidden */
  55631. export var outlinePixelShader: {
  55632. name: string;
  55633. shader: string;
  55634. };
  55635. }
  55636. declare module "babylonjs/Shaders/outline.vertex" {
  55637. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55638. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55639. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55640. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55641. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55642. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55643. /** @hidden */
  55644. export var outlineVertexShader: {
  55645. name: string;
  55646. shader: string;
  55647. };
  55648. }
  55649. declare module "babylonjs/Rendering/outlineRenderer" {
  55650. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55651. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55652. import { Scene } from "babylonjs/scene";
  55653. import { ISceneComponent } from "babylonjs/sceneComponent";
  55654. import "babylonjs/Shaders/outline.fragment";
  55655. import "babylonjs/Shaders/outline.vertex";
  55656. module "babylonjs/scene" {
  55657. interface Scene {
  55658. /** @hidden */
  55659. _outlineRenderer: OutlineRenderer;
  55660. /**
  55661. * Gets the outline renderer associated with the scene
  55662. * @returns a OutlineRenderer
  55663. */
  55664. getOutlineRenderer(): OutlineRenderer;
  55665. }
  55666. }
  55667. module "babylonjs/Meshes/abstractMesh" {
  55668. interface AbstractMesh {
  55669. /** @hidden (Backing field) */
  55670. _renderOutline: boolean;
  55671. /**
  55672. * Gets or sets a boolean indicating if the outline must be rendered as well
  55673. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55674. */
  55675. renderOutline: boolean;
  55676. /** @hidden (Backing field) */
  55677. _renderOverlay: boolean;
  55678. /**
  55679. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55680. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55681. */
  55682. renderOverlay: boolean;
  55683. }
  55684. }
  55685. /**
  55686. * This class is responsible to draw bothe outline/overlay of meshes.
  55687. * It should not be used directly but through the available method on mesh.
  55688. */
  55689. export class OutlineRenderer implements ISceneComponent {
  55690. /**
  55691. * The name of the component. Each component must have a unique name.
  55692. */
  55693. name: string;
  55694. /**
  55695. * The scene the component belongs to.
  55696. */
  55697. scene: Scene;
  55698. /**
  55699. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55700. */
  55701. zOffset: number;
  55702. private _engine;
  55703. private _effect;
  55704. private _cachedDefines;
  55705. private _savedDepthWrite;
  55706. /**
  55707. * Instantiates a new outline renderer. (There could be only one per scene).
  55708. * @param scene Defines the scene it belongs to
  55709. */
  55710. constructor(scene: Scene);
  55711. /**
  55712. * Register the component to one instance of a scene.
  55713. */
  55714. register(): void;
  55715. /**
  55716. * Rebuilds the elements related to this component in case of
  55717. * context lost for instance.
  55718. */
  55719. rebuild(): void;
  55720. /**
  55721. * Disposes the component and the associated ressources.
  55722. */
  55723. dispose(): void;
  55724. /**
  55725. * Renders the outline in the canvas.
  55726. * @param subMesh Defines the sumesh to render
  55727. * @param batch Defines the batch of meshes in case of instances
  55728. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55729. */
  55730. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55731. /**
  55732. * Returns whether or not the outline renderer is ready for a given submesh.
  55733. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55734. * @param subMesh Defines the submesh to check readyness for
  55735. * @param useInstances Defines wheter wee are trying to render instances or not
  55736. * @returns true if ready otherwise false
  55737. */
  55738. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55739. private _beforeRenderingMesh;
  55740. private _afterRenderingMesh;
  55741. }
  55742. }
  55743. declare module "babylonjs/Rendering/index" {
  55744. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55745. export * from "babylonjs/Rendering/depthRenderer";
  55746. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55747. export * from "babylonjs/Rendering/edgesRenderer";
  55748. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55749. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55750. export * from "babylonjs/Rendering/outlineRenderer";
  55751. export * from "babylonjs/Rendering/renderingGroup";
  55752. export * from "babylonjs/Rendering/renderingManager";
  55753. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55754. }
  55755. declare module "babylonjs/Sprites/index" {
  55756. export * from "babylonjs/Sprites/sprite";
  55757. export * from "babylonjs/Sprites/spriteManager";
  55758. export * from "babylonjs/Sprites/spriteSceneComponent";
  55759. }
  55760. declare module "babylonjs/Misc/assetsManager" {
  55761. import { Scene } from "babylonjs/scene";
  55762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55763. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55764. import { Skeleton } from "babylonjs/Bones/skeleton";
  55765. import { Observable } from "babylonjs/Misc/observable";
  55766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55767. import { Texture } from "babylonjs/Materials/Textures/texture";
  55768. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55769. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55770. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55771. /**
  55772. * Defines the list of states available for a task inside a AssetsManager
  55773. */
  55774. export enum AssetTaskState {
  55775. /**
  55776. * Initialization
  55777. */
  55778. INIT = 0,
  55779. /**
  55780. * Running
  55781. */
  55782. RUNNING = 1,
  55783. /**
  55784. * Done
  55785. */
  55786. DONE = 2,
  55787. /**
  55788. * Error
  55789. */
  55790. ERROR = 3
  55791. }
  55792. /**
  55793. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55794. */
  55795. export abstract class AbstractAssetTask {
  55796. /**
  55797. * Task name
  55798. */ name: string;
  55799. /**
  55800. * Callback called when the task is successful
  55801. */
  55802. onSuccess: (task: any) => void;
  55803. /**
  55804. * Callback called when the task is not successful
  55805. */
  55806. onError: (task: any, message?: string, exception?: any) => void;
  55807. /**
  55808. * Creates a new AssetsManager
  55809. * @param name defines the name of the task
  55810. */
  55811. constructor(
  55812. /**
  55813. * Task name
  55814. */ name: string);
  55815. private _isCompleted;
  55816. private _taskState;
  55817. private _errorObject;
  55818. /**
  55819. * Get if the task is completed
  55820. */
  55821. readonly isCompleted: boolean;
  55822. /**
  55823. * Gets the current state of the task
  55824. */
  55825. readonly taskState: AssetTaskState;
  55826. /**
  55827. * Gets the current error object (if task is in error)
  55828. */
  55829. readonly errorObject: {
  55830. message?: string;
  55831. exception?: any;
  55832. };
  55833. /**
  55834. * Internal only
  55835. * @hidden
  55836. */
  55837. _setErrorObject(message?: string, exception?: any): void;
  55838. /**
  55839. * Execute the current task
  55840. * @param scene defines the scene where you want your assets to be loaded
  55841. * @param onSuccess is a callback called when the task is successfully executed
  55842. * @param onError is a callback called if an error occurs
  55843. */
  55844. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55845. /**
  55846. * Execute the current task
  55847. * @param scene defines the scene where you want your assets to be loaded
  55848. * @param onSuccess is a callback called when the task is successfully executed
  55849. * @param onError is a callback called if an error occurs
  55850. */
  55851. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55852. /**
  55853. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55854. * This can be used with failed tasks that have the reason for failure fixed.
  55855. */
  55856. reset(): void;
  55857. private onErrorCallback;
  55858. private onDoneCallback;
  55859. }
  55860. /**
  55861. * Define the interface used by progress events raised during assets loading
  55862. */
  55863. export interface IAssetsProgressEvent {
  55864. /**
  55865. * Defines the number of remaining tasks to process
  55866. */
  55867. remainingCount: number;
  55868. /**
  55869. * Defines the total number of tasks
  55870. */
  55871. totalCount: number;
  55872. /**
  55873. * Defines the task that was just processed
  55874. */
  55875. task: AbstractAssetTask;
  55876. }
  55877. /**
  55878. * Class used to share progress information about assets loading
  55879. */
  55880. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55881. /**
  55882. * Defines the number of remaining tasks to process
  55883. */
  55884. remainingCount: number;
  55885. /**
  55886. * Defines the total number of tasks
  55887. */
  55888. totalCount: number;
  55889. /**
  55890. * Defines the task that was just processed
  55891. */
  55892. task: AbstractAssetTask;
  55893. /**
  55894. * Creates a AssetsProgressEvent
  55895. * @param remainingCount defines the number of remaining tasks to process
  55896. * @param totalCount defines the total number of tasks
  55897. * @param task defines the task that was just processed
  55898. */
  55899. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55900. }
  55901. /**
  55902. * Define a task used by AssetsManager to load meshes
  55903. */
  55904. export class MeshAssetTask extends AbstractAssetTask {
  55905. /**
  55906. * Defines the name of the task
  55907. */
  55908. name: string;
  55909. /**
  55910. * Defines the list of mesh's names you want to load
  55911. */
  55912. meshesNames: any;
  55913. /**
  55914. * Defines the root url to use as a base to load your meshes and associated resources
  55915. */
  55916. rootUrl: string;
  55917. /**
  55918. * Defines the filename of the scene to load from
  55919. */
  55920. sceneFilename: string;
  55921. /**
  55922. * Gets the list of loaded meshes
  55923. */
  55924. loadedMeshes: Array<AbstractMesh>;
  55925. /**
  55926. * Gets the list of loaded particle systems
  55927. */
  55928. loadedParticleSystems: Array<IParticleSystem>;
  55929. /**
  55930. * Gets the list of loaded skeletons
  55931. */
  55932. loadedSkeletons: Array<Skeleton>;
  55933. /**
  55934. * Gets the list of loaded animation groups
  55935. */
  55936. loadedAnimationGroups: Array<AnimationGroup>;
  55937. /**
  55938. * Callback called when the task is successful
  55939. */
  55940. onSuccess: (task: MeshAssetTask) => void;
  55941. /**
  55942. * Callback called when the task is successful
  55943. */
  55944. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55945. /**
  55946. * Creates a new MeshAssetTask
  55947. * @param name defines the name of the task
  55948. * @param meshesNames defines the list of mesh's names you want to load
  55949. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55950. * @param sceneFilename defines the filename of the scene to load from
  55951. */
  55952. constructor(
  55953. /**
  55954. * Defines the name of the task
  55955. */
  55956. name: string,
  55957. /**
  55958. * Defines the list of mesh's names you want to load
  55959. */
  55960. meshesNames: any,
  55961. /**
  55962. * Defines the root url to use as a base to load your meshes and associated resources
  55963. */
  55964. rootUrl: string,
  55965. /**
  55966. * Defines the filename of the scene to load from
  55967. */
  55968. sceneFilename: string);
  55969. /**
  55970. * Execute the current task
  55971. * @param scene defines the scene where you want your assets to be loaded
  55972. * @param onSuccess is a callback called when the task is successfully executed
  55973. * @param onError is a callback called if an error occurs
  55974. */
  55975. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55976. }
  55977. /**
  55978. * Define a task used by AssetsManager to load text content
  55979. */
  55980. export class TextFileAssetTask extends AbstractAssetTask {
  55981. /**
  55982. * Defines the name of the task
  55983. */
  55984. name: string;
  55985. /**
  55986. * Defines the location of the file to load
  55987. */
  55988. url: string;
  55989. /**
  55990. * Gets the loaded text string
  55991. */
  55992. text: string;
  55993. /**
  55994. * Callback called when the task is successful
  55995. */
  55996. onSuccess: (task: TextFileAssetTask) => void;
  55997. /**
  55998. * Callback called when the task is successful
  55999. */
  56000. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56001. /**
  56002. * Creates a new TextFileAssetTask object
  56003. * @param name defines the name of the task
  56004. * @param url defines the location of the file to load
  56005. */
  56006. constructor(
  56007. /**
  56008. * Defines the name of the task
  56009. */
  56010. name: string,
  56011. /**
  56012. * Defines the location of the file to load
  56013. */
  56014. url: string);
  56015. /**
  56016. * Execute the current task
  56017. * @param scene defines the scene where you want your assets to be loaded
  56018. * @param onSuccess is a callback called when the task is successfully executed
  56019. * @param onError is a callback called if an error occurs
  56020. */
  56021. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56022. }
  56023. /**
  56024. * Define a task used by AssetsManager to load binary data
  56025. */
  56026. export class BinaryFileAssetTask extends AbstractAssetTask {
  56027. /**
  56028. * Defines the name of the task
  56029. */
  56030. name: string;
  56031. /**
  56032. * Defines the location of the file to load
  56033. */
  56034. url: string;
  56035. /**
  56036. * Gets the lodaded data (as an array buffer)
  56037. */
  56038. data: ArrayBuffer;
  56039. /**
  56040. * Callback called when the task is successful
  56041. */
  56042. onSuccess: (task: BinaryFileAssetTask) => void;
  56043. /**
  56044. * Callback called when the task is successful
  56045. */
  56046. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56047. /**
  56048. * Creates a new BinaryFileAssetTask object
  56049. * @param name defines the name of the new task
  56050. * @param url defines the location of the file to load
  56051. */
  56052. constructor(
  56053. /**
  56054. * Defines the name of the task
  56055. */
  56056. name: string,
  56057. /**
  56058. * Defines the location of the file to load
  56059. */
  56060. url: string);
  56061. /**
  56062. * Execute the current task
  56063. * @param scene defines the scene where you want your assets to be loaded
  56064. * @param onSuccess is a callback called when the task is successfully executed
  56065. * @param onError is a callback called if an error occurs
  56066. */
  56067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56068. }
  56069. /**
  56070. * Define a task used by AssetsManager to load images
  56071. */
  56072. export class ImageAssetTask extends AbstractAssetTask {
  56073. /**
  56074. * Defines the name of the task
  56075. */
  56076. name: string;
  56077. /**
  56078. * Defines the location of the image to load
  56079. */
  56080. url: string;
  56081. /**
  56082. * Gets the loaded images
  56083. */
  56084. image: HTMLImageElement;
  56085. /**
  56086. * Callback called when the task is successful
  56087. */
  56088. onSuccess: (task: ImageAssetTask) => void;
  56089. /**
  56090. * Callback called when the task is successful
  56091. */
  56092. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56093. /**
  56094. * Creates a new ImageAssetTask
  56095. * @param name defines the name of the task
  56096. * @param url defines the location of the image to load
  56097. */
  56098. constructor(
  56099. /**
  56100. * Defines the name of the task
  56101. */
  56102. name: string,
  56103. /**
  56104. * Defines the location of the image to load
  56105. */
  56106. url: string);
  56107. /**
  56108. * Execute the current task
  56109. * @param scene defines the scene where you want your assets to be loaded
  56110. * @param onSuccess is a callback called when the task is successfully executed
  56111. * @param onError is a callback called if an error occurs
  56112. */
  56113. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56114. }
  56115. /**
  56116. * Defines the interface used by texture loading tasks
  56117. */
  56118. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56119. /**
  56120. * Gets the loaded texture
  56121. */
  56122. texture: TEX;
  56123. }
  56124. /**
  56125. * Define a task used by AssetsManager to load 2D textures
  56126. */
  56127. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56128. /**
  56129. * Defines the name of the task
  56130. */
  56131. name: string;
  56132. /**
  56133. * Defines the location of the file to load
  56134. */
  56135. url: string;
  56136. /**
  56137. * Defines if mipmap should not be generated (default is false)
  56138. */
  56139. noMipmap?: boolean | undefined;
  56140. /**
  56141. * Defines if texture must be inverted on Y axis (default is false)
  56142. */
  56143. invertY?: boolean | undefined;
  56144. /**
  56145. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56146. */
  56147. samplingMode: number;
  56148. /**
  56149. * Gets the loaded texture
  56150. */
  56151. texture: Texture;
  56152. /**
  56153. * Callback called when the task is successful
  56154. */
  56155. onSuccess: (task: TextureAssetTask) => void;
  56156. /**
  56157. * Callback called when the task is successful
  56158. */
  56159. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56160. /**
  56161. * Creates a new TextureAssetTask object
  56162. * @param name defines the name of the task
  56163. * @param url defines the location of the file to load
  56164. * @param noMipmap defines if mipmap should not be generated (default is false)
  56165. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56166. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56167. */
  56168. constructor(
  56169. /**
  56170. * Defines the name of the task
  56171. */
  56172. name: string,
  56173. /**
  56174. * Defines the location of the file to load
  56175. */
  56176. url: string,
  56177. /**
  56178. * Defines if mipmap should not be generated (default is false)
  56179. */
  56180. noMipmap?: boolean | undefined,
  56181. /**
  56182. * Defines if texture must be inverted on Y axis (default is false)
  56183. */
  56184. invertY?: boolean | undefined,
  56185. /**
  56186. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56187. */
  56188. samplingMode?: number);
  56189. /**
  56190. * Execute the current task
  56191. * @param scene defines the scene where you want your assets to be loaded
  56192. * @param onSuccess is a callback called when the task is successfully executed
  56193. * @param onError is a callback called if an error occurs
  56194. */
  56195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56196. }
  56197. /**
  56198. * Define a task used by AssetsManager to load cube textures
  56199. */
  56200. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56201. /**
  56202. * Defines the name of the task
  56203. */
  56204. name: string;
  56205. /**
  56206. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56207. */
  56208. url: string;
  56209. /**
  56210. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56211. */
  56212. extensions?: string[] | undefined;
  56213. /**
  56214. * Defines if mipmaps should not be generated (default is false)
  56215. */
  56216. noMipmap?: boolean | undefined;
  56217. /**
  56218. * Defines the explicit list of files (undefined by default)
  56219. */
  56220. files?: string[] | undefined;
  56221. /**
  56222. * Gets the loaded texture
  56223. */
  56224. texture: CubeTexture;
  56225. /**
  56226. * Callback called when the task is successful
  56227. */
  56228. onSuccess: (task: CubeTextureAssetTask) => void;
  56229. /**
  56230. * Callback called when the task is successful
  56231. */
  56232. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56233. /**
  56234. * Creates a new CubeTextureAssetTask
  56235. * @param name defines the name of the task
  56236. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56237. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56238. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56239. * @param files defines the explicit list of files (undefined by default)
  56240. */
  56241. constructor(
  56242. /**
  56243. * Defines the name of the task
  56244. */
  56245. name: string,
  56246. /**
  56247. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56248. */
  56249. url: string,
  56250. /**
  56251. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56252. */
  56253. extensions?: string[] | undefined,
  56254. /**
  56255. * Defines if mipmaps should not be generated (default is false)
  56256. */
  56257. noMipmap?: boolean | undefined,
  56258. /**
  56259. * Defines the explicit list of files (undefined by default)
  56260. */
  56261. files?: string[] | undefined);
  56262. /**
  56263. * Execute the current task
  56264. * @param scene defines the scene where you want your assets to be loaded
  56265. * @param onSuccess is a callback called when the task is successfully executed
  56266. * @param onError is a callback called if an error occurs
  56267. */
  56268. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56269. }
  56270. /**
  56271. * Define a task used by AssetsManager to load HDR cube textures
  56272. */
  56273. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56274. /**
  56275. * Defines the name of the task
  56276. */
  56277. name: string;
  56278. /**
  56279. * Defines the location of the file to load
  56280. */
  56281. url: string;
  56282. /**
  56283. * Defines the desired size (the more it increases the longer the generation will be)
  56284. */
  56285. size: number;
  56286. /**
  56287. * Defines if mipmaps should not be generated (default is false)
  56288. */
  56289. noMipmap: boolean;
  56290. /**
  56291. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56292. */
  56293. generateHarmonics: boolean;
  56294. /**
  56295. * 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)
  56296. */
  56297. gammaSpace: boolean;
  56298. /**
  56299. * Internal Use Only
  56300. */
  56301. reserved: boolean;
  56302. /**
  56303. * Gets the loaded texture
  56304. */
  56305. texture: HDRCubeTexture;
  56306. /**
  56307. * Callback called when the task is successful
  56308. */
  56309. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56310. /**
  56311. * Callback called when the task is successful
  56312. */
  56313. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56314. /**
  56315. * Creates a new HDRCubeTextureAssetTask object
  56316. * @param name defines the name of the task
  56317. * @param url defines the location of the file to load
  56318. * @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.
  56319. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56320. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56321. * @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)
  56322. * @param reserved Internal use only
  56323. */
  56324. constructor(
  56325. /**
  56326. * Defines the name of the task
  56327. */
  56328. name: string,
  56329. /**
  56330. * Defines the location of the file to load
  56331. */
  56332. url: string,
  56333. /**
  56334. * Defines the desired size (the more it increases the longer the generation will be)
  56335. */
  56336. size: number,
  56337. /**
  56338. * Defines if mipmaps should not be generated (default is false)
  56339. */
  56340. noMipmap?: boolean,
  56341. /**
  56342. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56343. */
  56344. generateHarmonics?: boolean,
  56345. /**
  56346. * 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)
  56347. */
  56348. gammaSpace?: boolean,
  56349. /**
  56350. * Internal Use Only
  56351. */
  56352. reserved?: boolean);
  56353. /**
  56354. * Execute the current task
  56355. * @param scene defines the scene where you want your assets to be loaded
  56356. * @param onSuccess is a callback called when the task is successfully executed
  56357. * @param onError is a callback called if an error occurs
  56358. */
  56359. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56360. }
  56361. /**
  56362. * This class can be used to easily import assets into a scene
  56363. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56364. */
  56365. export class AssetsManager {
  56366. private _scene;
  56367. private _isLoading;
  56368. protected _tasks: AbstractAssetTask[];
  56369. protected _waitingTasksCount: number;
  56370. protected _totalTasksCount: number;
  56371. /**
  56372. * Callback called when all tasks are processed
  56373. */
  56374. onFinish: (tasks: AbstractAssetTask[]) => void;
  56375. /**
  56376. * Callback called when a task is successful
  56377. */
  56378. onTaskSuccess: (task: AbstractAssetTask) => void;
  56379. /**
  56380. * Callback called when a task had an error
  56381. */
  56382. onTaskError: (task: AbstractAssetTask) => void;
  56383. /**
  56384. * Callback called when a task is done (whatever the result is)
  56385. */
  56386. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56387. /**
  56388. * Observable called when all tasks are processed
  56389. */
  56390. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56391. /**
  56392. * Observable called when a task had an error
  56393. */
  56394. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56395. /**
  56396. * Observable called when all tasks were executed
  56397. */
  56398. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56399. /**
  56400. * Observable called when a task is done (whatever the result is)
  56401. */
  56402. onProgressObservable: Observable<IAssetsProgressEvent>;
  56403. /**
  56404. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56405. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56406. */
  56407. useDefaultLoadingScreen: boolean;
  56408. /**
  56409. * Creates a new AssetsManager
  56410. * @param scene defines the scene to work on
  56411. */
  56412. constructor(scene: Scene);
  56413. /**
  56414. * Add a MeshAssetTask to the list of active tasks
  56415. * @param taskName defines the name of the new task
  56416. * @param meshesNames defines the name of meshes to load
  56417. * @param rootUrl defines the root url to use to locate files
  56418. * @param sceneFilename defines the filename of the scene file
  56419. * @returns a new MeshAssetTask object
  56420. */
  56421. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56422. /**
  56423. * Add a TextFileAssetTask to the list of active tasks
  56424. * @param taskName defines the name of the new task
  56425. * @param url defines the url of the file to load
  56426. * @returns a new TextFileAssetTask object
  56427. */
  56428. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56429. /**
  56430. * Add a BinaryFileAssetTask to the list of active tasks
  56431. * @param taskName defines the name of the new task
  56432. * @param url defines the url of the file to load
  56433. * @returns a new BinaryFileAssetTask object
  56434. */
  56435. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56436. /**
  56437. * Add a ImageAssetTask to the list of active tasks
  56438. * @param taskName defines the name of the new task
  56439. * @param url defines the url of the file to load
  56440. * @returns a new ImageAssetTask object
  56441. */
  56442. addImageTask(taskName: string, url: string): ImageAssetTask;
  56443. /**
  56444. * Add a TextureAssetTask to the list of active tasks
  56445. * @param taskName defines the name of the new task
  56446. * @param url defines the url of the file to load
  56447. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56448. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56449. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56450. * @returns a new TextureAssetTask object
  56451. */
  56452. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56453. /**
  56454. * Add a CubeTextureAssetTask to the list of active tasks
  56455. * @param taskName defines the name of the new task
  56456. * @param url defines the url of the file to load
  56457. * @param extensions defines the extension to use to load the cube map (can be null)
  56458. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56459. * @param files defines the list of files to load (can be null)
  56460. * @returns a new CubeTextureAssetTask object
  56461. */
  56462. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56463. /**
  56464. *
  56465. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56466. * @param taskName defines the name of the new task
  56467. * @param url defines the url of the file to load
  56468. * @param size defines the size you want for the cubemap (can be null)
  56469. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56470. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56471. * @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)
  56472. * @param reserved Internal use only
  56473. * @returns a new HDRCubeTextureAssetTask object
  56474. */
  56475. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56476. /**
  56477. * Remove a task from the assets manager.
  56478. * @param task the task to remove
  56479. */
  56480. removeTask(task: AbstractAssetTask): void;
  56481. private _decreaseWaitingTasksCount;
  56482. private _runTask;
  56483. /**
  56484. * Reset the AssetsManager and remove all tasks
  56485. * @return the current instance of the AssetsManager
  56486. */
  56487. reset(): AssetsManager;
  56488. /**
  56489. * Start the loading process
  56490. * @return the current instance of the AssetsManager
  56491. */
  56492. load(): AssetsManager;
  56493. /**
  56494. * Start the loading process as an async operation
  56495. * @return a promise returning the list of failed tasks
  56496. */
  56497. loadAsync(): Promise<void>;
  56498. }
  56499. }
  56500. declare module "babylonjs/Misc/deferred" {
  56501. /**
  56502. * Wrapper class for promise with external resolve and reject.
  56503. */
  56504. export class Deferred<T> {
  56505. /**
  56506. * The promise associated with this deferred object.
  56507. */
  56508. readonly promise: Promise<T>;
  56509. private _resolve;
  56510. private _reject;
  56511. /**
  56512. * The resolve method of the promise associated with this deferred object.
  56513. */
  56514. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56515. /**
  56516. * The reject method of the promise associated with this deferred object.
  56517. */
  56518. readonly reject: (reason?: any) => void;
  56519. /**
  56520. * Constructor for this deferred object.
  56521. */
  56522. constructor();
  56523. }
  56524. }
  56525. declare module "babylonjs/Misc/meshExploder" {
  56526. import { Mesh } from "babylonjs/Meshes/mesh";
  56527. /**
  56528. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  56529. */
  56530. export class MeshExploder {
  56531. private _centerMesh;
  56532. private _meshes;
  56533. private _meshesOrigins;
  56534. private _toCenterVectors;
  56535. private _scaledDirection;
  56536. private _newPosition;
  56537. private _centerPosition;
  56538. /**
  56539. * Explodes meshes from a center mesh.
  56540. * @param meshes The meshes to explode.
  56541. * @param centerMesh The mesh to be center of explosion.
  56542. */
  56543. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  56544. private _setCenterMesh;
  56545. /**
  56546. * Get class name
  56547. * @returns "MeshExploder"
  56548. */
  56549. getClassName(): string;
  56550. /**
  56551. * "Exploded meshes"
  56552. * @returns Array of meshes with the centerMesh at index 0.
  56553. */
  56554. getMeshes(): Array<Mesh>;
  56555. /**
  56556. * Explodes meshes giving a specific direction
  56557. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  56558. */
  56559. explode(direction?: number): void;
  56560. }
  56561. }
  56562. declare module "babylonjs/Misc/filesInput" {
  56563. import { Engine } from "babylonjs/Engines/engine";
  56564. import { Scene } from "babylonjs/scene";
  56565. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56566. /**
  56567. * Class used to help managing file picking and drag'n'drop
  56568. */
  56569. export class FilesInput {
  56570. /**
  56571. * List of files ready to be loaded
  56572. */
  56573. static readonly FilesToLoad: {
  56574. [key: string]: File;
  56575. };
  56576. /**
  56577. * Callback called when a file is processed
  56578. */
  56579. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56580. private _engine;
  56581. private _currentScene;
  56582. private _sceneLoadedCallback;
  56583. private _progressCallback;
  56584. private _additionalRenderLoopLogicCallback;
  56585. private _textureLoadingCallback;
  56586. private _startingProcessingFilesCallback;
  56587. private _onReloadCallback;
  56588. private _errorCallback;
  56589. private _elementToMonitor;
  56590. private _sceneFileToLoad;
  56591. private _filesToLoad;
  56592. /**
  56593. * Creates a new FilesInput
  56594. * @param engine defines the rendering engine
  56595. * @param scene defines the hosting scene
  56596. * @param sceneLoadedCallback callback called when scene is loaded
  56597. * @param progressCallback callback called to track progress
  56598. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56599. * @param textureLoadingCallback callback called when a texture is loading
  56600. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56601. * @param onReloadCallback callback called when a reload is requested
  56602. * @param errorCallback callback call if an error occurs
  56603. */
  56604. 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);
  56605. private _dragEnterHandler;
  56606. private _dragOverHandler;
  56607. private _dropHandler;
  56608. /**
  56609. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56610. * @param elementToMonitor defines the DOM element to track
  56611. */
  56612. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56613. /**
  56614. * Release all associated resources
  56615. */
  56616. dispose(): void;
  56617. private renderFunction;
  56618. private drag;
  56619. private drop;
  56620. private _traverseFolder;
  56621. private _processFiles;
  56622. /**
  56623. * Load files from a drop event
  56624. * @param event defines the drop event to use as source
  56625. */
  56626. loadFiles(event: any): void;
  56627. private _processReload;
  56628. /**
  56629. * Reload the current scene from the loaded files
  56630. */
  56631. reload(): void;
  56632. }
  56633. }
  56634. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56635. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56636. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56637. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56638. }
  56639. declare module "babylonjs/Misc/sceneOptimizer" {
  56640. import { Scene, IDisposable } from "babylonjs/scene";
  56641. import { Observable } from "babylonjs/Misc/observable";
  56642. /**
  56643. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56644. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56645. */
  56646. export class SceneOptimization {
  56647. /**
  56648. * Defines the priority of this optimization (0 by default which means first in the list)
  56649. */
  56650. priority: number;
  56651. /**
  56652. * Gets a string describing the action executed by the current optimization
  56653. * @returns description string
  56654. */
  56655. getDescription(): string;
  56656. /**
  56657. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56658. * @param scene defines the current scene where to apply this optimization
  56659. * @param optimizer defines the current optimizer
  56660. * @returns true if everything that can be done was applied
  56661. */
  56662. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56663. /**
  56664. * Creates the SceneOptimization object
  56665. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56666. * @param desc defines the description associated with the optimization
  56667. */
  56668. constructor(
  56669. /**
  56670. * Defines the priority of this optimization (0 by default which means first in the list)
  56671. */
  56672. priority?: number);
  56673. }
  56674. /**
  56675. * Defines an optimization used to reduce the size of render target textures
  56676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56677. */
  56678. export class TextureOptimization extends SceneOptimization {
  56679. /**
  56680. * Defines the priority of this optimization (0 by default which means first in the list)
  56681. */
  56682. priority: number;
  56683. /**
  56684. * 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
  56685. */
  56686. maximumSize: number;
  56687. /**
  56688. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56689. */
  56690. step: number;
  56691. /**
  56692. * Gets a string describing the action executed by the current optimization
  56693. * @returns description string
  56694. */
  56695. getDescription(): string;
  56696. /**
  56697. * Creates the TextureOptimization object
  56698. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56699. * @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
  56700. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56701. */
  56702. constructor(
  56703. /**
  56704. * Defines the priority of this optimization (0 by default which means first in the list)
  56705. */
  56706. priority?: number,
  56707. /**
  56708. * 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
  56709. */
  56710. maximumSize?: number,
  56711. /**
  56712. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56713. */
  56714. step?: number);
  56715. /**
  56716. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56717. * @param scene defines the current scene where to apply this optimization
  56718. * @param optimizer defines the current optimizer
  56719. * @returns true if everything that can be done was applied
  56720. */
  56721. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56722. }
  56723. /**
  56724. * Defines an optimization used to increase or decrease the rendering resolution
  56725. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56726. */
  56727. export class HardwareScalingOptimization extends SceneOptimization {
  56728. /**
  56729. * Defines the priority of this optimization (0 by default which means first in the list)
  56730. */
  56731. priority: number;
  56732. /**
  56733. * Defines the maximum scale to use (2 by default)
  56734. */
  56735. maximumScale: number;
  56736. /**
  56737. * Defines the step to use between two passes (0.5 by default)
  56738. */
  56739. step: number;
  56740. private _currentScale;
  56741. private _directionOffset;
  56742. /**
  56743. * Gets a string describing the action executed by the current optimization
  56744. * @return description string
  56745. */
  56746. getDescription(): string;
  56747. /**
  56748. * Creates the HardwareScalingOptimization object
  56749. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56750. * @param maximumScale defines the maximum scale to use (2 by default)
  56751. * @param step defines the step to use between two passes (0.5 by default)
  56752. */
  56753. constructor(
  56754. /**
  56755. * Defines the priority of this optimization (0 by default which means first in the list)
  56756. */
  56757. priority?: number,
  56758. /**
  56759. * Defines the maximum scale to use (2 by default)
  56760. */
  56761. maximumScale?: number,
  56762. /**
  56763. * Defines the step to use between two passes (0.5 by default)
  56764. */
  56765. step?: number);
  56766. /**
  56767. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56768. * @param scene defines the current scene where to apply this optimization
  56769. * @param optimizer defines the current optimizer
  56770. * @returns true if everything that can be done was applied
  56771. */
  56772. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56773. }
  56774. /**
  56775. * Defines an optimization used to remove shadows
  56776. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56777. */
  56778. export class ShadowsOptimization extends SceneOptimization {
  56779. /**
  56780. * Gets a string describing the action executed by the current optimization
  56781. * @return description string
  56782. */
  56783. getDescription(): string;
  56784. /**
  56785. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56786. * @param scene defines the current scene where to apply this optimization
  56787. * @param optimizer defines the current optimizer
  56788. * @returns true if everything that can be done was applied
  56789. */
  56790. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56791. }
  56792. /**
  56793. * Defines an optimization used to turn post-processes off
  56794. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56795. */
  56796. export class PostProcessesOptimization extends SceneOptimization {
  56797. /**
  56798. * Gets a string describing the action executed by the current optimization
  56799. * @return description string
  56800. */
  56801. getDescription(): string;
  56802. /**
  56803. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56804. * @param scene defines the current scene where to apply this optimization
  56805. * @param optimizer defines the current optimizer
  56806. * @returns true if everything that can be done was applied
  56807. */
  56808. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56809. }
  56810. /**
  56811. * Defines an optimization used to turn lens flares off
  56812. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56813. */
  56814. export class LensFlaresOptimization extends SceneOptimization {
  56815. /**
  56816. * Gets a string describing the action executed by the current optimization
  56817. * @return description string
  56818. */
  56819. getDescription(): string;
  56820. /**
  56821. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56822. * @param scene defines the current scene where to apply this optimization
  56823. * @param optimizer defines the current optimizer
  56824. * @returns true if everything that can be done was applied
  56825. */
  56826. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56827. }
  56828. /**
  56829. * Defines an optimization based on user defined callback.
  56830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56831. */
  56832. export class CustomOptimization extends SceneOptimization {
  56833. /**
  56834. * Callback called to apply the custom optimization.
  56835. */
  56836. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56837. /**
  56838. * Callback called to get custom description
  56839. */
  56840. onGetDescription: () => string;
  56841. /**
  56842. * Gets a string describing the action executed by the current optimization
  56843. * @returns description string
  56844. */
  56845. getDescription(): string;
  56846. /**
  56847. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56848. * @param scene defines the current scene where to apply this optimization
  56849. * @param optimizer defines the current optimizer
  56850. * @returns true if everything that can be done was applied
  56851. */
  56852. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56853. }
  56854. /**
  56855. * Defines an optimization used to turn particles off
  56856. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56857. */
  56858. export class ParticlesOptimization extends SceneOptimization {
  56859. /**
  56860. * Gets a string describing the action executed by the current optimization
  56861. * @return description string
  56862. */
  56863. getDescription(): string;
  56864. /**
  56865. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56866. * @param scene defines the current scene where to apply this optimization
  56867. * @param optimizer defines the current optimizer
  56868. * @returns true if everything that can be done was applied
  56869. */
  56870. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56871. }
  56872. /**
  56873. * Defines an optimization used to turn render targets off
  56874. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56875. */
  56876. export class RenderTargetsOptimization extends SceneOptimization {
  56877. /**
  56878. * Gets a string describing the action executed by the current optimization
  56879. * @return description string
  56880. */
  56881. getDescription(): string;
  56882. /**
  56883. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56884. * @param scene defines the current scene where to apply this optimization
  56885. * @param optimizer defines the current optimizer
  56886. * @returns true if everything that can be done was applied
  56887. */
  56888. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56889. }
  56890. /**
  56891. * Defines an optimization used to merge meshes with compatible materials
  56892. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56893. */
  56894. export class MergeMeshesOptimization extends SceneOptimization {
  56895. private static _UpdateSelectionTree;
  56896. /**
  56897. * Gets or sets a boolean which defines if optimization octree has to be updated
  56898. */
  56899. /**
  56900. * Gets or sets a boolean which defines if optimization octree has to be updated
  56901. */
  56902. static UpdateSelectionTree: boolean;
  56903. /**
  56904. * Gets a string describing the action executed by the current optimization
  56905. * @return description string
  56906. */
  56907. getDescription(): string;
  56908. private _canBeMerged;
  56909. /**
  56910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56911. * @param scene defines the current scene where to apply this optimization
  56912. * @param optimizer defines the current optimizer
  56913. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56914. * @returns true if everything that can be done was applied
  56915. */
  56916. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56917. }
  56918. /**
  56919. * Defines a list of options used by SceneOptimizer
  56920. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56921. */
  56922. export class SceneOptimizerOptions {
  56923. /**
  56924. * Defines the target frame rate to reach (60 by default)
  56925. */
  56926. targetFrameRate: number;
  56927. /**
  56928. * Defines the interval between two checkes (2000ms by default)
  56929. */
  56930. trackerDuration: number;
  56931. /**
  56932. * Gets the list of optimizations to apply
  56933. */
  56934. optimizations: SceneOptimization[];
  56935. /**
  56936. * Creates a new list of options used by SceneOptimizer
  56937. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56938. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56939. */
  56940. constructor(
  56941. /**
  56942. * Defines the target frame rate to reach (60 by default)
  56943. */
  56944. targetFrameRate?: number,
  56945. /**
  56946. * Defines the interval between two checkes (2000ms by default)
  56947. */
  56948. trackerDuration?: number);
  56949. /**
  56950. * Add a new optimization
  56951. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56952. * @returns the current SceneOptimizerOptions
  56953. */
  56954. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56955. /**
  56956. * Add a new custom optimization
  56957. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56958. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56959. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56960. * @returns the current SceneOptimizerOptions
  56961. */
  56962. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56963. /**
  56964. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56965. * @param targetFrameRate defines the target frame rate (60 by default)
  56966. * @returns a SceneOptimizerOptions object
  56967. */
  56968. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56969. /**
  56970. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56971. * @param targetFrameRate defines the target frame rate (60 by default)
  56972. * @returns a SceneOptimizerOptions object
  56973. */
  56974. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56975. /**
  56976. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56977. * @param targetFrameRate defines the target frame rate (60 by default)
  56978. * @returns a SceneOptimizerOptions object
  56979. */
  56980. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56981. }
  56982. /**
  56983. * Class used to run optimizations in order to reach a target frame rate
  56984. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56985. */
  56986. export class SceneOptimizer implements IDisposable {
  56987. private _isRunning;
  56988. private _options;
  56989. private _scene;
  56990. private _currentPriorityLevel;
  56991. private _targetFrameRate;
  56992. private _trackerDuration;
  56993. private _currentFrameRate;
  56994. private _sceneDisposeObserver;
  56995. private _improvementMode;
  56996. /**
  56997. * Defines an observable called when the optimizer reaches the target frame rate
  56998. */
  56999. onSuccessObservable: Observable<SceneOptimizer>;
  57000. /**
  57001. * Defines an observable called when the optimizer enables an optimization
  57002. */
  57003. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57004. /**
  57005. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57006. */
  57007. onFailureObservable: Observable<SceneOptimizer>;
  57008. /**
  57009. * Gets a boolean indicating if the optimizer is in improvement mode
  57010. */
  57011. readonly isInImprovementMode: boolean;
  57012. /**
  57013. * Gets the current priority level (0 at start)
  57014. */
  57015. readonly currentPriorityLevel: number;
  57016. /**
  57017. * Gets the current frame rate checked by the SceneOptimizer
  57018. */
  57019. readonly currentFrameRate: number;
  57020. /**
  57021. * Gets or sets the current target frame rate (60 by default)
  57022. */
  57023. /**
  57024. * Gets or sets the current target frame rate (60 by default)
  57025. */
  57026. targetFrameRate: number;
  57027. /**
  57028. * Gets or sets the current interval between two checks (every 2000ms by default)
  57029. */
  57030. /**
  57031. * Gets or sets the current interval between two checks (every 2000ms by default)
  57032. */
  57033. trackerDuration: number;
  57034. /**
  57035. * Gets the list of active optimizations
  57036. */
  57037. readonly optimizations: SceneOptimization[];
  57038. /**
  57039. * Creates a new SceneOptimizer
  57040. * @param scene defines the scene to work on
  57041. * @param options defines the options to use with the SceneOptimizer
  57042. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57043. * @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)
  57044. */
  57045. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57046. /**
  57047. * Stops the current optimizer
  57048. */
  57049. stop(): void;
  57050. /**
  57051. * Reset the optimizer to initial step (current priority level = 0)
  57052. */
  57053. reset(): void;
  57054. /**
  57055. * Start the optimizer. By default it will try to reach a specific framerate
  57056. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57057. */
  57058. start(): void;
  57059. private _checkCurrentState;
  57060. /**
  57061. * Release all resources
  57062. */
  57063. dispose(): void;
  57064. /**
  57065. * Helper function to create a SceneOptimizer with one single line of code
  57066. * @param scene defines the scene to work on
  57067. * @param options defines the options to use with the SceneOptimizer
  57068. * @param onSuccess defines a callback to call on success
  57069. * @param onFailure defines a callback to call on failure
  57070. * @returns the new SceneOptimizer object
  57071. */
  57072. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57073. }
  57074. }
  57075. declare module "babylonjs/Misc/sceneSerializer" {
  57076. import { Scene } from "babylonjs/scene";
  57077. /**
  57078. * Class used to serialize a scene into a string
  57079. */
  57080. export class SceneSerializer {
  57081. /**
  57082. * Clear cache used by a previous serialization
  57083. */
  57084. static ClearCache(): void;
  57085. /**
  57086. * Serialize a scene into a JSON compatible object
  57087. * @param scene defines the scene to serialize
  57088. * @returns a JSON compatible object
  57089. */
  57090. static Serialize(scene: Scene): any;
  57091. /**
  57092. * Serialize a mesh into a JSON compatible object
  57093. * @param toSerialize defines the mesh to serialize
  57094. * @param withParents defines if parents must be serialized as well
  57095. * @param withChildren defines if children must be serialized as well
  57096. * @returns a JSON compatible object
  57097. */
  57098. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57099. }
  57100. }
  57101. declare module "babylonjs/Misc/videoRecorder" {
  57102. import { Nullable } from "babylonjs/types";
  57103. import { Engine } from "babylonjs/Engines/engine";
  57104. /**
  57105. * This represents the different options avilable for the video capture.
  57106. */
  57107. export interface VideoRecorderOptions {
  57108. /** Defines the mime type of the video */
  57109. mimeType: string;
  57110. /** Defines the video the video should be recorded at */
  57111. fps: number;
  57112. /** Defines the chunk size for the recording data */
  57113. recordChunckSize: number;
  57114. /** The audio tracks to attach to the record */
  57115. audioTracks?: MediaStreamTrack[];
  57116. }
  57117. /**
  57118. * This can helps recording videos from BabylonJS.
  57119. * This is based on the available WebRTC functionalities of the browser.
  57120. *
  57121. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57122. */
  57123. export class VideoRecorder {
  57124. private static readonly _defaultOptions;
  57125. /**
  57126. * Returns wehther or not the VideoRecorder is available in your browser.
  57127. * @param engine Defines the Babylon Engine to check the support for
  57128. * @returns true if supported otherwise false
  57129. */
  57130. static IsSupported(engine: Engine): boolean;
  57131. private readonly _options;
  57132. private _canvas;
  57133. private _mediaRecorder;
  57134. private _recordedChunks;
  57135. private _fileName;
  57136. private _resolve;
  57137. private _reject;
  57138. /**
  57139. * True wether a recording is already in progress.
  57140. */
  57141. readonly isRecording: boolean;
  57142. /**
  57143. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57144. * a video file.
  57145. * @param engine Defines the BabylonJS Engine you wish to record
  57146. * @param options Defines options that can be used to customized the capture
  57147. */
  57148. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57149. /**
  57150. * Stops the current recording before the default capture timeout passed in the startRecording
  57151. * functions.
  57152. */
  57153. stopRecording(): void;
  57154. /**
  57155. * Starts recording the canvas for a max duration specified in parameters.
  57156. * @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.
  57157. * @param maxDuration Defines the maximum recording time in seconds.
  57158. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57159. * @return a promise callback at the end of the recording with the video data in Blob.
  57160. */
  57161. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57162. /**
  57163. * Releases internal resources used during the recording.
  57164. */
  57165. dispose(): void;
  57166. private _handleDataAvailable;
  57167. private _handleError;
  57168. private _handleStop;
  57169. }
  57170. }
  57171. declare module "babylonjs/Misc/workerPool" {
  57172. import { IDisposable } from "babylonjs/scene";
  57173. /**
  57174. * Helper class to push actions to a pool of workers.
  57175. */
  57176. export class WorkerPool implements IDisposable {
  57177. private _workerInfos;
  57178. private _pendingActions;
  57179. /**
  57180. * Constructor
  57181. * @param workers Array of workers to use for actions
  57182. */
  57183. constructor(workers: Array<Worker>);
  57184. /**
  57185. * Terminates all workers and clears any pending actions.
  57186. */
  57187. dispose(): void;
  57188. /**
  57189. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57190. * pended until a worker has completed its action.
  57191. * @param action The action to perform. Call onComplete when the action is complete.
  57192. */
  57193. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57194. private _execute;
  57195. }
  57196. }
  57197. declare module "babylonjs/Misc/screenshotTools" {
  57198. import { Camera } from "babylonjs/Cameras/camera";
  57199. import { Engine } from "babylonjs/Engines/engine";
  57200. /**
  57201. * Class containing a set of static utilities functions for screenshots
  57202. */
  57203. export class ScreenshotTools {
  57204. /**
  57205. * Captures a screenshot of the current rendering
  57206. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57207. * @param engine defines the rendering engine
  57208. * @param camera defines the source camera
  57209. * @param size This parameter can be set to a single number or to an object with the
  57210. * following (optional) properties: precision, width, height. If a single number is passed,
  57211. * it will be used for both width and height. If an object is passed, the screenshot size
  57212. * will be derived from the parameters. The precision property is a multiplier allowing
  57213. * rendering at a higher or lower resolution
  57214. * @param successCallback defines the callback receives a single parameter which contains the
  57215. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57216. * src parameter of an <img> to display it
  57217. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57218. * Check your browser for supported MIME types
  57219. */
  57220. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57221. /**
  57222. * Generates an image screenshot from the specified camera.
  57223. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57224. * @param engine The engine to use for rendering
  57225. * @param camera The camera to use for rendering
  57226. * @param size This parameter can be set to a single number or to an object with the
  57227. * following (optional) properties: precision, width, height. If a single number is passed,
  57228. * it will be used for both width and height. If an object is passed, the screenshot size
  57229. * will be derived from the parameters. The precision property is a multiplier allowing
  57230. * rendering at a higher or lower resolution
  57231. * @param successCallback The callback receives a single parameter which contains the
  57232. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57233. * src parameter of an <img> to display it
  57234. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57235. * Check your browser for supported MIME types
  57236. * @param samples Texture samples (default: 1)
  57237. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57238. * @param fileName A name for for the downloaded file.
  57239. */
  57240. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57241. }
  57242. }
  57243. declare module "babylonjs/Misc/index" {
  57244. export * from "babylonjs/Misc/andOrNotEvaluator";
  57245. export * from "babylonjs/Misc/assetsManager";
  57246. export * from "babylonjs/Misc/dds";
  57247. export * from "babylonjs/Misc/decorators";
  57248. export * from "babylonjs/Misc/deferred";
  57249. export * from "babylonjs/Misc/environmentTextureTools";
  57250. export * from "babylonjs/Misc/meshExploder";
  57251. export * from "babylonjs/Misc/filesInput";
  57252. export * from "babylonjs/Misc/HighDynamicRange/index";
  57253. export * from "babylonjs/Misc/khronosTextureContainer";
  57254. export * from "babylonjs/Misc/observable";
  57255. export * from "babylonjs/Misc/performanceMonitor";
  57256. export * from "babylonjs/Misc/promise";
  57257. export * from "babylonjs/Misc/sceneOptimizer";
  57258. export * from "babylonjs/Misc/sceneSerializer";
  57259. export * from "babylonjs/Misc/smartArray";
  57260. export * from "babylonjs/Misc/stringDictionary";
  57261. export * from "babylonjs/Misc/tags";
  57262. export * from "babylonjs/Misc/textureTools";
  57263. export * from "babylonjs/Misc/tga";
  57264. export * from "babylonjs/Misc/tools";
  57265. export * from "babylonjs/Misc/videoRecorder";
  57266. export * from "babylonjs/Misc/virtualJoystick";
  57267. export * from "babylonjs/Misc/workerPool";
  57268. export * from "babylonjs/Misc/logger";
  57269. export * from "babylonjs/Misc/typeStore";
  57270. export * from "babylonjs/Misc/filesInputStore";
  57271. export * from "babylonjs/Misc/deepCopier";
  57272. export * from "babylonjs/Misc/pivotTools";
  57273. export * from "babylonjs/Misc/precisionDate";
  57274. export * from "babylonjs/Misc/screenshotTools";
  57275. export * from "babylonjs/Misc/typeStore";
  57276. export * from "babylonjs/Misc/webRequest";
  57277. }
  57278. declare module "babylonjs/index" {
  57279. export * from "babylonjs/abstractScene";
  57280. export * from "babylonjs/Actions/index";
  57281. export * from "babylonjs/Animations/index";
  57282. export * from "babylonjs/assetContainer";
  57283. export * from "babylonjs/Audio/index";
  57284. export * from "babylonjs/Behaviors/index";
  57285. export * from "babylonjs/Bones/index";
  57286. export * from "babylonjs/Cameras/index";
  57287. export * from "babylonjs/Collisions/index";
  57288. export * from "babylonjs/Culling/index";
  57289. export * from "babylonjs/Debug/index";
  57290. export * from "babylonjs/Engines/index";
  57291. export * from "babylonjs/Events/index";
  57292. export * from "babylonjs/Gamepads/index";
  57293. export * from "babylonjs/Gizmos/index";
  57294. export * from "babylonjs/Helpers/index";
  57295. export * from "babylonjs/Instrumentation/index";
  57296. export * from "babylonjs/Layers/index";
  57297. export * from "babylonjs/LensFlares/index";
  57298. export * from "babylonjs/Lights/index";
  57299. export * from "babylonjs/Loading/index";
  57300. export * from "babylonjs/Materials/index";
  57301. export * from "babylonjs/Maths/index";
  57302. export * from "babylonjs/Meshes/index";
  57303. export * from "babylonjs/Morph/index";
  57304. export * from "babylonjs/node";
  57305. export * from "babylonjs/Offline/index";
  57306. export * from "babylonjs/Particles/index";
  57307. export * from "babylonjs/Physics/index";
  57308. export * from "babylonjs/PostProcesses/index";
  57309. export * from "babylonjs/Probes/index";
  57310. export * from "babylonjs/Rendering/index";
  57311. export * from "babylonjs/scene";
  57312. export * from "babylonjs/sceneComponent";
  57313. export * from "babylonjs/Sprites/index";
  57314. export * from "babylonjs/States/index";
  57315. export * from "babylonjs/Misc/index";
  57316. export * from "babylonjs/types";
  57317. }
  57318. declare module "babylonjs/Animations/pathCursor" {
  57319. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57320. /**
  57321. * A cursor which tracks a point on a path
  57322. */
  57323. export class PathCursor {
  57324. private path;
  57325. /**
  57326. * Stores path cursor callbacks for when an onchange event is triggered
  57327. */
  57328. private _onchange;
  57329. /**
  57330. * The value of the path cursor
  57331. */
  57332. value: number;
  57333. /**
  57334. * The animation array of the path cursor
  57335. */
  57336. animations: Animation[];
  57337. /**
  57338. * Initializes the path cursor
  57339. * @param path The path to track
  57340. */
  57341. constructor(path: Path2);
  57342. /**
  57343. * Gets the cursor point on the path
  57344. * @returns A point on the path cursor at the cursor location
  57345. */
  57346. getPoint(): Vector3;
  57347. /**
  57348. * Moves the cursor ahead by the step amount
  57349. * @param step The amount to move the cursor forward
  57350. * @returns This path cursor
  57351. */
  57352. moveAhead(step?: number): PathCursor;
  57353. /**
  57354. * Moves the cursor behind by the step amount
  57355. * @param step The amount to move the cursor back
  57356. * @returns This path cursor
  57357. */
  57358. moveBack(step?: number): PathCursor;
  57359. /**
  57360. * Moves the cursor by the step amount
  57361. * If the step amount is greater than one, an exception is thrown
  57362. * @param step The amount to move the cursor
  57363. * @returns This path cursor
  57364. */
  57365. move(step: number): PathCursor;
  57366. /**
  57367. * Ensures that the value is limited between zero and one
  57368. * @returns This path cursor
  57369. */
  57370. private ensureLimits;
  57371. /**
  57372. * Runs onchange callbacks on change (used by the animation engine)
  57373. * @returns This path cursor
  57374. */
  57375. private raiseOnChange;
  57376. /**
  57377. * Executes a function on change
  57378. * @param f A path cursor onchange callback
  57379. * @returns This path cursor
  57380. */
  57381. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57382. }
  57383. }
  57384. declare module "babylonjs/Legacy/legacy" {
  57385. import * as Babylon from "babylonjs/index";
  57386. export * from "babylonjs/index";
  57387. }
  57388. declare module "babylonjs/Shaders/blur.fragment" {
  57389. /** @hidden */
  57390. export var blurPixelShader: {
  57391. name: string;
  57392. shader: string;
  57393. };
  57394. }
  57395. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57396. /** @hidden */
  57397. export var bones300Declaration: {
  57398. name: string;
  57399. shader: string;
  57400. };
  57401. }
  57402. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57403. /** @hidden */
  57404. export var instances300Declaration: {
  57405. name: string;
  57406. shader: string;
  57407. };
  57408. }
  57409. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57410. /** @hidden */
  57411. export var pointCloudVertexDeclaration: {
  57412. name: string;
  57413. shader: string;
  57414. };
  57415. }
  57416. // Mixins
  57417. interface Window {
  57418. mozIndexedDB: IDBFactory;
  57419. webkitIndexedDB: IDBFactory;
  57420. msIndexedDB: IDBFactory;
  57421. webkitURL: typeof URL;
  57422. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57423. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57424. WebGLRenderingContext: WebGLRenderingContext;
  57425. MSGesture: MSGesture;
  57426. CANNON: any;
  57427. AudioContext: AudioContext;
  57428. webkitAudioContext: AudioContext;
  57429. PointerEvent: any;
  57430. Math: Math;
  57431. Uint8Array: Uint8ArrayConstructor;
  57432. Float32Array: Float32ArrayConstructor;
  57433. mozURL: typeof URL;
  57434. msURL: typeof URL;
  57435. VRFrameData: any; // WebVR, from specs 1.1
  57436. DracoDecoderModule: any;
  57437. setImmediate(handler: (...args: any[]) => void): number;
  57438. }
  57439. interface HTMLCanvasElement {
  57440. requestPointerLock(): void;
  57441. msRequestPointerLock?(): void;
  57442. mozRequestPointerLock?(): void;
  57443. webkitRequestPointerLock?(): void;
  57444. /** Track wether a record is in progress */
  57445. isRecording: boolean;
  57446. /** Capture Stream method defined by some browsers */
  57447. captureStream(fps?: number): MediaStream;
  57448. }
  57449. interface CanvasRenderingContext2D {
  57450. msImageSmoothingEnabled: boolean;
  57451. }
  57452. interface MouseEvent {
  57453. mozMovementX: number;
  57454. mozMovementY: number;
  57455. webkitMovementX: number;
  57456. webkitMovementY: number;
  57457. msMovementX: number;
  57458. msMovementY: number;
  57459. }
  57460. interface Navigator {
  57461. mozGetVRDevices: (any: any) => any;
  57462. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57463. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57464. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57465. webkitGetGamepads(): Gamepad[];
  57466. msGetGamepads(): Gamepad[];
  57467. webkitGamepads(): Gamepad[];
  57468. }
  57469. interface HTMLVideoElement {
  57470. mozSrcObject: any;
  57471. }
  57472. interface Math {
  57473. fround(x: number): number;
  57474. imul(a: number, b: number): number;
  57475. }
  57476. interface WebGLProgram {
  57477. context?: WebGLRenderingContext;
  57478. vertexShader?: WebGLShader;
  57479. fragmentShader?: WebGLShader;
  57480. isParallelCompiled: boolean;
  57481. onCompiled?: () => void;
  57482. }
  57483. interface WebGLRenderingContext {
  57484. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57485. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57486. vertexAttribDivisor(index: number, divisor: number): void;
  57487. createVertexArray(): any;
  57488. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57489. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57490. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57491. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57492. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57493. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57494. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57495. // Queries
  57496. createQuery(): WebGLQuery;
  57497. deleteQuery(query: WebGLQuery): void;
  57498. beginQuery(target: number, query: WebGLQuery): void;
  57499. endQuery(target: number): void;
  57500. getQueryParameter(query: WebGLQuery, pname: number): any;
  57501. getQuery(target: number, pname: number): any;
  57502. MAX_SAMPLES: number;
  57503. RGBA8: number;
  57504. READ_FRAMEBUFFER: number;
  57505. DRAW_FRAMEBUFFER: number;
  57506. UNIFORM_BUFFER: number;
  57507. HALF_FLOAT_OES: number;
  57508. RGBA16F: number;
  57509. RGBA32F: number;
  57510. R32F: number;
  57511. RG32F: number;
  57512. RGB32F: number;
  57513. R16F: number;
  57514. RG16F: number;
  57515. RGB16F: number;
  57516. RED: number;
  57517. RG: number;
  57518. R8: number;
  57519. RG8: number;
  57520. UNSIGNED_INT_24_8: number;
  57521. DEPTH24_STENCIL8: number;
  57522. /* Multiple Render Targets */
  57523. drawBuffers(buffers: number[]): void;
  57524. readBuffer(src: number): void;
  57525. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57526. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57527. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57528. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57529. // Occlusion Query
  57530. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57531. ANY_SAMPLES_PASSED: number;
  57532. QUERY_RESULT_AVAILABLE: number;
  57533. QUERY_RESULT: number;
  57534. }
  57535. interface WebGLBuffer {
  57536. references: number;
  57537. capacity: number;
  57538. is32Bits: boolean;
  57539. }
  57540. interface WebGLProgram {
  57541. transformFeedback?: WebGLTransformFeedback | null;
  57542. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57543. }
  57544. interface EXT_disjoint_timer_query {
  57545. QUERY_COUNTER_BITS_EXT: number;
  57546. TIME_ELAPSED_EXT: number;
  57547. TIMESTAMP_EXT: number;
  57548. GPU_DISJOINT_EXT: number;
  57549. QUERY_RESULT_EXT: number;
  57550. QUERY_RESULT_AVAILABLE_EXT: number;
  57551. queryCounterEXT(query: WebGLQuery, target: number): void;
  57552. createQueryEXT(): WebGLQuery;
  57553. beginQueryEXT(target: number, query: WebGLQuery): void;
  57554. endQueryEXT(target: number): void;
  57555. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57556. deleteQueryEXT(query: WebGLQuery): void;
  57557. }
  57558. interface WebGLUniformLocation {
  57559. _currentState: any;
  57560. }
  57561. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57562. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57563. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57564. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57565. interface WebGLRenderingContext {
  57566. readonly RASTERIZER_DISCARD: number;
  57567. readonly DEPTH_COMPONENT24: number;
  57568. readonly TEXTURE_3D: number;
  57569. readonly TEXTURE_2D_ARRAY: number;
  57570. readonly TEXTURE_COMPARE_FUNC: number;
  57571. readonly TEXTURE_COMPARE_MODE: number;
  57572. readonly COMPARE_REF_TO_TEXTURE: number;
  57573. readonly TEXTURE_WRAP_R: number;
  57574. readonly HALF_FLOAT: number;
  57575. readonly RGB8: number;
  57576. readonly RED_INTEGER: number;
  57577. readonly RG_INTEGER: number;
  57578. readonly RGB_INTEGER: number;
  57579. readonly RGBA_INTEGER: number;
  57580. readonly R8_SNORM: number;
  57581. readonly RG8_SNORM: number;
  57582. readonly RGB8_SNORM: number;
  57583. readonly RGBA8_SNORM: number;
  57584. readonly R8I: number;
  57585. readonly RG8I: number;
  57586. readonly RGB8I: number;
  57587. readonly RGBA8I: number;
  57588. readonly R8UI: number;
  57589. readonly RG8UI: number;
  57590. readonly RGB8UI: number;
  57591. readonly RGBA8UI: number;
  57592. readonly R16I: number;
  57593. readonly RG16I: number;
  57594. readonly RGB16I: number;
  57595. readonly RGBA16I: number;
  57596. readonly R16UI: number;
  57597. readonly RG16UI: number;
  57598. readonly RGB16UI: number;
  57599. readonly RGBA16UI: number;
  57600. readonly R32I: number;
  57601. readonly RG32I: number;
  57602. readonly RGB32I: number;
  57603. readonly RGBA32I: number;
  57604. readonly R32UI: number;
  57605. readonly RG32UI: number;
  57606. readonly RGB32UI: number;
  57607. readonly RGBA32UI: number;
  57608. readonly RGB10_A2UI: number;
  57609. readonly R11F_G11F_B10F: number;
  57610. readonly RGB9_E5: number;
  57611. readonly RGB10_A2: number;
  57612. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57613. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57614. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57615. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57616. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57617. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57618. 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;
  57619. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57620. readonly TRANSFORM_FEEDBACK: number;
  57621. readonly INTERLEAVED_ATTRIBS: number;
  57622. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57623. createTransformFeedback(): WebGLTransformFeedback;
  57624. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57625. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57626. beginTransformFeedback(primitiveMode: number): void;
  57627. endTransformFeedback(): void;
  57628. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57629. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57630. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57631. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57632. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57633. }
  57634. interface ImageBitmap {
  57635. readonly width: number;
  57636. readonly height: number;
  57637. close(): void;
  57638. }
  57639. interface WebGLQuery extends WebGLObject {
  57640. }
  57641. declare var WebGLQuery: {
  57642. prototype: WebGLQuery;
  57643. new(): WebGLQuery;
  57644. };
  57645. interface WebGLSampler extends WebGLObject {
  57646. }
  57647. declare var WebGLSampler: {
  57648. prototype: WebGLSampler;
  57649. new(): WebGLSampler;
  57650. };
  57651. interface WebGLSync extends WebGLObject {
  57652. }
  57653. declare var WebGLSync: {
  57654. prototype: WebGLSync;
  57655. new(): WebGLSync;
  57656. };
  57657. interface WebGLTransformFeedback extends WebGLObject {
  57658. }
  57659. declare var WebGLTransformFeedback: {
  57660. prototype: WebGLTransformFeedback;
  57661. new(): WebGLTransformFeedback;
  57662. };
  57663. interface WebGLVertexArrayObject extends WebGLObject {
  57664. }
  57665. declare var WebGLVertexArrayObject: {
  57666. prototype: WebGLVertexArrayObject;
  57667. new(): WebGLVertexArrayObject;
  57668. };
  57669. // Type definitions for WebVR API
  57670. // Project: https://w3c.github.io/webvr/
  57671. // Definitions by: six a <https://github.com/lostfictions>
  57672. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57673. interface VRDisplay extends EventTarget {
  57674. /**
  57675. * Dictionary of capabilities describing the VRDisplay.
  57676. */
  57677. readonly capabilities: VRDisplayCapabilities;
  57678. /**
  57679. * z-depth defining the far plane of the eye view frustum
  57680. * enables mapping of values in the render target depth
  57681. * attachment to scene coordinates. Initially set to 10000.0.
  57682. */
  57683. depthFar: number;
  57684. /**
  57685. * z-depth defining the near plane of the eye view frustum
  57686. * enables mapping of values in the render target depth
  57687. * attachment to scene coordinates. Initially set to 0.01.
  57688. */
  57689. depthNear: number;
  57690. /**
  57691. * An identifier for this distinct VRDisplay. Used as an
  57692. * association point in the Gamepad API.
  57693. */
  57694. readonly displayId: number;
  57695. /**
  57696. * A display name, a user-readable name identifying it.
  57697. */
  57698. readonly displayName: string;
  57699. readonly isConnected: boolean;
  57700. readonly isPresenting: boolean;
  57701. /**
  57702. * If this VRDisplay supports room-scale experiences, the optional
  57703. * stage attribute contains details on the room-scale parameters.
  57704. */
  57705. readonly stageParameters: VRStageParameters | null;
  57706. /**
  57707. * Passing the value returned by `requestAnimationFrame` to
  57708. * `cancelAnimationFrame` will unregister the callback.
  57709. * @param handle Define the hanle of the request to cancel
  57710. */
  57711. cancelAnimationFrame(handle: number): void;
  57712. /**
  57713. * Stops presenting to the VRDisplay.
  57714. * @returns a promise to know when it stopped
  57715. */
  57716. exitPresent(): Promise<void>;
  57717. /**
  57718. * Return the current VREyeParameters for the given eye.
  57719. * @param whichEye Define the eye we want the parameter for
  57720. * @returns the eye parameters
  57721. */
  57722. getEyeParameters(whichEye: string): VREyeParameters;
  57723. /**
  57724. * Populates the passed VRFrameData with the information required to render
  57725. * the current frame.
  57726. * @param frameData Define the data structure to populate
  57727. * @returns true if ok otherwise false
  57728. */
  57729. getFrameData(frameData: VRFrameData): boolean;
  57730. /**
  57731. * Get the layers currently being presented.
  57732. * @returns the list of VR layers
  57733. */
  57734. getLayers(): VRLayer[];
  57735. /**
  57736. * Return a VRPose containing the future predicted pose of the VRDisplay
  57737. * when the current frame will be presented. The value returned will not
  57738. * change until JavaScript has returned control to the browser.
  57739. *
  57740. * The VRPose will contain the position, orientation, velocity,
  57741. * and acceleration of each of these properties.
  57742. * @returns the pose object
  57743. */
  57744. getPose(): VRPose;
  57745. /**
  57746. * Return the current instantaneous pose of the VRDisplay, with no
  57747. * prediction applied.
  57748. * @returns the current instantaneous pose
  57749. */
  57750. getImmediatePose(): VRPose;
  57751. /**
  57752. * The callback passed to `requestAnimationFrame` will be called
  57753. * any time a new frame should be rendered. When the VRDisplay is
  57754. * presenting the callback will be called at the native refresh
  57755. * rate of the HMD. When not presenting this function acts
  57756. * identically to how window.requestAnimationFrame acts. Content should
  57757. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57758. * asynchronously from other displays and at differing refresh rates.
  57759. * @param callback Define the eaction to run next frame
  57760. * @returns the request handle it
  57761. */
  57762. requestAnimationFrame(callback: FrameRequestCallback): number;
  57763. /**
  57764. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57765. * Repeat calls while already presenting will update the VRLayers being displayed.
  57766. * @param layers Define the list of layer to present
  57767. * @returns a promise to know when the request has been fulfilled
  57768. */
  57769. requestPresent(layers: VRLayer[]): Promise<void>;
  57770. /**
  57771. * Reset the pose for this display, treating its current position and
  57772. * orientation as the "origin/zero" values. VRPose.position,
  57773. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57774. * updated when calling resetPose(). This should be called in only
  57775. * sitting-space experiences.
  57776. */
  57777. resetPose(): void;
  57778. /**
  57779. * The VRLayer provided to the VRDisplay will be captured and presented
  57780. * in the HMD. Calling this function has the same effect on the source
  57781. * canvas as any other operation that uses its source image, and canvases
  57782. * created without preserveDrawingBuffer set to true will be cleared.
  57783. * @param pose Define the pose to submit
  57784. */
  57785. submitFrame(pose?: VRPose): void;
  57786. }
  57787. declare var VRDisplay: {
  57788. prototype: VRDisplay;
  57789. new(): VRDisplay;
  57790. };
  57791. interface VRLayer {
  57792. leftBounds?: number[] | Float32Array | null;
  57793. rightBounds?: number[] | Float32Array | null;
  57794. source?: HTMLCanvasElement | null;
  57795. }
  57796. interface VRDisplayCapabilities {
  57797. readonly canPresent: boolean;
  57798. readonly hasExternalDisplay: boolean;
  57799. readonly hasOrientation: boolean;
  57800. readonly hasPosition: boolean;
  57801. readonly maxLayers: number;
  57802. }
  57803. interface VREyeParameters {
  57804. /** @deprecated */
  57805. readonly fieldOfView: VRFieldOfView;
  57806. readonly offset: Float32Array;
  57807. readonly renderHeight: number;
  57808. readonly renderWidth: number;
  57809. }
  57810. interface VRFieldOfView {
  57811. readonly downDegrees: number;
  57812. readonly leftDegrees: number;
  57813. readonly rightDegrees: number;
  57814. readonly upDegrees: number;
  57815. }
  57816. interface VRFrameData {
  57817. readonly leftProjectionMatrix: Float32Array;
  57818. readonly leftViewMatrix: Float32Array;
  57819. readonly pose: VRPose;
  57820. readonly rightProjectionMatrix: Float32Array;
  57821. readonly rightViewMatrix: Float32Array;
  57822. readonly timestamp: number;
  57823. }
  57824. interface VRPose {
  57825. readonly angularAcceleration: Float32Array | null;
  57826. readonly angularVelocity: Float32Array | null;
  57827. readonly linearAcceleration: Float32Array | null;
  57828. readonly linearVelocity: Float32Array | null;
  57829. readonly orientation: Float32Array | null;
  57830. readonly position: Float32Array | null;
  57831. readonly timestamp: number;
  57832. }
  57833. interface VRStageParameters {
  57834. sittingToStandingTransform?: Float32Array;
  57835. sizeX?: number;
  57836. sizeY?: number;
  57837. }
  57838. interface Navigator {
  57839. getVRDisplays(): Promise<VRDisplay[]>;
  57840. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57841. }
  57842. interface Window {
  57843. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57844. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57845. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57846. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57847. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57848. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57849. }
  57850. interface Gamepad {
  57851. readonly displayId: number;
  57852. }
  57853. interface XRDevice {
  57854. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57855. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57856. }
  57857. interface XRSession {
  57858. getInputSources(): Array<any>;
  57859. baseLayer: XRWebGLLayer;
  57860. requestFrameOfReference(type: string): Promise<void>;
  57861. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57862. end(): Promise<void>;
  57863. requestAnimationFrame: Function;
  57864. addEventListener: Function;
  57865. }
  57866. interface XRSessionCreationOptions {
  57867. outputContext?: WebGLRenderingContext | null;
  57868. immersive?: boolean;
  57869. environmentIntegration?: boolean;
  57870. }
  57871. interface XRLayer {
  57872. getViewport: Function;
  57873. framebufferWidth: number;
  57874. framebufferHeight: number;
  57875. }
  57876. interface XRView {
  57877. projectionMatrix: Float32Array;
  57878. }
  57879. interface XRFrame {
  57880. getDevicePose: Function;
  57881. getInputPose: Function;
  57882. views: Array<XRView>;
  57883. baseLayer: XRLayer;
  57884. }
  57885. interface XRFrameOfReference {
  57886. }
  57887. interface XRWebGLLayer extends XRLayer {
  57888. framebuffer: WebGLFramebuffer;
  57889. }
  57890. declare var XRWebGLLayer: {
  57891. prototype: XRWebGLLayer;
  57892. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57893. };
  57894. declare module "babylonjs" {
  57895. export * from "babylonjs/Legacy/legacy";
  57896. }
  57897. declare module BABYLON {
  57898. /** Alias type for value that can be null */
  57899. export type Nullable<T> = T | null;
  57900. /**
  57901. * Alias type for number that are floats
  57902. * @ignorenaming
  57903. */
  57904. export type float = number;
  57905. /**
  57906. * Alias type for number that are doubles.
  57907. * @ignorenaming
  57908. */
  57909. export type double = number;
  57910. /**
  57911. * Alias type for number that are integer
  57912. * @ignorenaming
  57913. */
  57914. export type int = number;
  57915. /** Alias type for number array or Float32Array */
  57916. export type FloatArray = number[] | Float32Array;
  57917. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57918. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57919. /**
  57920. * Alias for types that can be used by a Buffer or VertexBuffer.
  57921. */
  57922. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57923. /**
  57924. * Alias type for primitive types
  57925. * @ignorenaming
  57926. */
  57927. type Primitive = undefined | null | boolean | string | number | Function;
  57928. /**
  57929. * Type modifier to make all the properties of an object Readonly
  57930. */
  57931. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57932. /**
  57933. * Type modifier to make all the properties of an object Readonly recursively
  57934. */
  57935. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57936. /** @hidden */
  57937. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57938. }
  57939. /** @hidden */
  57940. /** @hidden */
  57941. type DeepImmutableObject<T> = {
  57942. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57943. };
  57944. }
  57945. declare module BABYLON {
  57946. /**
  57947. * Class containing a set of static utilities functions for arrays.
  57948. */
  57949. export class ArrayTools {
  57950. /**
  57951. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57952. * @param size the number of element to construct and put in the array
  57953. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57954. * @returns a new array filled with new objects
  57955. */
  57956. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57957. }
  57958. }
  57959. declare module BABYLON {
  57960. /**
  57961. * Scalar computation library
  57962. */
  57963. export class Scalar {
  57964. /**
  57965. * Two pi constants convenient for computation.
  57966. */
  57967. static TwoPi: number;
  57968. /**
  57969. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57970. * @param a number
  57971. * @param b number
  57972. * @param epsilon (default = 1.401298E-45)
  57973. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57974. */
  57975. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57976. /**
  57977. * Returns a string : the upper case translation of the number i to hexadecimal.
  57978. * @param i number
  57979. * @returns the upper case translation of the number i to hexadecimal.
  57980. */
  57981. static ToHex(i: number): string;
  57982. /**
  57983. * Returns -1 if value is negative and +1 is value is positive.
  57984. * @param value the value
  57985. * @returns the value itself if it's equal to zero.
  57986. */
  57987. static Sign(value: number): number;
  57988. /**
  57989. * Returns the value itself if it's between min and max.
  57990. * Returns min if the value is lower than min.
  57991. * Returns max if the value is greater than max.
  57992. * @param value the value to clmap
  57993. * @param min the min value to clamp to (default: 0)
  57994. * @param max the max value to clamp to (default: 1)
  57995. * @returns the clamped value
  57996. */
  57997. static Clamp(value: number, min?: number, max?: number): number;
  57998. /**
  57999. * the log2 of value.
  58000. * @param value the value to compute log2 of
  58001. * @returns the log2 of value.
  58002. */
  58003. static Log2(value: number): number;
  58004. /**
  58005. * Loops the value, so that it is never larger than length and never smaller than 0.
  58006. *
  58007. * This is similar to the modulo operator but it works with floating point numbers.
  58008. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  58009. * With t = 5 and length = 2.5, the result would be 0.0.
  58010. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  58011. * @param value the value
  58012. * @param length the length
  58013. * @returns the looped value
  58014. */
  58015. static Repeat(value: number, length: number): number;
  58016. /**
  58017. * Normalize the value between 0.0 and 1.0 using min and max values
  58018. * @param value value to normalize
  58019. * @param min max to normalize between
  58020. * @param max min to normalize between
  58021. * @returns the normalized value
  58022. */
  58023. static Normalize(value: number, min: number, max: number): number;
  58024. /**
  58025. * Denormalize the value from 0.0 and 1.0 using min and max values
  58026. * @param normalized value to denormalize
  58027. * @param min max to denormalize between
  58028. * @param max min to denormalize between
  58029. * @returns the denormalized value
  58030. */
  58031. static Denormalize(normalized: number, min: number, max: number): number;
  58032. /**
  58033. * Calculates the shortest difference between two given angles given in degrees.
  58034. * @param current current angle in degrees
  58035. * @param target target angle in degrees
  58036. * @returns the delta
  58037. */
  58038. static DeltaAngle(current: number, target: number): number;
  58039. /**
  58040. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  58041. * @param tx value
  58042. * @param length length
  58043. * @returns The returned value will move back and forth between 0 and length
  58044. */
  58045. static PingPong(tx: number, length: number): number;
  58046. /**
  58047. * Interpolates between min and max with smoothing at the limits.
  58048. *
  58049. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  58050. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  58051. * @param from from
  58052. * @param to to
  58053. * @param tx value
  58054. * @returns the smooth stepped value
  58055. */
  58056. static SmoothStep(from: number, to: number, tx: number): number;
  58057. /**
  58058. * Moves a value current towards target.
  58059. *
  58060. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  58061. * Negative values of maxDelta pushes the value away from target.
  58062. * @param current current value
  58063. * @param target target value
  58064. * @param maxDelta max distance to move
  58065. * @returns resulting value
  58066. */
  58067. static MoveTowards(current: number, target: number, maxDelta: number): number;
  58068. /**
  58069. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58070. *
  58071. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  58072. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  58073. * @param current current value
  58074. * @param target target value
  58075. * @param maxDelta max distance to move
  58076. * @returns resulting angle
  58077. */
  58078. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  58079. /**
  58080. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  58081. * @param start start value
  58082. * @param end target value
  58083. * @param amount amount to lerp between
  58084. * @returns the lerped value
  58085. */
  58086. static Lerp(start: number, end: number, amount: number): number;
  58087. /**
  58088. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58089. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  58090. * @param start start value
  58091. * @param end target value
  58092. * @param amount amount to lerp between
  58093. * @returns the lerped value
  58094. */
  58095. static LerpAngle(start: number, end: number, amount: number): number;
  58096. /**
  58097. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  58098. * @param a start value
  58099. * @param b target value
  58100. * @param value value between a and b
  58101. * @returns the inverseLerp value
  58102. */
  58103. static InverseLerp(a: number, b: number, value: number): number;
  58104. /**
  58105. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  58106. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  58107. * @param value1 spline value
  58108. * @param tangent1 spline value
  58109. * @param value2 spline value
  58110. * @param tangent2 spline value
  58111. * @param amount input value
  58112. * @returns hermite result
  58113. */
  58114. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  58115. /**
  58116. * Returns a random float number between and min and max values
  58117. * @param min min value of random
  58118. * @param max max value of random
  58119. * @returns random value
  58120. */
  58121. static RandomRange(min: number, max: number): number;
  58122. /**
  58123. * This function returns percentage of a number in a given range.
  58124. *
  58125. * RangeToPercent(40,20,60) will return 0.5 (50%)
  58126. * RangeToPercent(34,0,100) will return 0.34 (34%)
  58127. * @param number to convert to percentage
  58128. * @param min min range
  58129. * @param max max range
  58130. * @returns the percentage
  58131. */
  58132. static RangeToPercent(number: number, min: number, max: number): number;
  58133. /**
  58134. * This function returns number that corresponds to the percentage in a given range.
  58135. *
  58136. * PercentToRange(0.34,0,100) will return 34.
  58137. * @param percent to convert to number
  58138. * @param min min range
  58139. * @param max max range
  58140. * @returns the number
  58141. */
  58142. static PercentToRange(percent: number, min: number, max: number): number;
  58143. /**
  58144. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58145. * @param angle The angle to normalize in radian.
  58146. * @return The converted angle.
  58147. */
  58148. static NormalizeRadians(angle: number): number;
  58149. }
  58150. }
  58151. declare module BABYLON {
  58152. /**
  58153. * Constant used to convert a value to gamma space
  58154. * @ignorenaming
  58155. */
  58156. export const ToGammaSpace: number;
  58157. /**
  58158. * Constant used to convert a value to linear space
  58159. * @ignorenaming
  58160. */
  58161. export const ToLinearSpace = 2.2;
  58162. /**
  58163. * Constant used to define the minimal number value in Babylon.js
  58164. * @ignorenaming
  58165. */
  58166. export const Epsilon = 0.001;
  58167. /**
  58168. * Class used to hold a RBG color
  58169. */
  58170. export class Color3 {
  58171. /**
  58172. * Defines the red component (between 0 and 1, default is 0)
  58173. */
  58174. r: number;
  58175. /**
  58176. * Defines the green component (between 0 and 1, default is 0)
  58177. */
  58178. g: number;
  58179. /**
  58180. * Defines the blue component (between 0 and 1, default is 0)
  58181. */
  58182. b: number;
  58183. /**
  58184. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58185. * @param r defines the red component (between 0 and 1, default is 0)
  58186. * @param g defines the green component (between 0 and 1, default is 0)
  58187. * @param b defines the blue component (between 0 and 1, default is 0)
  58188. */
  58189. constructor(
  58190. /**
  58191. * Defines the red component (between 0 and 1, default is 0)
  58192. */
  58193. r?: number,
  58194. /**
  58195. * Defines the green component (between 0 and 1, default is 0)
  58196. */
  58197. g?: number,
  58198. /**
  58199. * Defines the blue component (between 0 and 1, default is 0)
  58200. */
  58201. b?: number);
  58202. /**
  58203. * Creates a string with the Color3 current values
  58204. * @returns the string representation of the Color3 object
  58205. */
  58206. toString(): string;
  58207. /**
  58208. * Returns the string "Color3"
  58209. * @returns "Color3"
  58210. */
  58211. getClassName(): string;
  58212. /**
  58213. * Compute the Color3 hash code
  58214. * @returns an unique number that can be used to hash Color3 objects
  58215. */
  58216. getHashCode(): number;
  58217. /**
  58218. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58219. * @param array defines the array where to store the r,g,b components
  58220. * @param index defines an optional index in the target array to define where to start storing values
  58221. * @returns the current Color3 object
  58222. */
  58223. toArray(array: FloatArray, index?: number): Color3;
  58224. /**
  58225. * Returns a new Color4 object from the current Color3 and the given alpha
  58226. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58227. * @returns a new Color4 object
  58228. */
  58229. toColor4(alpha?: number): Color4;
  58230. /**
  58231. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58232. * @returns the new array
  58233. */
  58234. asArray(): number[];
  58235. /**
  58236. * Returns the luminance value
  58237. * @returns a float value
  58238. */
  58239. toLuminance(): number;
  58240. /**
  58241. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58242. * @param otherColor defines the second operand
  58243. * @returns the new Color3 object
  58244. */
  58245. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58246. /**
  58247. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58248. * @param otherColor defines the second operand
  58249. * @param result defines the Color3 object where to store the result
  58250. * @returns the current Color3
  58251. */
  58252. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58253. /**
  58254. * Determines equality between Color3 objects
  58255. * @param otherColor defines the second operand
  58256. * @returns true if the rgb values are equal to the given ones
  58257. */
  58258. equals(otherColor: DeepImmutable<Color3>): boolean;
  58259. /**
  58260. * Determines equality between the current Color3 object and a set of r,b,g values
  58261. * @param r defines the red component to check
  58262. * @param g defines the green component to check
  58263. * @param b defines the blue component to check
  58264. * @returns true if the rgb values are equal to the given ones
  58265. */
  58266. equalsFloats(r: number, g: number, b: number): boolean;
  58267. /**
  58268. * Multiplies in place each rgb value by scale
  58269. * @param scale defines the scaling factor
  58270. * @returns the updated Color3
  58271. */
  58272. scale(scale: number): Color3;
  58273. /**
  58274. * Multiplies the rgb values by scale and stores the result into "result"
  58275. * @param scale defines the scaling factor
  58276. * @param result defines the Color3 object where to store the result
  58277. * @returns the unmodified current Color3
  58278. */
  58279. scaleToRef(scale: number, result: Color3): Color3;
  58280. /**
  58281. * Scale the current Color3 values by a factor and add the result to a given Color3
  58282. * @param scale defines the scale factor
  58283. * @param result defines color to store the result into
  58284. * @returns the unmodified current Color3
  58285. */
  58286. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58287. /**
  58288. * Clamps the rgb values by the min and max values and stores the result into "result"
  58289. * @param min defines minimum clamping value (default is 0)
  58290. * @param max defines maximum clamping value (default is 1)
  58291. * @param result defines color to store the result into
  58292. * @returns the original Color3
  58293. */
  58294. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58295. /**
  58296. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58297. * @param otherColor defines the second operand
  58298. * @returns the new Color3
  58299. */
  58300. add(otherColor: DeepImmutable<Color3>): Color3;
  58301. /**
  58302. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58303. * @param otherColor defines the second operand
  58304. * @param result defines Color3 object to store the result into
  58305. * @returns the unmodified current Color3
  58306. */
  58307. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58308. /**
  58309. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58310. * @param otherColor defines the second operand
  58311. * @returns the new Color3
  58312. */
  58313. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58314. /**
  58315. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58316. * @param otherColor defines the second operand
  58317. * @param result defines Color3 object to store the result into
  58318. * @returns the unmodified current Color3
  58319. */
  58320. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58321. /**
  58322. * Copy the current object
  58323. * @returns a new Color3 copied the current one
  58324. */
  58325. clone(): Color3;
  58326. /**
  58327. * Copies the rgb values from the source in the current Color3
  58328. * @param source defines the source Color3 object
  58329. * @returns the updated Color3 object
  58330. */
  58331. copyFrom(source: DeepImmutable<Color3>): Color3;
  58332. /**
  58333. * Updates the Color3 rgb values from the given floats
  58334. * @param r defines the red component to read from
  58335. * @param g defines the green component to read from
  58336. * @param b defines the blue component to read from
  58337. * @returns the current Color3 object
  58338. */
  58339. copyFromFloats(r: number, g: number, b: number): Color3;
  58340. /**
  58341. * Updates the Color3 rgb values from the given floats
  58342. * @param r defines the red component to read from
  58343. * @param g defines the green component to read from
  58344. * @param b defines the blue component to read from
  58345. * @returns the current Color3 object
  58346. */
  58347. set(r: number, g: number, b: number): Color3;
  58348. /**
  58349. * Compute the Color3 hexadecimal code as a string
  58350. * @returns a string containing the hexadecimal representation of the Color3 object
  58351. */
  58352. toHexString(): string;
  58353. /**
  58354. * Computes a new Color3 converted from the current one to linear space
  58355. * @returns a new Color3 object
  58356. */
  58357. toLinearSpace(): Color3;
  58358. /**
  58359. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58360. * @param convertedColor defines the Color3 object where to store the linear space version
  58361. * @returns the unmodified Color3
  58362. */
  58363. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58364. /**
  58365. * Computes a new Color3 converted from the current one to gamma space
  58366. * @returns a new Color3 object
  58367. */
  58368. toGammaSpace(): Color3;
  58369. /**
  58370. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58371. * @param convertedColor defines the Color3 object where to store the gamma space version
  58372. * @returns the unmodified Color3
  58373. */
  58374. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58375. private static _BlackReadOnly;
  58376. /**
  58377. * Creates a new Color3 from the string containing valid hexadecimal values
  58378. * @param hex defines a string containing valid hexadecimal values
  58379. * @returns a new Color3 object
  58380. */
  58381. static FromHexString(hex: string): Color3;
  58382. /**
  58383. * Creates a new Vector3 from the starting index of the given array
  58384. * @param array defines the source array
  58385. * @param offset defines an offset in the source array
  58386. * @returns a new Color3 object
  58387. */
  58388. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58389. /**
  58390. * Creates a new Color3 from integer values (< 256)
  58391. * @param r defines the red component to read from (value between 0 and 255)
  58392. * @param g defines the green component to read from (value between 0 and 255)
  58393. * @param b defines the blue component to read from (value between 0 and 255)
  58394. * @returns a new Color3 object
  58395. */
  58396. static FromInts(r: number, g: number, b: number): Color3;
  58397. /**
  58398. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58399. * @param start defines the start Color3 value
  58400. * @param end defines the end Color3 value
  58401. * @param amount defines the gradient value between start and end
  58402. * @returns a new Color3 object
  58403. */
  58404. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58405. /**
  58406. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58407. * @param left defines the start value
  58408. * @param right defines the end value
  58409. * @param amount defines the gradient factor
  58410. * @param result defines the Color3 object where to store the result
  58411. */
  58412. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58413. /**
  58414. * Returns a Color3 value containing a red color
  58415. * @returns a new Color3 object
  58416. */
  58417. static Red(): Color3;
  58418. /**
  58419. * Returns a Color3 value containing a green color
  58420. * @returns a new Color3 object
  58421. */
  58422. static Green(): Color3;
  58423. /**
  58424. * Returns a Color3 value containing a blue color
  58425. * @returns a new Color3 object
  58426. */
  58427. static Blue(): Color3;
  58428. /**
  58429. * Returns a Color3 value containing a black color
  58430. * @returns a new Color3 object
  58431. */
  58432. static Black(): Color3;
  58433. /**
  58434. * Gets a Color3 value containing a black color that must not be updated
  58435. */
  58436. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58437. /**
  58438. * Returns a Color3 value containing a white color
  58439. * @returns a new Color3 object
  58440. */
  58441. static White(): Color3;
  58442. /**
  58443. * Returns a Color3 value containing a purple color
  58444. * @returns a new Color3 object
  58445. */
  58446. static Purple(): Color3;
  58447. /**
  58448. * Returns a Color3 value containing a magenta color
  58449. * @returns a new Color3 object
  58450. */
  58451. static Magenta(): Color3;
  58452. /**
  58453. * Returns a Color3 value containing a yellow color
  58454. * @returns a new Color3 object
  58455. */
  58456. static Yellow(): Color3;
  58457. /**
  58458. * Returns a Color3 value containing a gray color
  58459. * @returns a new Color3 object
  58460. */
  58461. static Gray(): Color3;
  58462. /**
  58463. * Returns a Color3 value containing a teal color
  58464. * @returns a new Color3 object
  58465. */
  58466. static Teal(): Color3;
  58467. /**
  58468. * Returns a Color3 value containing a random color
  58469. * @returns a new Color3 object
  58470. */
  58471. static Random(): Color3;
  58472. }
  58473. /**
  58474. * Class used to hold a RBGA color
  58475. */
  58476. export class Color4 {
  58477. /**
  58478. * Defines the red component (between 0 and 1, default is 0)
  58479. */
  58480. r: number;
  58481. /**
  58482. * Defines the green component (between 0 and 1, default is 0)
  58483. */
  58484. g: number;
  58485. /**
  58486. * Defines the blue component (between 0 and 1, default is 0)
  58487. */
  58488. b: number;
  58489. /**
  58490. * Defines the alpha component (between 0 and 1, default is 1)
  58491. */
  58492. a: number;
  58493. /**
  58494. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58495. * @param r defines the red component (between 0 and 1, default is 0)
  58496. * @param g defines the green component (between 0 and 1, default is 0)
  58497. * @param b defines the blue component (between 0 and 1, default is 0)
  58498. * @param a defines the alpha component (between 0 and 1, default is 1)
  58499. */
  58500. constructor(
  58501. /**
  58502. * Defines the red component (between 0 and 1, default is 0)
  58503. */
  58504. r?: number,
  58505. /**
  58506. * Defines the green component (between 0 and 1, default is 0)
  58507. */
  58508. g?: number,
  58509. /**
  58510. * Defines the blue component (between 0 and 1, default is 0)
  58511. */
  58512. b?: number,
  58513. /**
  58514. * Defines the alpha component (between 0 and 1, default is 1)
  58515. */
  58516. a?: number);
  58517. /**
  58518. * Adds in place the given Color4 values to the current Color4 object
  58519. * @param right defines the second operand
  58520. * @returns the current updated Color4 object
  58521. */
  58522. addInPlace(right: DeepImmutable<Color4>): Color4;
  58523. /**
  58524. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58525. * @returns the new array
  58526. */
  58527. asArray(): number[];
  58528. /**
  58529. * Stores from the starting index in the given array the Color4 successive values
  58530. * @param array defines the array where to store the r,g,b components
  58531. * @param index defines an optional index in the target array to define where to start storing values
  58532. * @returns the current Color4 object
  58533. */
  58534. toArray(array: number[], index?: number): Color4;
  58535. /**
  58536. * Determines equality between Color4 objects
  58537. * @param otherColor defines the second operand
  58538. * @returns true if the rgba values are equal to the given ones
  58539. */
  58540. equals(otherColor: DeepImmutable<Color4>): boolean;
  58541. /**
  58542. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58543. * @param right defines the second operand
  58544. * @returns a new Color4 object
  58545. */
  58546. add(right: DeepImmutable<Color4>): Color4;
  58547. /**
  58548. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58549. * @param right defines the second operand
  58550. * @returns a new Color4 object
  58551. */
  58552. subtract(right: DeepImmutable<Color4>): Color4;
  58553. /**
  58554. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58555. * @param right defines the second operand
  58556. * @param result defines the Color4 object where to store the result
  58557. * @returns the current Color4 object
  58558. */
  58559. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58560. /**
  58561. * Creates a new Color4 with the current Color4 values multiplied by scale
  58562. * @param scale defines the scaling factor to apply
  58563. * @returns a new Color4 object
  58564. */
  58565. scale(scale: number): Color4;
  58566. /**
  58567. * Multiplies the current Color4 values by scale and stores the result in "result"
  58568. * @param scale defines the scaling factor to apply
  58569. * @param result defines the Color4 object where to store the result
  58570. * @returns the current unmodified Color4
  58571. */
  58572. scaleToRef(scale: number, result: Color4): Color4;
  58573. /**
  58574. * Scale the current Color4 values by a factor and add the result to a given Color4
  58575. * @param scale defines the scale factor
  58576. * @param result defines the Color4 object where to store the result
  58577. * @returns the unmodified current Color4
  58578. */
  58579. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58580. /**
  58581. * Clamps the rgb values by the min and max values and stores the result into "result"
  58582. * @param min defines minimum clamping value (default is 0)
  58583. * @param max defines maximum clamping value (default is 1)
  58584. * @param result defines color to store the result into.
  58585. * @returns the cuurent Color4
  58586. */
  58587. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58588. /**
  58589. * Multipy an Color4 value by another and return a new Color4 object
  58590. * @param color defines the Color4 value to multiply by
  58591. * @returns a new Color4 object
  58592. */
  58593. multiply(color: Color4): Color4;
  58594. /**
  58595. * Multipy a Color4 value by another and push the result in a reference value
  58596. * @param color defines the Color4 value to multiply by
  58597. * @param result defines the Color4 to fill the result in
  58598. * @returns the result Color4
  58599. */
  58600. multiplyToRef(color: Color4, result: Color4): Color4;
  58601. /**
  58602. * Creates a string with the Color4 current values
  58603. * @returns the string representation of the Color4 object
  58604. */
  58605. toString(): string;
  58606. /**
  58607. * Returns the string "Color4"
  58608. * @returns "Color4"
  58609. */
  58610. getClassName(): string;
  58611. /**
  58612. * Compute the Color4 hash code
  58613. * @returns an unique number that can be used to hash Color4 objects
  58614. */
  58615. getHashCode(): number;
  58616. /**
  58617. * Creates a new Color4 copied from the current one
  58618. * @returns a new Color4 object
  58619. */
  58620. clone(): Color4;
  58621. /**
  58622. * Copies the given Color4 values into the current one
  58623. * @param source defines the source Color4 object
  58624. * @returns the current updated Color4 object
  58625. */
  58626. copyFrom(source: Color4): Color4;
  58627. /**
  58628. * Copies the given float values into the current one
  58629. * @param r defines the red component to read from
  58630. * @param g defines the green component to read from
  58631. * @param b defines the blue component to read from
  58632. * @param a defines the alpha component to read from
  58633. * @returns the current updated Color4 object
  58634. */
  58635. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58636. /**
  58637. * Copies the given float values into the current one
  58638. * @param r defines the red component to read from
  58639. * @param g defines the green component to read from
  58640. * @param b defines the blue component to read from
  58641. * @param a defines the alpha component to read from
  58642. * @returns the current updated Color4 object
  58643. */
  58644. set(r: number, g: number, b: number, a: number): Color4;
  58645. /**
  58646. * Compute the Color4 hexadecimal code as a string
  58647. * @returns a string containing the hexadecimal representation of the Color4 object
  58648. */
  58649. toHexString(): string;
  58650. /**
  58651. * Computes a new Color4 converted from the current one to linear space
  58652. * @returns a new Color4 object
  58653. */
  58654. toLinearSpace(): Color4;
  58655. /**
  58656. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58657. * @param convertedColor defines the Color4 object where to store the linear space version
  58658. * @returns the unmodified Color4
  58659. */
  58660. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58661. /**
  58662. * Computes a new Color4 converted from the current one to gamma space
  58663. * @returns a new Color4 object
  58664. */
  58665. toGammaSpace(): Color4;
  58666. /**
  58667. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58668. * @param convertedColor defines the Color4 object where to store the gamma space version
  58669. * @returns the unmodified Color4
  58670. */
  58671. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58672. /**
  58673. * Creates a new Color4 from the string containing valid hexadecimal values
  58674. * @param hex defines a string containing valid hexadecimal values
  58675. * @returns a new Color4 object
  58676. */
  58677. static FromHexString(hex: string): Color4;
  58678. /**
  58679. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58680. * @param left defines the start value
  58681. * @param right defines the end value
  58682. * @param amount defines the gradient factor
  58683. * @returns a new Color4 object
  58684. */
  58685. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58686. /**
  58687. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58688. * @param left defines the start value
  58689. * @param right defines the end value
  58690. * @param amount defines the gradient factor
  58691. * @param result defines the Color4 object where to store data
  58692. */
  58693. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58694. /**
  58695. * Creates a new Color4 from a Color3 and an alpha value
  58696. * @param color3 defines the source Color3 to read from
  58697. * @param alpha defines the alpha component (1.0 by default)
  58698. * @returns a new Color4 object
  58699. */
  58700. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58701. /**
  58702. * Creates a new Color4 from the starting index element of the given array
  58703. * @param array defines the source array to read from
  58704. * @param offset defines the offset in the source array
  58705. * @returns a new Color4 object
  58706. */
  58707. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58708. /**
  58709. * Creates a new Color3 from integer values (< 256)
  58710. * @param r defines the red component to read from (value between 0 and 255)
  58711. * @param g defines the green component to read from (value between 0 and 255)
  58712. * @param b defines the blue component to read from (value between 0 and 255)
  58713. * @param a defines the alpha component to read from (value between 0 and 255)
  58714. * @returns a new Color3 object
  58715. */
  58716. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58717. /**
  58718. * Check the content of a given array and convert it to an array containing RGBA data
  58719. * If the original array was already containing count * 4 values then it is returned directly
  58720. * @param colors defines the array to check
  58721. * @param count defines the number of RGBA data to expect
  58722. * @returns an array containing count * 4 values (RGBA)
  58723. */
  58724. static CheckColors4(colors: number[], count: number): number[];
  58725. }
  58726. /**
  58727. * Class representing a vector containing 2 coordinates
  58728. */
  58729. export class Vector2 {
  58730. /** defines the first coordinate */
  58731. x: number;
  58732. /** defines the second coordinate */
  58733. y: number;
  58734. /**
  58735. * Creates a new Vector2 from the given x and y coordinates
  58736. * @param x defines the first coordinate
  58737. * @param y defines the second coordinate
  58738. */
  58739. constructor(
  58740. /** defines the first coordinate */
  58741. x?: number,
  58742. /** defines the second coordinate */
  58743. y?: number);
  58744. /**
  58745. * Gets a string with the Vector2 coordinates
  58746. * @returns a string with the Vector2 coordinates
  58747. */
  58748. toString(): string;
  58749. /**
  58750. * Gets class name
  58751. * @returns the string "Vector2"
  58752. */
  58753. getClassName(): string;
  58754. /**
  58755. * Gets current vector hash code
  58756. * @returns the Vector2 hash code as a number
  58757. */
  58758. getHashCode(): number;
  58759. /**
  58760. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58761. * @param array defines the source array
  58762. * @param index defines the offset in source array
  58763. * @returns the current Vector2
  58764. */
  58765. toArray(array: FloatArray, index?: number): Vector2;
  58766. /**
  58767. * Copy the current vector to an array
  58768. * @returns a new array with 2 elements: the Vector2 coordinates.
  58769. */
  58770. asArray(): number[];
  58771. /**
  58772. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58773. * @param source defines the source Vector2
  58774. * @returns the current updated Vector2
  58775. */
  58776. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58777. /**
  58778. * Sets the Vector2 coordinates with the given floats
  58779. * @param x defines the first coordinate
  58780. * @param y defines the second coordinate
  58781. * @returns the current updated Vector2
  58782. */
  58783. copyFromFloats(x: number, y: number): Vector2;
  58784. /**
  58785. * Sets the Vector2 coordinates with the given floats
  58786. * @param x defines the first coordinate
  58787. * @param y defines the second coordinate
  58788. * @returns the current updated Vector2
  58789. */
  58790. set(x: number, y: number): Vector2;
  58791. /**
  58792. * Add another vector with the current one
  58793. * @param otherVector defines the other vector
  58794. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58795. */
  58796. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58797. /**
  58798. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58799. * @param otherVector defines the other vector
  58800. * @param result defines the target vector
  58801. * @returns the unmodified current Vector2
  58802. */
  58803. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58804. /**
  58805. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58806. * @param otherVector defines the other vector
  58807. * @returns the current updated Vector2
  58808. */
  58809. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58810. /**
  58811. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58812. * @param otherVector defines the other vector
  58813. * @returns a new Vector2
  58814. */
  58815. addVector3(otherVector: Vector3): Vector2;
  58816. /**
  58817. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58818. * @param otherVector defines the other vector
  58819. * @returns a new Vector2
  58820. */
  58821. subtract(otherVector: Vector2): Vector2;
  58822. /**
  58823. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58824. * @param otherVector defines the other vector
  58825. * @param result defines the target vector
  58826. * @returns the unmodified current Vector2
  58827. */
  58828. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58829. /**
  58830. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58831. * @param otherVector defines the other vector
  58832. * @returns the current updated Vector2
  58833. */
  58834. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58835. /**
  58836. * Multiplies in place the current Vector2 coordinates by the given ones
  58837. * @param otherVector defines the other vector
  58838. * @returns the current updated Vector2
  58839. */
  58840. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58841. /**
  58842. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58843. * @param otherVector defines the other vector
  58844. * @returns a new Vector2
  58845. */
  58846. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58847. /**
  58848. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58849. * @param otherVector defines the other vector
  58850. * @param result defines the target vector
  58851. * @returns the unmodified current Vector2
  58852. */
  58853. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58854. /**
  58855. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58856. * @param x defines the first coordinate
  58857. * @param y defines the second coordinate
  58858. * @returns a new Vector2
  58859. */
  58860. multiplyByFloats(x: number, y: number): Vector2;
  58861. /**
  58862. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58863. * @param otherVector defines the other vector
  58864. * @returns a new Vector2
  58865. */
  58866. divide(otherVector: Vector2): Vector2;
  58867. /**
  58868. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58869. * @param otherVector defines the other vector
  58870. * @param result defines the target vector
  58871. * @returns the unmodified current Vector2
  58872. */
  58873. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58874. /**
  58875. * Divides the current Vector2 coordinates by the given ones
  58876. * @param otherVector defines the other vector
  58877. * @returns the current updated Vector2
  58878. */
  58879. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58880. /**
  58881. * Gets a new Vector2 with current Vector2 negated coordinates
  58882. * @returns a new Vector2
  58883. */
  58884. negate(): Vector2;
  58885. /**
  58886. * Multiply the Vector2 coordinates by scale
  58887. * @param scale defines the scaling factor
  58888. * @returns the current updated Vector2
  58889. */
  58890. scaleInPlace(scale: number): Vector2;
  58891. /**
  58892. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58893. * @param scale defines the scaling factor
  58894. * @returns a new Vector2
  58895. */
  58896. scale(scale: number): Vector2;
  58897. /**
  58898. * Scale the current Vector2 values by a factor to a given Vector2
  58899. * @param scale defines the scale factor
  58900. * @param result defines the Vector2 object where to store the result
  58901. * @returns the unmodified current Vector2
  58902. */
  58903. scaleToRef(scale: number, result: Vector2): Vector2;
  58904. /**
  58905. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58906. * @param scale defines the scale factor
  58907. * @param result defines the Vector2 object where to store the result
  58908. * @returns the unmodified current Vector2
  58909. */
  58910. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58911. /**
  58912. * Gets a boolean if two vectors are equals
  58913. * @param otherVector defines the other vector
  58914. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58915. */
  58916. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58917. /**
  58918. * Gets a boolean if two vectors are equals (using an epsilon value)
  58919. * @param otherVector defines the other vector
  58920. * @param epsilon defines the minimal distance to consider equality
  58921. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58922. */
  58923. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58924. /**
  58925. * Gets a new Vector2 from current Vector2 floored values
  58926. * @returns a new Vector2
  58927. */
  58928. floor(): Vector2;
  58929. /**
  58930. * Gets a new Vector2 from current Vector2 floored values
  58931. * @returns a new Vector2
  58932. */
  58933. fract(): Vector2;
  58934. /**
  58935. * Gets the length of the vector
  58936. * @returns the vector length (float)
  58937. */
  58938. length(): number;
  58939. /**
  58940. * Gets the vector squared length
  58941. * @returns the vector squared length (float)
  58942. */
  58943. lengthSquared(): number;
  58944. /**
  58945. * Normalize the vector
  58946. * @returns the current updated Vector2
  58947. */
  58948. normalize(): Vector2;
  58949. /**
  58950. * Gets a new Vector2 copied from the Vector2
  58951. * @returns a new Vector2
  58952. */
  58953. clone(): Vector2;
  58954. /**
  58955. * Gets a new Vector2(0, 0)
  58956. * @returns a new Vector2
  58957. */
  58958. static Zero(): Vector2;
  58959. /**
  58960. * Gets a new Vector2(1, 1)
  58961. * @returns a new Vector2
  58962. */
  58963. static One(): Vector2;
  58964. /**
  58965. * Gets a new Vector2 set from the given index element of the given array
  58966. * @param array defines the data source
  58967. * @param offset defines the offset in the data source
  58968. * @returns a new Vector2
  58969. */
  58970. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58971. /**
  58972. * Sets "result" from the given index element of the given array
  58973. * @param array defines the data source
  58974. * @param offset defines the offset in the data source
  58975. * @param result defines the target vector
  58976. */
  58977. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58978. /**
  58979. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58980. * @param value1 defines 1st point of control
  58981. * @param value2 defines 2nd point of control
  58982. * @param value3 defines 3rd point of control
  58983. * @param value4 defines 4th point of control
  58984. * @param amount defines the interpolation factor
  58985. * @returns a new Vector2
  58986. */
  58987. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58988. /**
  58989. * 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".
  58990. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58991. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58992. * @param value defines the value to clamp
  58993. * @param min defines the lower limit
  58994. * @param max defines the upper limit
  58995. * @returns a new Vector2
  58996. */
  58997. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58998. /**
  58999. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  59000. * @param value1 defines the 1st control point
  59001. * @param tangent1 defines the outgoing tangent
  59002. * @param value2 defines the 2nd control point
  59003. * @param tangent2 defines the incoming tangent
  59004. * @param amount defines the interpolation factor
  59005. * @returns a new Vector2
  59006. */
  59007. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  59008. /**
  59009. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  59010. * @param start defines the start vector
  59011. * @param end defines the end vector
  59012. * @param amount defines the interpolation factor
  59013. * @returns a new Vector2
  59014. */
  59015. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  59016. /**
  59017. * Gets the dot product of the vector "left" and the vector "right"
  59018. * @param left defines first vector
  59019. * @param right defines second vector
  59020. * @returns the dot product (float)
  59021. */
  59022. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  59023. /**
  59024. * Returns a new Vector2 equal to the normalized given vector
  59025. * @param vector defines the vector to normalize
  59026. * @returns a new Vector2
  59027. */
  59028. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  59029. /**
  59030. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  59031. * @param left defines 1st vector
  59032. * @param right defines 2nd vector
  59033. * @returns a new Vector2
  59034. */
  59035. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59036. /**
  59037. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  59038. * @param left defines 1st vector
  59039. * @param right defines 2nd vector
  59040. * @returns a new Vector2
  59041. */
  59042. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59043. /**
  59044. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  59045. * @param vector defines the vector to transform
  59046. * @param transformation defines the matrix to apply
  59047. * @returns a new Vector2
  59048. */
  59049. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  59050. /**
  59051. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  59052. * @param vector defines the vector to transform
  59053. * @param transformation defines the matrix to apply
  59054. * @param result defines the target vector
  59055. */
  59056. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  59057. /**
  59058. * Determines if a given vector is included in a triangle
  59059. * @param p defines the vector to test
  59060. * @param p0 defines 1st triangle point
  59061. * @param p1 defines 2nd triangle point
  59062. * @param p2 defines 3rd triangle point
  59063. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  59064. */
  59065. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  59066. /**
  59067. * Gets the distance between the vectors "value1" and "value2"
  59068. * @param value1 defines first vector
  59069. * @param value2 defines second vector
  59070. * @returns the distance between vectors
  59071. */
  59072. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59073. /**
  59074. * Returns the squared distance between the vectors "value1" and "value2"
  59075. * @param value1 defines first vector
  59076. * @param value2 defines second vector
  59077. * @returns the squared distance between vectors
  59078. */
  59079. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59080. /**
  59081. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  59082. * @param value1 defines first vector
  59083. * @param value2 defines second vector
  59084. * @returns a new Vector2
  59085. */
  59086. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  59087. /**
  59088. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  59089. * @param p defines the middle point
  59090. * @param segA defines one point of the segment
  59091. * @param segB defines the other point of the segment
  59092. * @returns the shortest distance
  59093. */
  59094. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  59095. }
  59096. /**
  59097. * Classed used to store (x,y,z) vector representation
  59098. * A Vector3 is the main object used in 3D geometry
  59099. * It can represent etiher the coordinates of a point the space, either a direction
  59100. * Reminder: js uses a left handed forward facing system
  59101. */
  59102. export class Vector3 {
  59103. /**
  59104. * Defines the first coordinates (on X axis)
  59105. */
  59106. x: number;
  59107. /**
  59108. * Defines the second coordinates (on Y axis)
  59109. */
  59110. y: number;
  59111. /**
  59112. * Defines the third coordinates (on Z axis)
  59113. */
  59114. z: number;
  59115. private static _UpReadOnly;
  59116. /**
  59117. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  59118. * @param x defines the first coordinates (on X axis)
  59119. * @param y defines the second coordinates (on Y axis)
  59120. * @param z defines the third coordinates (on Z axis)
  59121. */
  59122. constructor(
  59123. /**
  59124. * Defines the first coordinates (on X axis)
  59125. */
  59126. x?: number,
  59127. /**
  59128. * Defines the second coordinates (on Y axis)
  59129. */
  59130. y?: number,
  59131. /**
  59132. * Defines the third coordinates (on Z axis)
  59133. */
  59134. z?: number);
  59135. /**
  59136. * Creates a string representation of the Vector3
  59137. * @returns a string with the Vector3 coordinates.
  59138. */
  59139. toString(): string;
  59140. /**
  59141. * Gets the class name
  59142. * @returns the string "Vector3"
  59143. */
  59144. getClassName(): string;
  59145. /**
  59146. * Creates the Vector3 hash code
  59147. * @returns a number which tends to be unique between Vector3 instances
  59148. */
  59149. getHashCode(): number;
  59150. /**
  59151. * Creates an array containing three elements : the coordinates of the Vector3
  59152. * @returns a new array of numbers
  59153. */
  59154. asArray(): number[];
  59155. /**
  59156. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59157. * @param array defines the destination array
  59158. * @param index defines the offset in the destination array
  59159. * @returns the current Vector3
  59160. */
  59161. toArray(array: FloatArray, index?: number): Vector3;
  59162. /**
  59163. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59164. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59165. */
  59166. toQuaternion(): Quaternion;
  59167. /**
  59168. * Adds the given vector to the current Vector3
  59169. * @param otherVector defines the second operand
  59170. * @returns the current updated Vector3
  59171. */
  59172. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59173. /**
  59174. * Adds the given coordinates to the current Vector3
  59175. * @param x defines the x coordinate of the operand
  59176. * @param y defines the y coordinate of the operand
  59177. * @param z defines the z coordinate of the operand
  59178. * @returns the current updated Vector3
  59179. */
  59180. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59181. /**
  59182. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59183. * @param otherVector defines the second operand
  59184. * @returns the resulting Vector3
  59185. */
  59186. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59187. /**
  59188. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59189. * @param otherVector defines the second operand
  59190. * @param result defines the Vector3 object where to store the result
  59191. * @returns the current Vector3
  59192. */
  59193. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59194. /**
  59195. * Subtract the given vector from the current Vector3
  59196. * @param otherVector defines the second operand
  59197. * @returns the current updated Vector3
  59198. */
  59199. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59200. /**
  59201. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59202. * @param otherVector defines the second operand
  59203. * @returns the resulting Vector3
  59204. */
  59205. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59206. /**
  59207. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59208. * @param otherVector defines the second operand
  59209. * @param result defines the Vector3 object where to store the result
  59210. * @returns the current Vector3
  59211. */
  59212. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59213. /**
  59214. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  59215. * @param x defines the x coordinate of the operand
  59216. * @param y defines the y coordinate of the operand
  59217. * @param z defines the z coordinate of the operand
  59218. * @returns the resulting Vector3
  59219. */
  59220. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59221. /**
  59222. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59223. * @param x defines the x coordinate of the operand
  59224. * @param y defines the y coordinate of the operand
  59225. * @param z defines the z coordinate of the operand
  59226. * @param result defines the Vector3 object where to store the result
  59227. * @returns the current Vector3
  59228. */
  59229. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59230. /**
  59231. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59232. * @returns a new Vector3
  59233. */
  59234. negate(): Vector3;
  59235. /**
  59236. * Multiplies the Vector3 coordinates by the float "scale"
  59237. * @param scale defines the multiplier factor
  59238. * @returns the current updated Vector3
  59239. */
  59240. scaleInPlace(scale: number): Vector3;
  59241. /**
  59242. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59243. * @param scale defines the multiplier factor
  59244. * @returns a new Vector3
  59245. */
  59246. scale(scale: number): Vector3;
  59247. /**
  59248. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59249. * @param scale defines the multiplier factor
  59250. * @param result defines the Vector3 object where to store the result
  59251. * @returns the current Vector3
  59252. */
  59253. scaleToRef(scale: number, result: Vector3): Vector3;
  59254. /**
  59255. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59256. * @param scale defines the scale factor
  59257. * @param result defines the Vector3 object where to store the result
  59258. * @returns the unmodified current Vector3
  59259. */
  59260. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59261. /**
  59262. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59263. * @param otherVector defines the second operand
  59264. * @returns true if both vectors are equals
  59265. */
  59266. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59267. /**
  59268. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59269. * @param otherVector defines the second operand
  59270. * @param epsilon defines the minimal distance to define values as equals
  59271. * @returns true if both vectors are distant less than epsilon
  59272. */
  59273. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59274. /**
  59275. * Returns true if the current Vector3 coordinates equals the given floats
  59276. * @param x defines the x coordinate of the operand
  59277. * @param y defines the y coordinate of the operand
  59278. * @param z defines the z coordinate of the operand
  59279. * @returns true if both vectors are equals
  59280. */
  59281. equalsToFloats(x: number, y: number, z: number): boolean;
  59282. /**
  59283. * Multiplies the current Vector3 coordinates by the given ones
  59284. * @param otherVector defines the second operand
  59285. * @returns the current updated Vector3
  59286. */
  59287. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59288. /**
  59289. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59290. * @param otherVector defines the second operand
  59291. * @returns the new Vector3
  59292. */
  59293. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59294. /**
  59295. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59296. * @param otherVector defines the second operand
  59297. * @param result defines the Vector3 object where to store the result
  59298. * @returns the current Vector3
  59299. */
  59300. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59301. /**
  59302. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59303. * @param x defines the x coordinate of the operand
  59304. * @param y defines the y coordinate of the operand
  59305. * @param z defines the z coordinate of the operand
  59306. * @returns the new Vector3
  59307. */
  59308. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59309. /**
  59310. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59311. * @param otherVector defines the second operand
  59312. * @returns the new Vector3
  59313. */
  59314. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59315. /**
  59316. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59317. * @param otherVector defines the second operand
  59318. * @param result defines the Vector3 object where to store the result
  59319. * @returns the current Vector3
  59320. */
  59321. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59322. /**
  59323. * Divides the current Vector3 coordinates by the given ones.
  59324. * @param otherVector defines the second operand
  59325. * @returns the current updated Vector3
  59326. */
  59327. divideInPlace(otherVector: Vector3): Vector3;
  59328. /**
  59329. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59330. * @param other defines the second operand
  59331. * @returns the current updated Vector3
  59332. */
  59333. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59334. /**
  59335. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59336. * @param other defines the second operand
  59337. * @returns the current updated Vector3
  59338. */
  59339. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59340. /**
  59341. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59342. * @param x defines the x coordinate of the operand
  59343. * @param y defines the y coordinate of the operand
  59344. * @param z defines the z coordinate of the operand
  59345. * @returns the current updated Vector3
  59346. */
  59347. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59348. /**
  59349. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59350. * @param x defines the x coordinate of the operand
  59351. * @param y defines the y coordinate of the operand
  59352. * @param z defines the z coordinate of the operand
  59353. * @returns the current updated Vector3
  59354. */
  59355. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59356. /**
  59357. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59358. * Check if is non uniform within a certain amount of decimal places to account for this
  59359. * @param epsilon the amount the values can differ
  59360. * @returns if the the vector is non uniform to a certain number of decimal places
  59361. */
  59362. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59363. /**
  59364. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59365. */
  59366. readonly isNonUniform: boolean;
  59367. /**
  59368. * Gets a new Vector3 from current Vector3 floored values
  59369. * @returns a new Vector3
  59370. */
  59371. floor(): Vector3;
  59372. /**
  59373. * Gets a new Vector3 from current Vector3 floored values
  59374. * @returns a new Vector3
  59375. */
  59376. fract(): Vector3;
  59377. /**
  59378. * Gets the length of the Vector3
  59379. * @returns the length of the Vecto3
  59380. */
  59381. length(): number;
  59382. /**
  59383. * Gets the squared length of the Vector3
  59384. * @returns squared length of the Vector3
  59385. */
  59386. lengthSquared(): number;
  59387. /**
  59388. * Normalize the current Vector3.
  59389. * Please note that this is an in place operation.
  59390. * @returns the current updated Vector3
  59391. */
  59392. normalize(): Vector3;
  59393. /**
  59394. * Reorders the x y z properties of the vector in place
  59395. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59396. * @returns the current updated vector
  59397. */
  59398. reorderInPlace(order: string): this;
  59399. /**
  59400. * Rotates the vector around 0,0,0 by a quaternion
  59401. * @param quaternion the rotation quaternion
  59402. * @param result vector to store the result
  59403. * @returns the resulting vector
  59404. */
  59405. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59406. /**
  59407. * Rotates a vector around a given point
  59408. * @param quaternion the rotation quaternion
  59409. * @param point the point to rotate around
  59410. * @param result vector to store the result
  59411. * @returns the resulting vector
  59412. */
  59413. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59414. /**
  59415. * Normalize the current Vector3 with the given input length.
  59416. * Please note that this is an in place operation.
  59417. * @param len the length of the vector
  59418. * @returns the current updated Vector3
  59419. */
  59420. normalizeFromLength(len: number): Vector3;
  59421. /**
  59422. * Normalize the current Vector3 to a new vector
  59423. * @returns the new Vector3
  59424. */
  59425. normalizeToNew(): Vector3;
  59426. /**
  59427. * Normalize the current Vector3 to the reference
  59428. * @param reference define the Vector3 to update
  59429. * @returns the updated Vector3
  59430. */
  59431. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59432. /**
  59433. * Creates a new Vector3 copied from the current Vector3
  59434. * @returns the new Vector3
  59435. */
  59436. clone(): Vector3;
  59437. /**
  59438. * Copies the given vector coordinates to the current Vector3 ones
  59439. * @param source defines the source Vector3
  59440. * @returns the current updated Vector3
  59441. */
  59442. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59443. /**
  59444. * Copies the given floats to the current Vector3 coordinates
  59445. * @param x defines the x coordinate of the operand
  59446. * @param y defines the y coordinate of the operand
  59447. * @param z defines the z coordinate of the operand
  59448. * @returns the current updated Vector3
  59449. */
  59450. copyFromFloats(x: number, y: number, z: number): Vector3;
  59451. /**
  59452. * Copies the given floats to the current Vector3 coordinates
  59453. * @param x defines the x coordinate of the operand
  59454. * @param y defines the y coordinate of the operand
  59455. * @param z defines the z coordinate of the operand
  59456. * @returns the current updated Vector3
  59457. */
  59458. set(x: number, y: number, z: number): Vector3;
  59459. /**
  59460. * Copies the given float to the current Vector3 coordinates
  59461. * @param v defines the x, y and z coordinates of the operand
  59462. * @returns the current updated Vector3
  59463. */
  59464. setAll(v: number): Vector3;
  59465. /**
  59466. * Get the clip factor between two vectors
  59467. * @param vector0 defines the first operand
  59468. * @param vector1 defines the second operand
  59469. * @param axis defines the axis to use
  59470. * @param size defines the size along the axis
  59471. * @returns the clip factor
  59472. */
  59473. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59474. /**
  59475. * Get angle between two vectors
  59476. * @param vector0 angle between vector0 and vector1
  59477. * @param vector1 angle between vector0 and vector1
  59478. * @param normal direction of the normal
  59479. * @return the angle between vector0 and vector1
  59480. */
  59481. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59482. /**
  59483. * Returns a new Vector3 set from the index "offset" of the given array
  59484. * @param array defines the source array
  59485. * @param offset defines the offset in the source array
  59486. * @returns the new Vector3
  59487. */
  59488. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59489. /**
  59490. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59491. * This function is deprecated. Use FromArray instead
  59492. * @param array defines the source array
  59493. * @param offset defines the offset in the source array
  59494. * @returns the new Vector3
  59495. */
  59496. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59497. /**
  59498. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59499. * @param array defines the source array
  59500. * @param offset defines the offset in the source array
  59501. * @param result defines the Vector3 where to store the result
  59502. */
  59503. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59504. /**
  59505. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59506. * This function is deprecated. Use FromArrayToRef instead.
  59507. * @param array defines the source array
  59508. * @param offset defines the offset in the source array
  59509. * @param result defines the Vector3 where to store the result
  59510. */
  59511. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59512. /**
  59513. * Sets the given vector "result" with the given floats.
  59514. * @param x defines the x coordinate of the source
  59515. * @param y defines the y coordinate of the source
  59516. * @param z defines the z coordinate of the source
  59517. * @param result defines the Vector3 where to store the result
  59518. */
  59519. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59520. /**
  59521. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59522. * @returns a new empty Vector3
  59523. */
  59524. static Zero(): Vector3;
  59525. /**
  59526. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59527. * @returns a new unit Vector3
  59528. */
  59529. static One(): Vector3;
  59530. /**
  59531. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59532. * @returns a new up Vector3
  59533. */
  59534. static Up(): Vector3;
  59535. /**
  59536. * Gets a up Vector3 that must not be updated
  59537. */
  59538. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59539. /**
  59540. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59541. * @returns a new down Vector3
  59542. */
  59543. static Down(): Vector3;
  59544. /**
  59545. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59546. * @returns a new forward Vector3
  59547. */
  59548. static Forward(): Vector3;
  59549. /**
  59550. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59551. * @returns a new forward Vector3
  59552. */
  59553. static Backward(): Vector3;
  59554. /**
  59555. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59556. * @returns a new right Vector3
  59557. */
  59558. static Right(): Vector3;
  59559. /**
  59560. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59561. * @returns a new left Vector3
  59562. */
  59563. static Left(): Vector3;
  59564. /**
  59565. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59566. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59567. * @param vector defines the Vector3 to transform
  59568. * @param transformation defines the transformation matrix
  59569. * @returns the transformed Vector3
  59570. */
  59571. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59572. /**
  59573. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59574. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59575. * @param vector defines the Vector3 to transform
  59576. * @param transformation defines the transformation matrix
  59577. * @param result defines the Vector3 where to store the result
  59578. */
  59579. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59580. /**
  59581. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59582. * This method computes tranformed coordinates only, not transformed direction vectors
  59583. * @param x define the x coordinate of the source vector
  59584. * @param y define the y coordinate of the source vector
  59585. * @param z define the z coordinate of the source vector
  59586. * @param transformation defines the transformation matrix
  59587. * @param result defines the Vector3 where to store the result
  59588. */
  59589. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59590. /**
  59591. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59592. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59593. * @param vector defines the Vector3 to transform
  59594. * @param transformation defines the transformation matrix
  59595. * @returns the new Vector3
  59596. */
  59597. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59598. /**
  59599. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59600. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59601. * @param vector defines the Vector3 to transform
  59602. * @param transformation defines the transformation matrix
  59603. * @param result defines the Vector3 where to store the result
  59604. */
  59605. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59606. /**
  59607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59608. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59609. * @param x define the x coordinate of the source vector
  59610. * @param y define the y coordinate of the source vector
  59611. * @param z define the z coordinate of the source vector
  59612. * @param transformation defines the transformation matrix
  59613. * @param result defines the Vector3 where to store the result
  59614. */
  59615. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59616. /**
  59617. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59618. * @param value1 defines the first control point
  59619. * @param value2 defines the second control point
  59620. * @param value3 defines the third control point
  59621. * @param value4 defines the fourth control point
  59622. * @param amount defines the amount on the spline to use
  59623. * @returns the new Vector3
  59624. */
  59625. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59626. /**
  59627. * 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"
  59628. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59629. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59630. * @param value defines the current value
  59631. * @param min defines the lower range value
  59632. * @param max defines the upper range value
  59633. * @returns the new Vector3
  59634. */
  59635. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59636. /**
  59637. * 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"
  59638. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59639. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59640. * @param value defines the current value
  59641. * @param min defines the lower range value
  59642. * @param max defines the upper range value
  59643. * @param result defines the Vector3 where to store the result
  59644. */
  59645. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59646. /**
  59647. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59648. * @param value1 defines the first control point
  59649. * @param tangent1 defines the first tangent vector
  59650. * @param value2 defines the second control point
  59651. * @param tangent2 defines the second tangent vector
  59652. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59653. * @returns the new Vector3
  59654. */
  59655. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59656. /**
  59657. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59658. * @param start defines the start value
  59659. * @param end defines the end value
  59660. * @param amount max defines amount between both (between 0 and 1)
  59661. * @returns the new Vector3
  59662. */
  59663. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59664. /**
  59665. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59666. * @param start defines the start value
  59667. * @param end defines the end value
  59668. * @param amount max defines amount between both (between 0 and 1)
  59669. * @param result defines the Vector3 where to store the result
  59670. */
  59671. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59672. /**
  59673. * Returns the dot product (float) between the vectors "left" and "right"
  59674. * @param left defines the left operand
  59675. * @param right defines the right operand
  59676. * @returns the dot product
  59677. */
  59678. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59679. /**
  59680. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59681. * The cross product is then orthogonal to both "left" and "right"
  59682. * @param left defines the left operand
  59683. * @param right defines the right operand
  59684. * @returns the cross product
  59685. */
  59686. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59687. /**
  59688. * Sets the given vector "result" with the cross product of "left" and "right"
  59689. * The cross product is then orthogonal to both "left" and "right"
  59690. * @param left defines the left operand
  59691. * @param right defines the right operand
  59692. * @param result defines the Vector3 where to store the result
  59693. */
  59694. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59695. /**
  59696. * Returns a new Vector3 as the normalization of the given vector
  59697. * @param vector defines the Vector3 to normalize
  59698. * @returns the new Vector3
  59699. */
  59700. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59701. /**
  59702. * Sets the given vector "result" with the normalization of the given first vector
  59703. * @param vector defines the Vector3 to normalize
  59704. * @param result defines the Vector3 where to store the result
  59705. */
  59706. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59707. /**
  59708. * Project a Vector3 onto screen space
  59709. * @param vector defines the Vector3 to project
  59710. * @param world defines the world matrix to use
  59711. * @param transform defines the transform (view x projection) matrix to use
  59712. * @param viewport defines the screen viewport to use
  59713. * @returns the new Vector3
  59714. */
  59715. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59716. /** @hidden */
  59717. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59718. /**
  59719. * Unproject from screen space to object space
  59720. * @param source defines the screen space Vector3 to use
  59721. * @param viewportWidth defines the current width of the viewport
  59722. * @param viewportHeight defines the current height of the viewport
  59723. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59724. * @param transform defines the transform (view x projection) matrix to use
  59725. * @returns the new Vector3
  59726. */
  59727. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59728. /**
  59729. * Unproject from screen space to object space
  59730. * @param source defines the screen space Vector3 to use
  59731. * @param viewportWidth defines the current width of the viewport
  59732. * @param viewportHeight defines the current height of the viewport
  59733. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59734. * @param view defines the view matrix to use
  59735. * @param projection defines the projection matrix to use
  59736. * @returns the new Vector3
  59737. */
  59738. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59739. /**
  59740. * Unproject from screen space to object space
  59741. * @param source defines the screen space Vector3 to use
  59742. * @param viewportWidth defines the current width of the viewport
  59743. * @param viewportHeight defines the current height of the viewport
  59744. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59745. * @param view defines the view matrix to use
  59746. * @param projection defines the projection matrix to use
  59747. * @param result defines the Vector3 where to store the result
  59748. */
  59749. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59750. /**
  59751. * Unproject from screen space to object space
  59752. * @param sourceX defines the screen space x coordinate to use
  59753. * @param sourceY defines the screen space y coordinate to use
  59754. * @param sourceZ defines the screen space z coordinate to use
  59755. * @param viewportWidth defines the current width of the viewport
  59756. * @param viewportHeight defines the current height of the viewport
  59757. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59758. * @param view defines the view matrix to use
  59759. * @param projection defines the projection matrix to use
  59760. * @param result defines the Vector3 where to store the result
  59761. */
  59762. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59763. /**
  59764. * Gets the minimal coordinate values between two Vector3
  59765. * @param left defines the first operand
  59766. * @param right defines the second operand
  59767. * @returns the new Vector3
  59768. */
  59769. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59770. /**
  59771. * Gets the maximal coordinate values between two Vector3
  59772. * @param left defines the first operand
  59773. * @param right defines the second operand
  59774. * @returns the new Vector3
  59775. */
  59776. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59777. /**
  59778. * Returns the distance between the vectors "value1" and "value2"
  59779. * @param value1 defines the first operand
  59780. * @param value2 defines the second operand
  59781. * @returns the distance
  59782. */
  59783. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59784. /**
  59785. * Returns the squared distance between the vectors "value1" and "value2"
  59786. * @param value1 defines the first operand
  59787. * @param value2 defines the second operand
  59788. * @returns the squared distance
  59789. */
  59790. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59791. /**
  59792. * Returns a new Vector3 located at the center between "value1" and "value2"
  59793. * @param value1 defines the first operand
  59794. * @param value2 defines the second operand
  59795. * @returns the new Vector3
  59796. */
  59797. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59798. /**
  59799. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59800. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59801. * to something in order to rotate it from its local system to the given target system
  59802. * Note: axis1, axis2 and axis3 are normalized during this operation
  59803. * @param axis1 defines the first axis
  59804. * @param axis2 defines the second axis
  59805. * @param axis3 defines the third axis
  59806. * @returns a new Vector3
  59807. */
  59808. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59809. /**
  59810. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59811. * @param axis1 defines the first axis
  59812. * @param axis2 defines the second axis
  59813. * @param axis3 defines the third axis
  59814. * @param ref defines the Vector3 where to store the result
  59815. */
  59816. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59817. }
  59818. /**
  59819. * Vector4 class created for EulerAngle class conversion to Quaternion
  59820. */
  59821. export class Vector4 {
  59822. /** x value of the vector */
  59823. x: number;
  59824. /** y value of the vector */
  59825. y: number;
  59826. /** z value of the vector */
  59827. z: number;
  59828. /** w value of the vector */
  59829. w: number;
  59830. /**
  59831. * Creates a Vector4 object from the given floats.
  59832. * @param x x value of the vector
  59833. * @param y y value of the vector
  59834. * @param z z value of the vector
  59835. * @param w w value of the vector
  59836. */
  59837. constructor(
  59838. /** x value of the vector */
  59839. x: number,
  59840. /** y value of the vector */
  59841. y: number,
  59842. /** z value of the vector */
  59843. z: number,
  59844. /** w value of the vector */
  59845. w: number);
  59846. /**
  59847. * Returns the string with the Vector4 coordinates.
  59848. * @returns a string containing all the vector values
  59849. */
  59850. toString(): string;
  59851. /**
  59852. * Returns the string "Vector4".
  59853. * @returns "Vector4"
  59854. */
  59855. getClassName(): string;
  59856. /**
  59857. * Returns the Vector4 hash code.
  59858. * @returns a unique hash code
  59859. */
  59860. getHashCode(): number;
  59861. /**
  59862. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59863. * @returns the resulting array
  59864. */
  59865. asArray(): number[];
  59866. /**
  59867. * Populates the given array from the given index with the Vector4 coordinates.
  59868. * @param array array to populate
  59869. * @param index index of the array to start at (default: 0)
  59870. * @returns the Vector4.
  59871. */
  59872. toArray(array: FloatArray, index?: number): Vector4;
  59873. /**
  59874. * Adds the given vector to the current Vector4.
  59875. * @param otherVector the vector to add
  59876. * @returns the updated Vector4.
  59877. */
  59878. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59879. /**
  59880. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59881. * @param otherVector the vector to add
  59882. * @returns the resulting vector
  59883. */
  59884. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59885. /**
  59886. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59887. * @param otherVector the vector to add
  59888. * @param result the vector to store the result
  59889. * @returns the current Vector4.
  59890. */
  59891. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59892. /**
  59893. * Subtract in place the given vector from the current Vector4.
  59894. * @param otherVector the vector to subtract
  59895. * @returns the updated Vector4.
  59896. */
  59897. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59898. /**
  59899. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59900. * @param otherVector the vector to add
  59901. * @returns the new vector with the result
  59902. */
  59903. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59904. /**
  59905. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59906. * @param otherVector the vector to subtract
  59907. * @param result the vector to store the result
  59908. * @returns the current Vector4.
  59909. */
  59910. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59911. /**
  59912. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59913. */
  59914. /**
  59915. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59916. * @param x value to subtract
  59917. * @param y value to subtract
  59918. * @param z value to subtract
  59919. * @param w value to subtract
  59920. * @returns new vector containing the result
  59921. */
  59922. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59923. /**
  59924. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59925. * @param x value to subtract
  59926. * @param y value to subtract
  59927. * @param z value to subtract
  59928. * @param w value to subtract
  59929. * @param result the vector to store the result in
  59930. * @returns the current Vector4.
  59931. */
  59932. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59933. /**
  59934. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59935. * @returns a new vector with the negated values
  59936. */
  59937. negate(): Vector4;
  59938. /**
  59939. * Multiplies the current Vector4 coordinates by scale (float).
  59940. * @param scale the number to scale with
  59941. * @returns the updated Vector4.
  59942. */
  59943. scaleInPlace(scale: number): Vector4;
  59944. /**
  59945. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59946. * @param scale the number to scale with
  59947. * @returns a new vector with the result
  59948. */
  59949. scale(scale: number): Vector4;
  59950. /**
  59951. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59952. * @param scale the number to scale with
  59953. * @param result a vector to store the result in
  59954. * @returns the current Vector4.
  59955. */
  59956. scaleToRef(scale: number, result: Vector4): Vector4;
  59957. /**
  59958. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59959. * @param scale defines the scale factor
  59960. * @param result defines the Vector4 object where to store the result
  59961. * @returns the unmodified current Vector4
  59962. */
  59963. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59964. /**
  59965. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59966. * @param otherVector the vector to compare against
  59967. * @returns true if they are equal
  59968. */
  59969. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59970. /**
  59971. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59972. * @param otherVector vector to compare against
  59973. * @param epsilon (Default: very small number)
  59974. * @returns true if they are equal
  59975. */
  59976. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59977. /**
  59978. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59979. * @param x x value to compare against
  59980. * @param y y value to compare against
  59981. * @param z z value to compare against
  59982. * @param w w value to compare against
  59983. * @returns true if equal
  59984. */
  59985. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59986. /**
  59987. * Multiplies in place the current Vector4 by the given one.
  59988. * @param otherVector vector to multiple with
  59989. * @returns the updated Vector4.
  59990. */
  59991. multiplyInPlace(otherVector: Vector4): Vector4;
  59992. /**
  59993. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59994. * @param otherVector vector to multiple with
  59995. * @returns resulting new vector
  59996. */
  59997. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59998. /**
  59999. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  60000. * @param otherVector vector to multiple with
  60001. * @param result vector to store the result
  60002. * @returns the current Vector4.
  60003. */
  60004. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60005. /**
  60006. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  60007. * @param x x value multiply with
  60008. * @param y y value multiply with
  60009. * @param z z value multiply with
  60010. * @param w w value multiply with
  60011. * @returns resulting new vector
  60012. */
  60013. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  60014. /**
  60015. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  60016. * @param otherVector vector to devide with
  60017. * @returns resulting new vector
  60018. */
  60019. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  60020. /**
  60021. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  60022. * @param otherVector vector to devide with
  60023. * @param result vector to store the result
  60024. * @returns the current Vector4.
  60025. */
  60026. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60027. /**
  60028. * Divides the current Vector3 coordinates by the given ones.
  60029. * @param otherVector vector to devide with
  60030. * @returns the updated Vector3.
  60031. */
  60032. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60033. /**
  60034. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  60035. * @param other defines the second operand
  60036. * @returns the current updated Vector4
  60037. */
  60038. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60039. /**
  60040. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  60041. * @param other defines the second operand
  60042. * @returns the current updated Vector4
  60043. */
  60044. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60045. /**
  60046. * Gets a new Vector4 from current Vector4 floored values
  60047. * @returns a new Vector4
  60048. */
  60049. floor(): Vector4;
  60050. /**
  60051. * Gets a new Vector4 from current Vector3 floored values
  60052. * @returns a new Vector4
  60053. */
  60054. fract(): Vector4;
  60055. /**
  60056. * Returns the Vector4 length (float).
  60057. * @returns the length
  60058. */
  60059. length(): number;
  60060. /**
  60061. * Returns the Vector4 squared length (float).
  60062. * @returns the length squared
  60063. */
  60064. lengthSquared(): number;
  60065. /**
  60066. * Normalizes in place the Vector4.
  60067. * @returns the updated Vector4.
  60068. */
  60069. normalize(): Vector4;
  60070. /**
  60071. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  60072. * @returns this converted to a new vector3
  60073. */
  60074. toVector3(): Vector3;
  60075. /**
  60076. * Returns a new Vector4 copied from the current one.
  60077. * @returns the new cloned vector
  60078. */
  60079. clone(): Vector4;
  60080. /**
  60081. * Updates the current Vector4 with the given one coordinates.
  60082. * @param source the source vector to copy from
  60083. * @returns the updated Vector4.
  60084. */
  60085. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  60086. /**
  60087. * Updates the current Vector4 coordinates with the given floats.
  60088. * @param x float to copy from
  60089. * @param y float to copy from
  60090. * @param z float to copy from
  60091. * @param w float to copy from
  60092. * @returns the updated Vector4.
  60093. */
  60094. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60095. /**
  60096. * Updates the current Vector4 coordinates with the given floats.
  60097. * @param x float to set from
  60098. * @param y float to set from
  60099. * @param z float to set from
  60100. * @param w float to set from
  60101. * @returns the updated Vector4.
  60102. */
  60103. set(x: number, y: number, z: number, w: number): Vector4;
  60104. /**
  60105. * Copies the given float to the current Vector3 coordinates
  60106. * @param v defines the x, y, z and w coordinates of the operand
  60107. * @returns the current updated Vector3
  60108. */
  60109. setAll(v: number): Vector4;
  60110. /**
  60111. * Returns a new Vector4 set from the starting index of the given array.
  60112. * @param array the array to pull values from
  60113. * @param offset the offset into the array to start at
  60114. * @returns the new vector
  60115. */
  60116. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  60117. /**
  60118. * Updates the given vector "result" from the starting index of the given array.
  60119. * @param array the array to pull values from
  60120. * @param offset the offset into the array to start at
  60121. * @param result the vector to store the result in
  60122. */
  60123. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  60124. /**
  60125. * Updates the given vector "result" from the starting index of the given Float32Array.
  60126. * @param array the array to pull values from
  60127. * @param offset the offset into the array to start at
  60128. * @param result the vector to store the result in
  60129. */
  60130. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  60131. /**
  60132. * Updates the given vector "result" coordinates from the given floats.
  60133. * @param x float to set from
  60134. * @param y float to set from
  60135. * @param z float to set from
  60136. * @param w float to set from
  60137. * @param result the vector to the floats in
  60138. */
  60139. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60140. /**
  60141. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60142. * @returns the new vector
  60143. */
  60144. static Zero(): Vector4;
  60145. /**
  60146. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60147. * @returns the new vector
  60148. */
  60149. static One(): Vector4;
  60150. /**
  60151. * Returns a new normalized Vector4 from the given one.
  60152. * @param vector the vector to normalize
  60153. * @returns the vector
  60154. */
  60155. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60156. /**
  60157. * Updates the given vector "result" from the normalization of the given one.
  60158. * @param vector the vector to normalize
  60159. * @param result the vector to store the result in
  60160. */
  60161. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60162. /**
  60163. * Returns a vector with the minimum values from the left and right vectors
  60164. * @param left left vector to minimize
  60165. * @param right right vector to minimize
  60166. * @returns a new vector with the minimum of the left and right vector values
  60167. */
  60168. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60169. /**
  60170. * Returns a vector with the maximum values from the left and right vectors
  60171. * @param left left vector to maximize
  60172. * @param right right vector to maximize
  60173. * @returns a new vector with the maximum of the left and right vector values
  60174. */
  60175. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60176. /**
  60177. * Returns the distance (float) between the vectors "value1" and "value2".
  60178. * @param value1 value to calulate the distance between
  60179. * @param value2 value to calulate the distance between
  60180. * @return the distance between the two vectors
  60181. */
  60182. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60183. /**
  60184. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60185. * @param value1 value to calulate the distance between
  60186. * @param value2 value to calulate the distance between
  60187. * @return the distance between the two vectors squared
  60188. */
  60189. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60190. /**
  60191. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60192. * @param value1 value to calulate the center between
  60193. * @param value2 value to calulate the center between
  60194. * @return the center between the two vectors
  60195. */
  60196. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60197. /**
  60198. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60199. * This methods computes transformed normalized direction vectors only.
  60200. * @param vector the vector to transform
  60201. * @param transformation the transformation matrix to apply
  60202. * @returns the new vector
  60203. */
  60204. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60205. /**
  60206. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60207. * This methods computes transformed normalized direction vectors only.
  60208. * @param vector the vector to transform
  60209. * @param transformation the transformation matrix to apply
  60210. * @param result the vector to store the result in
  60211. */
  60212. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60213. /**
  60214. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60215. * This methods computes transformed normalized direction vectors only.
  60216. * @param x value to transform
  60217. * @param y value to transform
  60218. * @param z value to transform
  60219. * @param w value to transform
  60220. * @param transformation the transformation matrix to apply
  60221. * @param result the vector to store the results in
  60222. */
  60223. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60224. /**
  60225. * Creates a new Vector4 from a Vector3
  60226. * @param source defines the source data
  60227. * @param w defines the 4th component (default is 0)
  60228. * @returns a new Vector4
  60229. */
  60230. static FromVector3(source: Vector3, w?: number): Vector4;
  60231. }
  60232. /**
  60233. * Interface for the size containing width and height
  60234. */
  60235. export interface ISize {
  60236. /**
  60237. * Width
  60238. */
  60239. width: number;
  60240. /**
  60241. * Heighht
  60242. */
  60243. height: number;
  60244. }
  60245. /**
  60246. * Size containing widht and height
  60247. */
  60248. export class Size implements ISize {
  60249. /**
  60250. * Width
  60251. */
  60252. width: number;
  60253. /**
  60254. * Height
  60255. */
  60256. height: number;
  60257. /**
  60258. * Creates a Size object from the given width and height (floats).
  60259. * @param width width of the new size
  60260. * @param height height of the new size
  60261. */
  60262. constructor(width: number, height: number);
  60263. /**
  60264. * Returns a string with the Size width and height
  60265. * @returns a string with the Size width and height
  60266. */
  60267. toString(): string;
  60268. /**
  60269. * "Size"
  60270. * @returns the string "Size"
  60271. */
  60272. getClassName(): string;
  60273. /**
  60274. * Returns the Size hash code.
  60275. * @returns a hash code for a unique width and height
  60276. */
  60277. getHashCode(): number;
  60278. /**
  60279. * Updates the current size from the given one.
  60280. * @param src the given size
  60281. */
  60282. copyFrom(src: Size): void;
  60283. /**
  60284. * Updates in place the current Size from the given floats.
  60285. * @param width width of the new size
  60286. * @param height height of the new size
  60287. * @returns the updated Size.
  60288. */
  60289. copyFromFloats(width: number, height: number): Size;
  60290. /**
  60291. * Updates in place the current Size from the given floats.
  60292. * @param width width to set
  60293. * @param height height to set
  60294. * @returns the updated Size.
  60295. */
  60296. set(width: number, height: number): Size;
  60297. /**
  60298. * Multiplies the width and height by numbers
  60299. * @param w factor to multiple the width by
  60300. * @param h factor to multiple the height by
  60301. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60302. */
  60303. multiplyByFloats(w: number, h: number): Size;
  60304. /**
  60305. * Clones the size
  60306. * @returns a new Size copied from the given one.
  60307. */
  60308. clone(): Size;
  60309. /**
  60310. * True if the current Size and the given one width and height are strictly equal.
  60311. * @param other the other size to compare against
  60312. * @returns True if the current Size and the given one width and height are strictly equal.
  60313. */
  60314. equals(other: Size): boolean;
  60315. /**
  60316. * The surface of the Size : width * height (float).
  60317. */
  60318. readonly surface: number;
  60319. /**
  60320. * Create a new size of zero
  60321. * @returns a new Size set to (0.0, 0.0)
  60322. */
  60323. static Zero(): Size;
  60324. /**
  60325. * Sums the width and height of two sizes
  60326. * @param otherSize size to add to this size
  60327. * @returns a new Size set as the addition result of the current Size and the given one.
  60328. */
  60329. add(otherSize: Size): Size;
  60330. /**
  60331. * Subtracts the width and height of two
  60332. * @param otherSize size to subtract to this size
  60333. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60334. */
  60335. subtract(otherSize: Size): Size;
  60336. /**
  60337. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60338. * @param start starting size to lerp between
  60339. * @param end end size to lerp between
  60340. * @param amount amount to lerp between the start and end values
  60341. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60342. */
  60343. static Lerp(start: Size, end: Size, amount: number): Size;
  60344. }
  60345. /**
  60346. * Class used to store quaternion data
  60347. * @see https://en.wikipedia.org/wiki/Quaternion
  60348. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60349. */
  60350. export class Quaternion {
  60351. /** defines the first component (0 by default) */
  60352. x: number;
  60353. /** defines the second component (0 by default) */
  60354. y: number;
  60355. /** defines the third component (0 by default) */
  60356. z: number;
  60357. /** defines the fourth component (1.0 by default) */
  60358. w: number;
  60359. /**
  60360. * Creates a new Quaternion from the given floats
  60361. * @param x defines the first component (0 by default)
  60362. * @param y defines the second component (0 by default)
  60363. * @param z defines the third component (0 by default)
  60364. * @param w defines the fourth component (1.0 by default)
  60365. */
  60366. constructor(
  60367. /** defines the first component (0 by default) */
  60368. x?: number,
  60369. /** defines the second component (0 by default) */
  60370. y?: number,
  60371. /** defines the third component (0 by default) */
  60372. z?: number,
  60373. /** defines the fourth component (1.0 by default) */
  60374. w?: number);
  60375. /**
  60376. * Gets a string representation for the current quaternion
  60377. * @returns a string with the Quaternion coordinates
  60378. */
  60379. toString(): string;
  60380. /**
  60381. * Gets the class name of the quaternion
  60382. * @returns the string "Quaternion"
  60383. */
  60384. getClassName(): string;
  60385. /**
  60386. * Gets a hash code for this quaternion
  60387. * @returns the quaternion hash code
  60388. */
  60389. getHashCode(): number;
  60390. /**
  60391. * Copy the quaternion to an array
  60392. * @returns a new array populated with 4 elements from the quaternion coordinates
  60393. */
  60394. asArray(): number[];
  60395. /**
  60396. * Check if two quaternions are equals
  60397. * @param otherQuaternion defines the second operand
  60398. * @return true if the current quaternion and the given one coordinates are strictly equals
  60399. */
  60400. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60401. /**
  60402. * Clone the current quaternion
  60403. * @returns a new quaternion copied from the current one
  60404. */
  60405. clone(): Quaternion;
  60406. /**
  60407. * Copy a quaternion to the current one
  60408. * @param other defines the other quaternion
  60409. * @returns the updated current quaternion
  60410. */
  60411. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60412. /**
  60413. * Updates the current quaternion with the given float coordinates
  60414. * @param x defines the x coordinate
  60415. * @param y defines the y coordinate
  60416. * @param z defines the z coordinate
  60417. * @param w defines the w coordinate
  60418. * @returns the updated current quaternion
  60419. */
  60420. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60421. /**
  60422. * Updates the current quaternion from the given float coordinates
  60423. * @param x defines the x coordinate
  60424. * @param y defines the y coordinate
  60425. * @param z defines the z coordinate
  60426. * @param w defines the w coordinate
  60427. * @returns the updated current quaternion
  60428. */
  60429. set(x: number, y: number, z: number, w: number): Quaternion;
  60430. /**
  60431. * Adds two quaternions
  60432. * @param other defines the second operand
  60433. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60434. */
  60435. add(other: DeepImmutable<Quaternion>): Quaternion;
  60436. /**
  60437. * Add a quaternion to the current one
  60438. * @param other defines the quaternion to add
  60439. * @returns the current quaternion
  60440. */
  60441. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60442. /**
  60443. * Subtract two quaternions
  60444. * @param other defines the second operand
  60445. * @returns a new quaternion as the subtraction result of the given one from the current one
  60446. */
  60447. subtract(other: Quaternion): Quaternion;
  60448. /**
  60449. * Multiplies the current quaternion by a scale factor
  60450. * @param value defines the scale factor
  60451. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60452. */
  60453. scale(value: number): Quaternion;
  60454. /**
  60455. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60456. * @param scale defines the scale factor
  60457. * @param result defines the Quaternion object where to store the result
  60458. * @returns the unmodified current quaternion
  60459. */
  60460. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60461. /**
  60462. * Multiplies in place the current quaternion by a scale factor
  60463. * @param value defines the scale factor
  60464. * @returns the current modified quaternion
  60465. */
  60466. scaleInPlace(value: number): Quaternion;
  60467. /**
  60468. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60469. * @param scale defines the scale factor
  60470. * @param result defines the Quaternion object where to store the result
  60471. * @returns the unmodified current quaternion
  60472. */
  60473. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60474. /**
  60475. * Multiplies two quaternions
  60476. * @param q1 defines the second operand
  60477. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60478. */
  60479. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60480. /**
  60481. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60482. * @param q1 defines the second operand
  60483. * @param result defines the target quaternion
  60484. * @returns the current quaternion
  60485. */
  60486. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60487. /**
  60488. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60489. * @param q1 defines the second operand
  60490. * @returns the currentupdated quaternion
  60491. */
  60492. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60493. /**
  60494. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60495. * @param ref defines the target quaternion
  60496. * @returns the current quaternion
  60497. */
  60498. conjugateToRef(ref: Quaternion): Quaternion;
  60499. /**
  60500. * Conjugates in place (1-q) the current quaternion
  60501. * @returns the current updated quaternion
  60502. */
  60503. conjugateInPlace(): Quaternion;
  60504. /**
  60505. * Conjugates in place (1-q) the current quaternion
  60506. * @returns a new quaternion
  60507. */
  60508. conjugate(): Quaternion;
  60509. /**
  60510. * Gets length of current quaternion
  60511. * @returns the quaternion length (float)
  60512. */
  60513. length(): number;
  60514. /**
  60515. * Normalize in place the current quaternion
  60516. * @returns the current updated quaternion
  60517. */
  60518. normalize(): Quaternion;
  60519. /**
  60520. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60521. * @param order is a reserved parameter and is ignore for now
  60522. * @returns a new Vector3 containing the Euler angles
  60523. */
  60524. toEulerAngles(order?: string): Vector3;
  60525. /**
  60526. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60527. * @param result defines the vector which will be filled with the Euler angles
  60528. * @param order is a reserved parameter and is ignore for now
  60529. * @returns the current unchanged quaternion
  60530. */
  60531. toEulerAnglesToRef(result: Vector3): Quaternion;
  60532. /**
  60533. * Updates the given rotation matrix with the current quaternion values
  60534. * @param result defines the target matrix
  60535. * @returns the current unchanged quaternion
  60536. */
  60537. toRotationMatrix(result: Matrix): Quaternion;
  60538. /**
  60539. * Updates the current quaternion from the given rotation matrix values
  60540. * @param matrix defines the source matrix
  60541. * @returns the current updated quaternion
  60542. */
  60543. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60544. /**
  60545. * Creates a new quaternion from a rotation matrix
  60546. * @param matrix defines the source matrix
  60547. * @returns a new quaternion created from the given rotation matrix values
  60548. */
  60549. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60550. /**
  60551. * Updates the given quaternion with the given rotation matrix values
  60552. * @param matrix defines the source matrix
  60553. * @param result defines the target quaternion
  60554. */
  60555. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60556. /**
  60557. * Returns the dot product (float) between the quaternions "left" and "right"
  60558. * @param left defines the left operand
  60559. * @param right defines the right operand
  60560. * @returns the dot product
  60561. */
  60562. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60563. /**
  60564. * Checks if the two quaternions are close to each other
  60565. * @param quat0 defines the first quaternion to check
  60566. * @param quat1 defines the second quaternion to check
  60567. * @returns true if the two quaternions are close to each other
  60568. */
  60569. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60570. /**
  60571. * Creates an empty quaternion
  60572. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60573. */
  60574. static Zero(): Quaternion;
  60575. /**
  60576. * Inverse a given quaternion
  60577. * @param q defines the source quaternion
  60578. * @returns a new quaternion as the inverted current quaternion
  60579. */
  60580. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60581. /**
  60582. * Inverse a given quaternion
  60583. * @param q defines the source quaternion
  60584. * @param result the quaternion the result will be stored in
  60585. * @returns the result quaternion
  60586. */
  60587. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60588. /**
  60589. * Creates an identity quaternion
  60590. * @returns the identity quaternion
  60591. */
  60592. static Identity(): Quaternion;
  60593. /**
  60594. * Gets a boolean indicating if the given quaternion is identity
  60595. * @param quaternion defines the quaternion to check
  60596. * @returns true if the quaternion is identity
  60597. */
  60598. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60599. /**
  60600. * Creates a quaternion from a rotation around an axis
  60601. * @param axis defines the axis to use
  60602. * @param angle defines the angle to use
  60603. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60604. */
  60605. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60606. /**
  60607. * Creates a rotation around an axis and stores it into the given quaternion
  60608. * @param axis defines the axis to use
  60609. * @param angle defines the angle to use
  60610. * @param result defines the target quaternion
  60611. * @returns the target quaternion
  60612. */
  60613. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60614. /**
  60615. * Creates a new quaternion from data stored into an array
  60616. * @param array defines the data source
  60617. * @param offset defines the offset in the source array where the data starts
  60618. * @returns a new quaternion
  60619. */
  60620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60621. /**
  60622. * Create a quaternion from Euler rotation angles
  60623. * @param x Pitch
  60624. * @param y Yaw
  60625. * @param z Roll
  60626. * @returns the new Quaternion
  60627. */
  60628. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60629. /**
  60630. * Updates a quaternion from Euler rotation angles
  60631. * @param x Pitch
  60632. * @param y Yaw
  60633. * @param z Roll
  60634. * @param result the quaternion to store the result
  60635. * @returns the updated quaternion
  60636. */
  60637. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60638. /**
  60639. * Create a quaternion from Euler rotation vector
  60640. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60641. * @returns the new Quaternion
  60642. */
  60643. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60644. /**
  60645. * Updates a quaternion from Euler rotation vector
  60646. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60647. * @param result the quaternion to store the result
  60648. * @returns the updated quaternion
  60649. */
  60650. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60651. /**
  60652. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60653. * @param yaw defines the rotation around Y axis
  60654. * @param pitch defines the rotation around X axis
  60655. * @param roll defines the rotation around Z axis
  60656. * @returns the new quaternion
  60657. */
  60658. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60659. /**
  60660. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60661. * @param yaw defines the rotation around Y axis
  60662. * @param pitch defines the rotation around X axis
  60663. * @param roll defines the rotation around Z axis
  60664. * @param result defines the target quaternion
  60665. */
  60666. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60667. /**
  60668. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60669. * @param alpha defines the rotation around first axis
  60670. * @param beta defines the rotation around second axis
  60671. * @param gamma defines the rotation around third axis
  60672. * @returns the new quaternion
  60673. */
  60674. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60675. /**
  60676. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60677. * @param alpha defines the rotation around first axis
  60678. * @param beta defines the rotation around second axis
  60679. * @param gamma defines the rotation around third axis
  60680. * @param result defines the target quaternion
  60681. */
  60682. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60683. /**
  60684. * 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)
  60685. * @param axis1 defines the first axis
  60686. * @param axis2 defines the second axis
  60687. * @param axis3 defines the third axis
  60688. * @returns the new quaternion
  60689. */
  60690. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60691. /**
  60692. * 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
  60693. * @param axis1 defines the first axis
  60694. * @param axis2 defines the second axis
  60695. * @param axis3 defines the third axis
  60696. * @param ref defines the target quaternion
  60697. */
  60698. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60699. /**
  60700. * Interpolates between two quaternions
  60701. * @param left defines first quaternion
  60702. * @param right defines second quaternion
  60703. * @param amount defines the gradient to use
  60704. * @returns the new interpolated quaternion
  60705. */
  60706. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60707. /**
  60708. * Interpolates between two quaternions and stores it into a target quaternion
  60709. * @param left defines first quaternion
  60710. * @param right defines second quaternion
  60711. * @param amount defines the gradient to use
  60712. * @param result defines the target quaternion
  60713. */
  60714. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60715. /**
  60716. * Interpolate between two quaternions using Hermite interpolation
  60717. * @param value1 defines first quaternion
  60718. * @param tangent1 defines the incoming tangent
  60719. * @param value2 defines second quaternion
  60720. * @param tangent2 defines the outgoing tangent
  60721. * @param amount defines the target quaternion
  60722. * @returns the new interpolated quaternion
  60723. */
  60724. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60725. }
  60726. /**
  60727. * Class used to store matrix data (4x4)
  60728. */
  60729. export class Matrix {
  60730. private static _updateFlagSeed;
  60731. private static _identityReadOnly;
  60732. private _isIdentity;
  60733. private _isIdentityDirty;
  60734. private _isIdentity3x2;
  60735. private _isIdentity3x2Dirty;
  60736. /**
  60737. * Gets the update flag of the matrix which is an unique number for the matrix.
  60738. * It will be incremented every time the matrix data change.
  60739. * You can use it to speed the comparison between two versions of the same matrix.
  60740. */
  60741. updateFlag: number;
  60742. private readonly _m;
  60743. /**
  60744. * Gets the internal data of the matrix
  60745. */
  60746. readonly m: DeepImmutable<Float32Array>;
  60747. /** @hidden */
  60748. _markAsUpdated(): void;
  60749. /** @hidden */
  60750. private _updateIdentityStatus;
  60751. /**
  60752. * Creates an empty matrix (filled with zeros)
  60753. */
  60754. constructor();
  60755. /**
  60756. * Check if the current matrix is identity
  60757. * @returns true is the matrix is the identity matrix
  60758. */
  60759. isIdentity(): boolean;
  60760. /**
  60761. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60762. * @returns true is the matrix is the identity matrix
  60763. */
  60764. isIdentityAs3x2(): boolean;
  60765. /**
  60766. * Gets the determinant of the matrix
  60767. * @returns the matrix determinant
  60768. */
  60769. determinant(): number;
  60770. /**
  60771. * Returns the matrix as a Float32Array
  60772. * @returns the matrix underlying array
  60773. */
  60774. toArray(): DeepImmutable<Float32Array>;
  60775. /**
  60776. * Returns the matrix as a Float32Array
  60777. * @returns the matrix underlying array.
  60778. */
  60779. asArray(): DeepImmutable<Float32Array>;
  60780. /**
  60781. * Inverts the current matrix in place
  60782. * @returns the current inverted matrix
  60783. */
  60784. invert(): Matrix;
  60785. /**
  60786. * Sets all the matrix elements to zero
  60787. * @returns the current matrix
  60788. */
  60789. reset(): Matrix;
  60790. /**
  60791. * Adds the current matrix with a second one
  60792. * @param other defines the matrix to add
  60793. * @returns a new matrix as the addition of the current matrix and the given one
  60794. */
  60795. add(other: DeepImmutable<Matrix>): Matrix;
  60796. /**
  60797. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60798. * @param other defines the matrix to add
  60799. * @param result defines the target matrix
  60800. * @returns the current matrix
  60801. */
  60802. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60803. /**
  60804. * Adds in place the given matrix to the current matrix
  60805. * @param other defines the second operand
  60806. * @returns the current updated matrix
  60807. */
  60808. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60809. /**
  60810. * Sets the given matrix to the current inverted Matrix
  60811. * @param other defines the target matrix
  60812. * @returns the unmodified current matrix
  60813. */
  60814. invertToRef(other: Matrix): Matrix;
  60815. /**
  60816. * add a value at the specified position in the current Matrix
  60817. * @param index the index of the value within the matrix. between 0 and 15.
  60818. * @param value the value to be added
  60819. * @returns the current updated matrix
  60820. */
  60821. addAtIndex(index: number, value: number): Matrix;
  60822. /**
  60823. * mutiply the specified position in the current Matrix by a value
  60824. * @param index the index of the value within the matrix. between 0 and 15.
  60825. * @param value the value to be added
  60826. * @returns the current updated matrix
  60827. */
  60828. multiplyAtIndex(index: number, value: number): Matrix;
  60829. /**
  60830. * Inserts the translation vector (using 3 floats) in the current matrix
  60831. * @param x defines the 1st component of the translation
  60832. * @param y defines the 2nd component of the translation
  60833. * @param z defines the 3rd component of the translation
  60834. * @returns the current updated matrix
  60835. */
  60836. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60837. /**
  60838. * Inserts the translation vector in the current matrix
  60839. * @param vector3 defines the translation to insert
  60840. * @returns the current updated matrix
  60841. */
  60842. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60843. /**
  60844. * Gets the translation value of the current matrix
  60845. * @returns a new Vector3 as the extracted translation from the matrix
  60846. */
  60847. getTranslation(): Vector3;
  60848. /**
  60849. * Fill a Vector3 with the extracted translation from the matrix
  60850. * @param result defines the Vector3 where to store the translation
  60851. * @returns the current matrix
  60852. */
  60853. getTranslationToRef(result: Vector3): Matrix;
  60854. /**
  60855. * Remove rotation and scaling part from the matrix
  60856. * @returns the updated matrix
  60857. */
  60858. removeRotationAndScaling(): Matrix;
  60859. /**
  60860. * Multiply two matrices
  60861. * @param other defines the second operand
  60862. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60863. */
  60864. multiply(other: DeepImmutable<Matrix>): Matrix;
  60865. /**
  60866. * Copy the current matrix from the given one
  60867. * @param other defines the source matrix
  60868. * @returns the current updated matrix
  60869. */
  60870. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60871. /**
  60872. * Populates the given array from the starting index with the current matrix values
  60873. * @param array defines the target array
  60874. * @param offset defines the offset in the target array where to start storing values
  60875. * @returns the current matrix
  60876. */
  60877. copyToArray(array: Float32Array, offset?: number): Matrix;
  60878. /**
  60879. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60880. * @param other defines the second operand
  60881. * @param result defines the matrix where to store the multiplication
  60882. * @returns the current matrix
  60883. */
  60884. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60885. /**
  60886. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60887. * @param other defines the second operand
  60888. * @param result defines the array where to store the multiplication
  60889. * @param offset defines the offset in the target array where to start storing values
  60890. * @returns the current matrix
  60891. */
  60892. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60893. /**
  60894. * Check equality between this matrix and a second one
  60895. * @param value defines the second matrix to compare
  60896. * @returns true is the current matrix and the given one values are strictly equal
  60897. */
  60898. equals(value: DeepImmutable<Matrix>): boolean;
  60899. /**
  60900. * Clone the current matrix
  60901. * @returns a new matrix from the current matrix
  60902. */
  60903. clone(): Matrix;
  60904. /**
  60905. * Returns the name of the current matrix class
  60906. * @returns the string "Matrix"
  60907. */
  60908. getClassName(): string;
  60909. /**
  60910. * Gets the hash code of the current matrix
  60911. * @returns the hash code
  60912. */
  60913. getHashCode(): number;
  60914. /**
  60915. * Decomposes the current Matrix into a translation, rotation and scaling components
  60916. * @param scale defines the scale vector3 given as a reference to update
  60917. * @param rotation defines the rotation quaternion given as a reference to update
  60918. * @param translation defines the translation vector3 given as a reference to update
  60919. * @returns true if operation was successful
  60920. */
  60921. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60922. /**
  60923. * Gets specific row of the matrix
  60924. * @param index defines the number of the row to get
  60925. * @returns the index-th row of the current matrix as a new Vector4
  60926. */
  60927. getRow(index: number): Nullable<Vector4>;
  60928. /**
  60929. * Sets the index-th row of the current matrix to the vector4 values
  60930. * @param index defines the number of the row to set
  60931. * @param row defines the target vector4
  60932. * @returns the updated current matrix
  60933. */
  60934. setRow(index: number, row: Vector4): Matrix;
  60935. /**
  60936. * Compute the transpose of the matrix
  60937. * @returns the new transposed matrix
  60938. */
  60939. transpose(): Matrix;
  60940. /**
  60941. * Compute the transpose of the matrix and store it in a given matrix
  60942. * @param result defines the target matrix
  60943. * @returns the current matrix
  60944. */
  60945. transposeToRef(result: Matrix): Matrix;
  60946. /**
  60947. * Sets the index-th row of the current matrix with the given 4 x float values
  60948. * @param index defines the row index
  60949. * @param x defines the x component to set
  60950. * @param y defines the y component to set
  60951. * @param z defines the z component to set
  60952. * @param w defines the w component to set
  60953. * @returns the updated current matrix
  60954. */
  60955. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60956. /**
  60957. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60958. * @param scale defines the scale factor
  60959. * @returns a new matrix
  60960. */
  60961. scale(scale: number): Matrix;
  60962. /**
  60963. * Scale the current matrix values by a factor to a given result matrix
  60964. * @param scale defines the scale factor
  60965. * @param result defines the matrix to store the result
  60966. * @returns the current matrix
  60967. */
  60968. scaleToRef(scale: number, result: Matrix): Matrix;
  60969. /**
  60970. * Scale the current matrix values by a factor and add the result to a given matrix
  60971. * @param scale defines the scale factor
  60972. * @param result defines the Matrix to store the result
  60973. * @returns the current matrix
  60974. */
  60975. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60976. /**
  60977. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60978. * @param ref matrix to store the result
  60979. */
  60980. toNormalMatrix(ref: Matrix): void;
  60981. /**
  60982. * Gets only rotation part of the current matrix
  60983. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60984. */
  60985. getRotationMatrix(): Matrix;
  60986. /**
  60987. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60988. * @param result defines the target matrix to store data to
  60989. * @returns the current matrix
  60990. */
  60991. getRotationMatrixToRef(result: Matrix): Matrix;
  60992. /**
  60993. * Toggles model matrix from being right handed to left handed in place and vice versa
  60994. */
  60995. toggleModelMatrixHandInPlace(): void;
  60996. /**
  60997. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60998. */
  60999. toggleProjectionMatrixHandInPlace(): void;
  61000. /**
  61001. * Creates a matrix from an array
  61002. * @param array defines the source array
  61003. * @param offset defines an offset in the source array
  61004. * @returns a new Matrix set from the starting index of the given array
  61005. */
  61006. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  61007. /**
  61008. * Copy the content of an array into a given matrix
  61009. * @param array defines the source array
  61010. * @param offset defines an offset in the source array
  61011. * @param result defines the target matrix
  61012. */
  61013. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  61014. /**
  61015. * Stores an array into a matrix after having multiplied each component by a given factor
  61016. * @param array defines the source array
  61017. * @param offset defines the offset in the source array
  61018. * @param scale defines the scaling factor
  61019. * @param result defines the target matrix
  61020. */
  61021. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  61022. /**
  61023. * Gets an identity matrix that must not be updated
  61024. */
  61025. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  61026. /**
  61027. * Stores a list of values (16) inside a given matrix
  61028. * @param initialM11 defines 1st value of 1st row
  61029. * @param initialM12 defines 2nd value of 1st row
  61030. * @param initialM13 defines 3rd value of 1st row
  61031. * @param initialM14 defines 4th value of 1st row
  61032. * @param initialM21 defines 1st value of 2nd row
  61033. * @param initialM22 defines 2nd value of 2nd row
  61034. * @param initialM23 defines 3rd value of 2nd row
  61035. * @param initialM24 defines 4th value of 2nd row
  61036. * @param initialM31 defines 1st value of 3rd row
  61037. * @param initialM32 defines 2nd value of 3rd row
  61038. * @param initialM33 defines 3rd value of 3rd row
  61039. * @param initialM34 defines 4th value of 3rd row
  61040. * @param initialM41 defines 1st value of 4th row
  61041. * @param initialM42 defines 2nd value of 4th row
  61042. * @param initialM43 defines 3rd value of 4th row
  61043. * @param initialM44 defines 4th value of 4th row
  61044. * @param result defines the target matrix
  61045. */
  61046. 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;
  61047. /**
  61048. * Creates new matrix from a list of values (16)
  61049. * @param initialM11 defines 1st value of 1st row
  61050. * @param initialM12 defines 2nd value of 1st row
  61051. * @param initialM13 defines 3rd value of 1st row
  61052. * @param initialM14 defines 4th value of 1st row
  61053. * @param initialM21 defines 1st value of 2nd row
  61054. * @param initialM22 defines 2nd value of 2nd row
  61055. * @param initialM23 defines 3rd value of 2nd row
  61056. * @param initialM24 defines 4th value of 2nd row
  61057. * @param initialM31 defines 1st value of 3rd row
  61058. * @param initialM32 defines 2nd value of 3rd row
  61059. * @param initialM33 defines 3rd value of 3rd row
  61060. * @param initialM34 defines 4th value of 3rd row
  61061. * @param initialM41 defines 1st value of 4th row
  61062. * @param initialM42 defines 2nd value of 4th row
  61063. * @param initialM43 defines 3rd value of 4th row
  61064. * @param initialM44 defines 4th value of 4th row
  61065. * @returns the new matrix
  61066. */
  61067. 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;
  61068. /**
  61069. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61070. * @param scale defines the scale vector3
  61071. * @param rotation defines the rotation quaternion
  61072. * @param translation defines the translation vector3
  61073. * @returns a new matrix
  61074. */
  61075. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  61076. /**
  61077. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61078. * @param scale defines the scale vector3
  61079. * @param rotation defines the rotation quaternion
  61080. * @param translation defines the translation vector3
  61081. * @param result defines the target matrix
  61082. */
  61083. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  61084. /**
  61085. * Creates a new identity matrix
  61086. * @returns a new identity matrix
  61087. */
  61088. static Identity(): Matrix;
  61089. /**
  61090. * Creates a new identity matrix and stores the result in a given matrix
  61091. * @param result defines the target matrix
  61092. */
  61093. static IdentityToRef(result: Matrix): void;
  61094. /**
  61095. * Creates a new zero matrix
  61096. * @returns a new zero matrix
  61097. */
  61098. static Zero(): Matrix;
  61099. /**
  61100. * Creates a new rotation matrix for "angle" radians around the X axis
  61101. * @param angle defines the angle (in radians) to use
  61102. * @return the new matrix
  61103. */
  61104. static RotationX(angle: number): Matrix;
  61105. /**
  61106. * Creates a new matrix as the invert of a given matrix
  61107. * @param source defines the source matrix
  61108. * @returns the new matrix
  61109. */
  61110. static Invert(source: DeepImmutable<Matrix>): Matrix;
  61111. /**
  61112. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  61113. * @param angle defines the angle (in radians) to use
  61114. * @param result defines the target matrix
  61115. */
  61116. static RotationXToRef(angle: number, result: Matrix): void;
  61117. /**
  61118. * Creates a new rotation matrix for "angle" radians around the Y axis
  61119. * @param angle defines the angle (in radians) to use
  61120. * @return the new matrix
  61121. */
  61122. static RotationY(angle: number): Matrix;
  61123. /**
  61124. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  61125. * @param angle defines the angle (in radians) to use
  61126. * @param result defines the target matrix
  61127. */
  61128. static RotationYToRef(angle: number, result: Matrix): void;
  61129. /**
  61130. * Creates a new rotation matrix for "angle" radians around the Z axis
  61131. * @param angle defines the angle (in radians) to use
  61132. * @return the new matrix
  61133. */
  61134. static RotationZ(angle: number): Matrix;
  61135. /**
  61136. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61137. * @param angle defines the angle (in radians) to use
  61138. * @param result defines the target matrix
  61139. */
  61140. static RotationZToRef(angle: number, result: Matrix): void;
  61141. /**
  61142. * Creates a new rotation matrix for "angle" radians around the given axis
  61143. * @param axis defines the axis to use
  61144. * @param angle defines the angle (in radians) to use
  61145. * @return the new matrix
  61146. */
  61147. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61148. /**
  61149. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61150. * @param axis defines the axis to use
  61151. * @param angle defines the angle (in radians) to use
  61152. * @param result defines the target matrix
  61153. */
  61154. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61155. /**
  61156. * Creates a rotation matrix
  61157. * @param yaw defines the yaw angle in radians (Y axis)
  61158. * @param pitch defines the pitch angle in radians (X axis)
  61159. * @param roll defines the roll angle in radians (X axis)
  61160. * @returns the new rotation matrix
  61161. */
  61162. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61163. /**
  61164. * Creates a rotation matrix and stores it in a given matrix
  61165. * @param yaw defines the yaw angle in radians (Y axis)
  61166. * @param pitch defines the pitch angle in radians (X axis)
  61167. * @param roll defines the roll angle in radians (X axis)
  61168. * @param result defines the target matrix
  61169. */
  61170. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61171. /**
  61172. * Creates a scaling matrix
  61173. * @param x defines the scale factor on X axis
  61174. * @param y defines the scale factor on Y axis
  61175. * @param z defines the scale factor on Z axis
  61176. * @returns the new matrix
  61177. */
  61178. static Scaling(x: number, y: number, z: number): Matrix;
  61179. /**
  61180. * Creates a scaling matrix and stores it in a given matrix
  61181. * @param x defines the scale factor on X axis
  61182. * @param y defines the scale factor on Y axis
  61183. * @param z defines the scale factor on Z axis
  61184. * @param result defines the target matrix
  61185. */
  61186. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61187. /**
  61188. * Creates a translation matrix
  61189. * @param x defines the translation on X axis
  61190. * @param y defines the translation on Y axis
  61191. * @param z defines the translationon Z axis
  61192. * @returns the new matrix
  61193. */
  61194. static Translation(x: number, y: number, z: number): Matrix;
  61195. /**
  61196. * Creates a translation matrix and stores it in a given matrix
  61197. * @param x defines the translation on X axis
  61198. * @param y defines the translation on Y axis
  61199. * @param z defines the translationon Z axis
  61200. * @param result defines the target matrix
  61201. */
  61202. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61203. /**
  61204. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61205. * @param startValue defines the start value
  61206. * @param endValue defines the end value
  61207. * @param gradient defines the gradient factor
  61208. * @returns the new matrix
  61209. */
  61210. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61211. /**
  61212. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61213. * @param startValue defines the start value
  61214. * @param endValue defines the end value
  61215. * @param gradient defines the gradient factor
  61216. * @param result defines the Matrix object where to store data
  61217. */
  61218. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61219. /**
  61220. * Builds a new matrix whose values are computed by:
  61221. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61222. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61223. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61224. * @param startValue defines the first matrix
  61225. * @param endValue defines the second matrix
  61226. * @param gradient defines the gradient between the two matrices
  61227. * @returns the new matrix
  61228. */
  61229. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61230. /**
  61231. * Update a matrix to values which are computed by:
  61232. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61233. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61234. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61235. * @param startValue defines the first matrix
  61236. * @param endValue defines the second matrix
  61237. * @param gradient defines the gradient between the two matrices
  61238. * @param result defines the target matrix
  61239. */
  61240. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61241. /**
  61242. * 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"
  61243. * This function works in left handed mode
  61244. * @param eye defines the final position of the entity
  61245. * @param target defines where the entity should look at
  61246. * @param up defines the up vector for the entity
  61247. * @returns the new matrix
  61248. */
  61249. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61250. /**
  61251. * 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".
  61252. * This function works in left handed mode
  61253. * @param eye defines the final position of the entity
  61254. * @param target defines where the entity should look at
  61255. * @param up defines the up vector for the entity
  61256. * @param result defines the target matrix
  61257. */
  61258. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61259. /**
  61260. * 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"
  61261. * This function works in right handed mode
  61262. * @param eye defines the final position of the entity
  61263. * @param target defines where the entity should look at
  61264. * @param up defines the up vector for the entity
  61265. * @returns the new matrix
  61266. */
  61267. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61268. /**
  61269. * 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".
  61270. * This function works in right handed mode
  61271. * @param eye defines the final position of the entity
  61272. * @param target defines where the entity should look at
  61273. * @param up defines the up vector for the entity
  61274. * @param result defines the target matrix
  61275. */
  61276. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61277. /**
  61278. * Create a left-handed orthographic projection matrix
  61279. * @param width defines the viewport width
  61280. * @param height defines the viewport height
  61281. * @param znear defines the near clip plane
  61282. * @param zfar defines the far clip plane
  61283. * @returns a new matrix as a left-handed orthographic projection matrix
  61284. */
  61285. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61286. /**
  61287. * Store a left-handed orthographic projection to a given matrix
  61288. * @param width defines the viewport width
  61289. * @param height defines the viewport height
  61290. * @param znear defines the near clip plane
  61291. * @param zfar defines the far clip plane
  61292. * @param result defines the target matrix
  61293. */
  61294. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61295. /**
  61296. * Create a left-handed orthographic projection matrix
  61297. * @param left defines the viewport left coordinate
  61298. * @param right defines the viewport right coordinate
  61299. * @param bottom defines the viewport bottom coordinate
  61300. * @param top defines the viewport top coordinate
  61301. * @param znear defines the near clip plane
  61302. * @param zfar defines the far clip plane
  61303. * @returns a new matrix as a left-handed orthographic projection matrix
  61304. */
  61305. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61306. /**
  61307. * Stores a left-handed orthographic projection into a given matrix
  61308. * @param left defines the viewport left coordinate
  61309. * @param right defines the viewport right coordinate
  61310. * @param bottom defines the viewport bottom coordinate
  61311. * @param top defines the viewport top coordinate
  61312. * @param znear defines the near clip plane
  61313. * @param zfar defines the far clip plane
  61314. * @param result defines the target matrix
  61315. */
  61316. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61317. /**
  61318. * Creates a right-handed orthographic projection matrix
  61319. * @param left defines the viewport left coordinate
  61320. * @param right defines the viewport right coordinate
  61321. * @param bottom defines the viewport bottom coordinate
  61322. * @param top defines the viewport top coordinate
  61323. * @param znear defines the near clip plane
  61324. * @param zfar defines the far clip plane
  61325. * @returns a new matrix as a right-handed orthographic projection matrix
  61326. */
  61327. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61328. /**
  61329. * Stores a right-handed orthographic projection into a given matrix
  61330. * @param left defines the viewport left coordinate
  61331. * @param right defines the viewport right coordinate
  61332. * @param bottom defines the viewport bottom coordinate
  61333. * @param top defines the viewport top coordinate
  61334. * @param znear defines the near clip plane
  61335. * @param zfar defines the far clip plane
  61336. * @param result defines the target matrix
  61337. */
  61338. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61339. /**
  61340. * Creates a left-handed perspective projection matrix
  61341. * @param width defines the viewport width
  61342. * @param height defines the viewport height
  61343. * @param znear defines the near clip plane
  61344. * @param zfar defines the far clip plane
  61345. * @returns a new matrix as a left-handed perspective projection matrix
  61346. */
  61347. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61348. /**
  61349. * Creates a left-handed perspective projection matrix
  61350. * @param fov defines the horizontal field of view
  61351. * @param aspect defines the aspect ratio
  61352. * @param znear defines the near clip plane
  61353. * @param zfar defines the far clip plane
  61354. * @returns a new matrix as a left-handed perspective projection matrix
  61355. */
  61356. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61357. /**
  61358. * Stores a left-handed perspective projection into a given matrix
  61359. * @param fov defines the horizontal field of view
  61360. * @param aspect defines the aspect ratio
  61361. * @param znear defines the near clip plane
  61362. * @param zfar defines the far clip plane
  61363. * @param result defines the target matrix
  61364. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61365. */
  61366. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61367. /**
  61368. * Creates a right-handed perspective projection matrix
  61369. * @param fov defines the horizontal field of view
  61370. * @param aspect defines the aspect ratio
  61371. * @param znear defines the near clip plane
  61372. * @param zfar defines the far clip plane
  61373. * @returns a new matrix as a right-handed perspective projection matrix
  61374. */
  61375. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61376. /**
  61377. * Stores a right-handed perspective projection into a given matrix
  61378. * @param fov defines the horizontal field of view
  61379. * @param aspect defines the aspect ratio
  61380. * @param znear defines the near clip plane
  61381. * @param zfar defines the far clip plane
  61382. * @param result defines the target matrix
  61383. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61384. */
  61385. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61386. /**
  61387. * Stores a perspective projection for WebVR info a given matrix
  61388. * @param fov defines the field of view
  61389. * @param znear defines the near clip plane
  61390. * @param zfar defines the far clip plane
  61391. * @param result defines the target matrix
  61392. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61393. */
  61394. static PerspectiveFovWebVRToRef(fov: {
  61395. upDegrees: number;
  61396. downDegrees: number;
  61397. leftDegrees: number;
  61398. rightDegrees: number;
  61399. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61400. /**
  61401. * Computes a complete transformation matrix
  61402. * @param viewport defines the viewport to use
  61403. * @param world defines the world matrix
  61404. * @param view defines the view matrix
  61405. * @param projection defines the projection matrix
  61406. * @param zmin defines the near clip plane
  61407. * @param zmax defines the far clip plane
  61408. * @returns the transformation matrix
  61409. */
  61410. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61411. /**
  61412. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61413. * @param matrix defines the matrix to use
  61414. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61415. */
  61416. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61417. /**
  61418. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61419. * @param matrix defines the matrix to use
  61420. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61421. */
  61422. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61423. /**
  61424. * Compute the transpose of a given matrix
  61425. * @param matrix defines the matrix to transpose
  61426. * @returns the new matrix
  61427. */
  61428. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61429. /**
  61430. * Compute the transpose of a matrix and store it in a target matrix
  61431. * @param matrix defines the matrix to transpose
  61432. * @param result defines the target matrix
  61433. */
  61434. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61435. /**
  61436. * Computes a reflection matrix from a plane
  61437. * @param plane defines the reflection plane
  61438. * @returns a new matrix
  61439. */
  61440. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61441. /**
  61442. * Computes a reflection matrix from a plane
  61443. * @param plane defines the reflection plane
  61444. * @param result defines the target matrix
  61445. */
  61446. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61447. /**
  61448. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61449. * @param xaxis defines the value of the 1st axis
  61450. * @param yaxis defines the value of the 2nd axis
  61451. * @param zaxis defines the value of the 3rd axis
  61452. * @param result defines the target matrix
  61453. */
  61454. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61455. /**
  61456. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61457. * @param quat defines the quaternion to use
  61458. * @param result defines the target matrix
  61459. */
  61460. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61461. }
  61462. /**
  61463. * Represens a plane by the equation ax + by + cz + d = 0
  61464. */
  61465. export class Plane {
  61466. /**
  61467. * Normal of the plane (a,b,c)
  61468. */
  61469. normal: Vector3;
  61470. /**
  61471. * d component of the plane
  61472. */
  61473. d: number;
  61474. /**
  61475. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61476. * @param a a component of the plane
  61477. * @param b b component of the plane
  61478. * @param c c component of the plane
  61479. * @param d d component of the plane
  61480. */
  61481. constructor(a: number, b: number, c: number, d: number);
  61482. /**
  61483. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61484. */
  61485. asArray(): number[];
  61486. /**
  61487. * @returns a new plane copied from the current Plane.
  61488. */
  61489. clone(): Plane;
  61490. /**
  61491. * @returns the string "Plane".
  61492. */
  61493. getClassName(): string;
  61494. /**
  61495. * @returns the Plane hash code.
  61496. */
  61497. getHashCode(): number;
  61498. /**
  61499. * Normalize the current Plane in place.
  61500. * @returns the updated Plane.
  61501. */
  61502. normalize(): Plane;
  61503. /**
  61504. * Applies a transformation the plane and returns the result
  61505. * @param transformation the transformation matrix to be applied to the plane
  61506. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61507. */
  61508. transform(transformation: DeepImmutable<Matrix>): Plane;
  61509. /**
  61510. * Calcualtte the dot product between the point and the plane normal
  61511. * @param point point to calculate the dot product with
  61512. * @returns the dot product (float) of the point coordinates and the plane normal.
  61513. */
  61514. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61515. /**
  61516. * Updates the current Plane from the plane defined by the three given points.
  61517. * @param point1 one of the points used to contruct the plane
  61518. * @param point2 one of the points used to contruct the plane
  61519. * @param point3 one of the points used to contruct the plane
  61520. * @returns the updated Plane.
  61521. */
  61522. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61523. /**
  61524. * Checks if the plane is facing a given direction
  61525. * @param direction the direction to check if the plane is facing
  61526. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61527. * @returns True is the vector "direction" is the same side than the plane normal.
  61528. */
  61529. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61530. /**
  61531. * Calculates the distance to a point
  61532. * @param point point to calculate distance to
  61533. * @returns the signed distance (float) from the given point to the Plane.
  61534. */
  61535. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61536. /**
  61537. * Creates a plane from an array
  61538. * @param array the array to create a plane from
  61539. * @returns a new Plane from the given array.
  61540. */
  61541. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61542. /**
  61543. * Creates a plane from three points
  61544. * @param point1 point used to create the plane
  61545. * @param point2 point used to create the plane
  61546. * @param point3 point used to create the plane
  61547. * @returns a new Plane defined by the three given points.
  61548. */
  61549. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61550. /**
  61551. * Creates a plane from an origin point and a normal
  61552. * @param origin origin of the plane to be constructed
  61553. * @param normal normal of the plane to be constructed
  61554. * @returns a new Plane the normal vector to this plane at the given origin point.
  61555. * Note : the vector "normal" is updated because normalized.
  61556. */
  61557. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61558. /**
  61559. * Calculates the distance from a plane and a point
  61560. * @param origin origin of the plane to be constructed
  61561. * @param normal normal of the plane to be constructed
  61562. * @param point point to calculate distance to
  61563. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61564. */
  61565. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61566. }
  61567. /**
  61568. * Class used to represent a viewport on screen
  61569. */
  61570. export class Viewport {
  61571. /** viewport left coordinate */
  61572. x: number;
  61573. /** viewport top coordinate */
  61574. y: number;
  61575. /**viewport width */
  61576. width: number;
  61577. /** viewport height */
  61578. height: number;
  61579. /**
  61580. * Creates a Viewport object located at (x, y) and sized (width, height)
  61581. * @param x defines viewport left coordinate
  61582. * @param y defines viewport top coordinate
  61583. * @param width defines the viewport width
  61584. * @param height defines the viewport height
  61585. */
  61586. constructor(
  61587. /** viewport left coordinate */
  61588. x: number,
  61589. /** viewport top coordinate */
  61590. y: number,
  61591. /**viewport width */
  61592. width: number,
  61593. /** viewport height */
  61594. height: number);
  61595. /**
  61596. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61597. * @param renderWidth defines the rendering width
  61598. * @param renderHeight defines the rendering height
  61599. * @returns a new Viewport
  61600. */
  61601. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61602. /**
  61603. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61604. * @param renderWidth defines the rendering width
  61605. * @param renderHeight defines the rendering height
  61606. * @param ref defines the target viewport
  61607. * @returns the current viewport
  61608. */
  61609. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61610. /**
  61611. * Returns a new Viewport copied from the current one
  61612. * @returns a new Viewport
  61613. */
  61614. clone(): Viewport;
  61615. }
  61616. /**
  61617. * Reprasents a camera frustum
  61618. */
  61619. export class Frustum {
  61620. /**
  61621. * Gets the planes representing the frustum
  61622. * @param transform matrix to be applied to the returned planes
  61623. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61624. */
  61625. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61626. /**
  61627. * Gets the near frustum plane transformed by the transform matrix
  61628. * @param transform transformation matrix to be applied to the resulting frustum plane
  61629. * @param frustumPlane the resuling frustum plane
  61630. */
  61631. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61632. /**
  61633. * Gets the far frustum plane transformed by the transform matrix
  61634. * @param transform transformation matrix to be applied to the resulting frustum plane
  61635. * @param frustumPlane the resuling frustum plane
  61636. */
  61637. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61638. /**
  61639. * Gets the left frustum plane transformed by the transform matrix
  61640. * @param transform transformation matrix to be applied to the resulting frustum plane
  61641. * @param frustumPlane the resuling frustum plane
  61642. */
  61643. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61644. /**
  61645. * Gets the right frustum plane transformed by the transform matrix
  61646. * @param transform transformation matrix to be applied to the resulting frustum plane
  61647. * @param frustumPlane the resuling frustum plane
  61648. */
  61649. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61650. /**
  61651. * Gets the top frustum plane transformed by the transform matrix
  61652. * @param transform transformation matrix to be applied to the resulting frustum plane
  61653. * @param frustumPlane the resuling frustum plane
  61654. */
  61655. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61656. /**
  61657. * Gets the bottom frustum plane transformed by the transform matrix
  61658. * @param transform transformation matrix to be applied to the resulting frustum plane
  61659. * @param frustumPlane the resuling frustum plane
  61660. */
  61661. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61662. /**
  61663. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61664. * @param transform transformation matrix to be applied to the resulting frustum planes
  61665. * @param frustumPlanes the resuling frustum planes
  61666. */
  61667. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61668. }
  61669. /** Defines supported spaces */
  61670. export enum Space {
  61671. /** Local (object) space */
  61672. LOCAL = 0,
  61673. /** World space */
  61674. WORLD = 1,
  61675. /** Bone space */
  61676. BONE = 2
  61677. }
  61678. /** Defines the 3 main axes */
  61679. export class Axis {
  61680. /** X axis */
  61681. static X: Vector3;
  61682. /** Y axis */
  61683. static Y: Vector3;
  61684. /** Z axis */
  61685. static Z: Vector3;
  61686. }
  61687. /** Class used to represent a Bezier curve */
  61688. export class BezierCurve {
  61689. /**
  61690. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61691. * @param t defines the time
  61692. * @param x1 defines the left coordinate on X axis
  61693. * @param y1 defines the left coordinate on Y axis
  61694. * @param x2 defines the right coordinate on X axis
  61695. * @param y2 defines the right coordinate on Y axis
  61696. * @returns the interpolated value
  61697. */
  61698. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61699. }
  61700. /**
  61701. * Defines potential orientation for back face culling
  61702. */
  61703. export enum Orientation {
  61704. /**
  61705. * Clockwise
  61706. */
  61707. CW = 0,
  61708. /** Counter clockwise */
  61709. CCW = 1
  61710. }
  61711. /**
  61712. * Defines angle representation
  61713. */
  61714. export class Angle {
  61715. private _radians;
  61716. /**
  61717. * Creates an Angle object of "radians" radians (float).
  61718. * @param radians the angle in radians
  61719. */
  61720. constructor(radians: number);
  61721. /**
  61722. * Get value in degrees
  61723. * @returns the Angle value in degrees (float)
  61724. */
  61725. degrees(): number;
  61726. /**
  61727. * Get value in radians
  61728. * @returns the Angle value in radians (float)
  61729. */
  61730. radians(): number;
  61731. /**
  61732. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61733. * @param a defines first vector
  61734. * @param b defines second vector
  61735. * @returns a new Angle
  61736. */
  61737. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61738. /**
  61739. * Gets a new Angle object from the given float in radians
  61740. * @param radians defines the angle value in radians
  61741. * @returns a new Angle
  61742. */
  61743. static FromRadians(radians: number): Angle;
  61744. /**
  61745. * Gets a new Angle object from the given float in degrees
  61746. * @param degrees defines the angle value in degrees
  61747. * @returns a new Angle
  61748. */
  61749. static FromDegrees(degrees: number): Angle;
  61750. }
  61751. /**
  61752. * This represents an arc in a 2d space.
  61753. */
  61754. export class Arc2 {
  61755. /** Defines the start point of the arc */
  61756. startPoint: Vector2;
  61757. /** Defines the mid point of the arc */
  61758. midPoint: Vector2;
  61759. /** Defines the end point of the arc */
  61760. endPoint: Vector2;
  61761. /**
  61762. * Defines the center point of the arc.
  61763. */
  61764. centerPoint: Vector2;
  61765. /**
  61766. * Defines the radius of the arc.
  61767. */
  61768. radius: number;
  61769. /**
  61770. * Defines the angle of the arc (from mid point to end point).
  61771. */
  61772. angle: Angle;
  61773. /**
  61774. * Defines the start angle of the arc (from start point to middle point).
  61775. */
  61776. startAngle: Angle;
  61777. /**
  61778. * Defines the orientation of the arc (clock wise/counter clock wise).
  61779. */
  61780. orientation: Orientation;
  61781. /**
  61782. * Creates an Arc object from the three given points : start, middle and end.
  61783. * @param startPoint Defines the start point of the arc
  61784. * @param midPoint Defines the midlle point of the arc
  61785. * @param endPoint Defines the end point of the arc
  61786. */
  61787. constructor(
  61788. /** Defines the start point of the arc */
  61789. startPoint: Vector2,
  61790. /** Defines the mid point of the arc */
  61791. midPoint: Vector2,
  61792. /** Defines the end point of the arc */
  61793. endPoint: Vector2);
  61794. }
  61795. /**
  61796. * Represents a 2D path made up of multiple 2D points
  61797. */
  61798. export class Path2 {
  61799. private _points;
  61800. private _length;
  61801. /**
  61802. * If the path start and end point are the same
  61803. */
  61804. closed: boolean;
  61805. /**
  61806. * Creates a Path2 object from the starting 2D coordinates x and y.
  61807. * @param x the starting points x value
  61808. * @param y the starting points y value
  61809. */
  61810. constructor(x: number, y: number);
  61811. /**
  61812. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61813. * @param x the added points x value
  61814. * @param y the added points y value
  61815. * @returns the updated Path2.
  61816. */
  61817. addLineTo(x: number, y: number): Path2;
  61818. /**
  61819. * 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.
  61820. * @param midX middle point x value
  61821. * @param midY middle point y value
  61822. * @param endX end point x value
  61823. * @param endY end point y value
  61824. * @param numberOfSegments (default: 36)
  61825. * @returns the updated Path2.
  61826. */
  61827. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61828. /**
  61829. * Closes the Path2.
  61830. * @returns the Path2.
  61831. */
  61832. close(): Path2;
  61833. /**
  61834. * Gets the sum of the distance between each sequential point in the path
  61835. * @returns the Path2 total length (float).
  61836. */
  61837. length(): number;
  61838. /**
  61839. * Gets the points which construct the path
  61840. * @returns the Path2 internal array of points.
  61841. */
  61842. getPoints(): Vector2[];
  61843. /**
  61844. * Retreives the point at the distance aways from the starting point
  61845. * @param normalizedLengthPosition the length along the path to retreive the point from
  61846. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61847. */
  61848. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61849. /**
  61850. * Creates a new path starting from an x and y position
  61851. * @param x starting x value
  61852. * @param y starting y value
  61853. * @returns a new Path2 starting at the coordinates (x, y).
  61854. */
  61855. static StartingAt(x: number, y: number): Path2;
  61856. }
  61857. /**
  61858. * Represents a 3D path made up of multiple 3D points
  61859. */
  61860. export class Path3D {
  61861. /**
  61862. * an array of Vector3, the curve axis of the Path3D
  61863. */
  61864. path: Vector3[];
  61865. private _curve;
  61866. private _distances;
  61867. private _tangents;
  61868. private _normals;
  61869. private _binormals;
  61870. private _raw;
  61871. /**
  61872. * new Path3D(path, normal, raw)
  61873. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61874. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61875. * @param path an array of Vector3, the curve axis of the Path3D
  61876. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61877. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61878. */
  61879. constructor(
  61880. /**
  61881. * an array of Vector3, the curve axis of the Path3D
  61882. */
  61883. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61884. /**
  61885. * Returns the Path3D array of successive Vector3 designing its curve.
  61886. * @returns the Path3D array of successive Vector3 designing its curve.
  61887. */
  61888. getCurve(): Vector3[];
  61889. /**
  61890. * Returns an array populated with tangent vectors on each Path3D curve point.
  61891. * @returns an array populated with tangent vectors on each Path3D curve point.
  61892. */
  61893. getTangents(): Vector3[];
  61894. /**
  61895. * Returns an array populated with normal vectors on each Path3D curve point.
  61896. * @returns an array populated with normal vectors on each Path3D curve point.
  61897. */
  61898. getNormals(): Vector3[];
  61899. /**
  61900. * Returns an array populated with binormal vectors on each Path3D curve point.
  61901. * @returns an array populated with binormal vectors on each Path3D curve point.
  61902. */
  61903. getBinormals(): Vector3[];
  61904. /**
  61905. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61906. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61907. */
  61908. getDistances(): number[];
  61909. /**
  61910. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61911. * @param path path which all values are copied into the curves points
  61912. * @param firstNormal which should be projected onto the curve
  61913. * @returns the same object updated.
  61914. */
  61915. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61916. private _compute;
  61917. private _getFirstNonNullVector;
  61918. private _getLastNonNullVector;
  61919. private _normalVector;
  61920. }
  61921. /**
  61922. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61923. * A Curve3 is designed from a series of successive Vector3.
  61924. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61925. */
  61926. export class Curve3 {
  61927. private _points;
  61928. private _length;
  61929. /**
  61930. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61931. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61932. * @param v1 (Vector3) the control point
  61933. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61934. * @param nbPoints (integer) the wanted number of points in the curve
  61935. * @returns the created Curve3
  61936. */
  61937. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61938. /**
  61939. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61940. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61941. * @param v1 (Vector3) the first control point
  61942. * @param v2 (Vector3) the second control point
  61943. * @param v3 (Vector3) the end point of the Cubic Bezier
  61944. * @param nbPoints (integer) the wanted number of points in the curve
  61945. * @returns the created Curve3
  61946. */
  61947. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61948. /**
  61949. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61950. * @param p1 (Vector3) the origin point of the Hermite Spline
  61951. * @param t1 (Vector3) the tangent vector at the origin point
  61952. * @param p2 (Vector3) the end point of the Hermite Spline
  61953. * @param t2 (Vector3) the tangent vector at the end point
  61954. * @param nbPoints (integer) the wanted number of points in the curve
  61955. * @returns the created Curve3
  61956. */
  61957. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61958. /**
  61959. * Returns a Curve3 object along a CatmullRom Spline curve :
  61960. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61961. * @param nbPoints (integer) the wanted number of points between each curve control points
  61962. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61963. * @returns the created Curve3
  61964. */
  61965. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61966. /**
  61967. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61968. * A Curve3 is designed from a series of successive Vector3.
  61969. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61970. * @param points points which make up the curve
  61971. */
  61972. constructor(points: Vector3[]);
  61973. /**
  61974. * @returns the Curve3 stored array of successive Vector3
  61975. */
  61976. getPoints(): Vector3[];
  61977. /**
  61978. * @returns the computed length (float) of the curve.
  61979. */
  61980. length(): number;
  61981. /**
  61982. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61983. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61984. * curveA and curveB keep unchanged.
  61985. * @param curve the curve to continue from this curve
  61986. * @returns the newly constructed curve
  61987. */
  61988. continue(curve: DeepImmutable<Curve3>): Curve3;
  61989. private _computeLength;
  61990. }
  61991. /**
  61992. * Contains position and normal vectors for a vertex
  61993. */
  61994. export class PositionNormalVertex {
  61995. /** the position of the vertex (defaut: 0,0,0) */
  61996. position: Vector3;
  61997. /** the normal of the vertex (defaut: 0,1,0) */
  61998. normal: Vector3;
  61999. /**
  62000. * Creates a PositionNormalVertex
  62001. * @param position the position of the vertex (defaut: 0,0,0)
  62002. * @param normal the normal of the vertex (defaut: 0,1,0)
  62003. */
  62004. constructor(
  62005. /** the position of the vertex (defaut: 0,0,0) */
  62006. position?: Vector3,
  62007. /** the normal of the vertex (defaut: 0,1,0) */
  62008. normal?: Vector3);
  62009. /**
  62010. * Clones the PositionNormalVertex
  62011. * @returns the cloned PositionNormalVertex
  62012. */
  62013. clone(): PositionNormalVertex;
  62014. }
  62015. /**
  62016. * Contains position, normal and uv vectors for a vertex
  62017. */
  62018. export class PositionNormalTextureVertex {
  62019. /** the position of the vertex (defaut: 0,0,0) */
  62020. position: Vector3;
  62021. /** the normal of the vertex (defaut: 0,1,0) */
  62022. normal: Vector3;
  62023. /** the uv of the vertex (default: 0,0) */
  62024. uv: Vector2;
  62025. /**
  62026. * Creates a PositionNormalTextureVertex
  62027. * @param position the position of the vertex (defaut: 0,0,0)
  62028. * @param normal the normal of the vertex (defaut: 0,1,0)
  62029. * @param uv the uv of the vertex (default: 0,0)
  62030. */
  62031. constructor(
  62032. /** the position of the vertex (defaut: 0,0,0) */
  62033. position?: Vector3,
  62034. /** the normal of the vertex (defaut: 0,1,0) */
  62035. normal?: Vector3,
  62036. /** the uv of the vertex (default: 0,0) */
  62037. uv?: Vector2);
  62038. /**
  62039. * Clones the PositionNormalTextureVertex
  62040. * @returns the cloned PositionNormalTextureVertex
  62041. */
  62042. clone(): PositionNormalTextureVertex;
  62043. }
  62044. /**
  62045. * @hidden
  62046. */
  62047. export class Tmp {
  62048. static Color3: Color3[];
  62049. static Color4: Color4[];
  62050. static Vector2: Vector2[];
  62051. static Vector3: Vector3[];
  62052. static Vector4: Vector4[];
  62053. static Quaternion: Quaternion[];
  62054. static Matrix: Matrix[];
  62055. }
  62056. }
  62057. declare module BABYLON {
  62058. /**
  62059. * Class used to enable access to offline support
  62060. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62061. */
  62062. export interface IOfflineProvider {
  62063. /**
  62064. * Gets a boolean indicating if scene must be saved in the database
  62065. */
  62066. enableSceneOffline: boolean;
  62067. /**
  62068. * Gets a boolean indicating if textures must be saved in the database
  62069. */
  62070. enableTexturesOffline: boolean;
  62071. /**
  62072. * Open the offline support and make it available
  62073. * @param successCallback defines the callback to call on success
  62074. * @param errorCallback defines the callback to call on error
  62075. */
  62076. open(successCallback: () => void, errorCallback: () => void): void;
  62077. /**
  62078. * Loads an image from the offline support
  62079. * @param url defines the url to load from
  62080. * @param image defines the target DOM image
  62081. */
  62082. loadImage(url: string, image: HTMLImageElement): void;
  62083. /**
  62084. * Loads a file from offline support
  62085. * @param url defines the URL to load from
  62086. * @param sceneLoaded defines a callback to call on success
  62087. * @param progressCallBack defines a callback to call when progress changed
  62088. * @param errorCallback defines a callback to call on error
  62089. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62090. */
  62091. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62092. }
  62093. }
  62094. declare module BABYLON {
  62095. /**
  62096. * A class serves as a medium between the observable and its observers
  62097. */
  62098. export class EventState {
  62099. /**
  62100. * Create a new EventState
  62101. * @param mask defines the mask associated with this state
  62102. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62103. * @param target defines the original target of the state
  62104. * @param currentTarget defines the current target of the state
  62105. */
  62106. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62107. /**
  62108. * Initialize the current event state
  62109. * @param mask defines the mask associated with this state
  62110. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62111. * @param target defines the original target of the state
  62112. * @param currentTarget defines the current target of the state
  62113. * @returns the current event state
  62114. */
  62115. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  62116. /**
  62117. * An Observer can set this property to true to prevent subsequent observers of being notified
  62118. */
  62119. skipNextObservers: boolean;
  62120. /**
  62121. * Get the mask value that were used to trigger the event corresponding to this EventState object
  62122. */
  62123. mask: number;
  62124. /**
  62125. * The object that originally notified the event
  62126. */
  62127. target?: any;
  62128. /**
  62129. * The current object in the bubbling phase
  62130. */
  62131. currentTarget?: any;
  62132. /**
  62133. * This will be populated with the return value of the last function that was executed.
  62134. * If it is the first function in the callback chain it will be the event data.
  62135. */
  62136. lastReturnValue?: any;
  62137. }
  62138. /**
  62139. * Represent an Observer registered to a given Observable object.
  62140. */
  62141. export class Observer<T> {
  62142. /**
  62143. * Defines the callback to call when the observer is notified
  62144. */
  62145. callback: (eventData: T, eventState: EventState) => void;
  62146. /**
  62147. * Defines the mask of the observer (used to filter notifications)
  62148. */
  62149. mask: number;
  62150. /**
  62151. * Defines the current scope used to restore the JS context
  62152. */
  62153. scope: any;
  62154. /** @hidden */
  62155. _willBeUnregistered: boolean;
  62156. /**
  62157. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62158. */
  62159. unregisterOnNextCall: boolean;
  62160. /**
  62161. * Creates a new observer
  62162. * @param callback defines the callback to call when the observer is notified
  62163. * @param mask defines the mask of the observer (used to filter notifications)
  62164. * @param scope defines the current scope used to restore the JS context
  62165. */
  62166. constructor(
  62167. /**
  62168. * Defines the callback to call when the observer is notified
  62169. */
  62170. callback: (eventData: T, eventState: EventState) => void,
  62171. /**
  62172. * Defines the mask of the observer (used to filter notifications)
  62173. */
  62174. mask: number,
  62175. /**
  62176. * Defines the current scope used to restore the JS context
  62177. */
  62178. scope?: any);
  62179. }
  62180. /**
  62181. * Represent a list of observers registered to multiple Observables object.
  62182. */
  62183. export class MultiObserver<T> {
  62184. private _observers;
  62185. private _observables;
  62186. /**
  62187. * Release associated resources
  62188. */
  62189. dispose(): void;
  62190. /**
  62191. * Raise a callback when one of the observable will notify
  62192. * @param observables defines a list of observables to watch
  62193. * @param callback defines the callback to call on notification
  62194. * @param mask defines the mask used to filter notifications
  62195. * @param scope defines the current scope used to restore the JS context
  62196. * @returns the new MultiObserver
  62197. */
  62198. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62199. }
  62200. /**
  62201. * The Observable class is a simple implementation of the Observable pattern.
  62202. *
  62203. * 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.
  62204. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62205. * 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).
  62206. * 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.
  62207. */
  62208. export class Observable<T> {
  62209. private _observers;
  62210. private _eventState;
  62211. private _onObserverAdded;
  62212. /**
  62213. * Creates a new observable
  62214. * @param onObserverAdded defines a callback to call when a new observer is added
  62215. */
  62216. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62217. /**
  62218. * Create a new Observer with the specified callback
  62219. * @param callback the callback that will be executed for that Observer
  62220. * @param mask the mask used to filter observers
  62221. * @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.
  62222. * @param scope optional scope for the callback to be called from
  62223. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62224. * @returns the new observer created for the callback
  62225. */
  62226. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62227. /**
  62228. * Create a new Observer with the specified callback and unregisters after the next notification
  62229. * @param callback the callback that will be executed for that Observer
  62230. * @returns the new observer created for the callback
  62231. */
  62232. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62233. /**
  62234. * Remove an Observer from the Observable object
  62235. * @param observer the instance of the Observer to remove
  62236. * @returns false if it doesn't belong to this Observable
  62237. */
  62238. remove(observer: Nullable<Observer<T>>): boolean;
  62239. /**
  62240. * Remove a callback from the Observable object
  62241. * @param callback the callback to remove
  62242. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62243. * @returns false if it doesn't belong to this Observable
  62244. */
  62245. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62246. private _deferUnregister;
  62247. private _remove;
  62248. /**
  62249. * Notify all Observers by calling their respective callback with the given data
  62250. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62251. * @param eventData defines the data to send to all observers
  62252. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62253. * @param target defines the original target of the state
  62254. * @param currentTarget defines the current target of the state
  62255. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62256. */
  62257. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62258. /**
  62259. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62260. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62261. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62262. * and it is crucial that all callbacks will be executed.
  62263. * The order of the callbacks is kept, callbacks are not executed parallel.
  62264. *
  62265. * @param eventData The data to be sent to each callback
  62266. * @param mask is used to filter observers defaults to -1
  62267. * @param target defines the callback target (see EventState)
  62268. * @param currentTarget defines he current object in the bubbling phase
  62269. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62270. */
  62271. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62272. /**
  62273. * Notify a specific observer
  62274. * @param observer defines the observer to notify
  62275. * @param eventData defines the data to be sent to each callback
  62276. * @param mask is used to filter observers defaults to -1
  62277. */
  62278. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62279. /**
  62280. * Gets a boolean indicating if the observable has at least one observer
  62281. * @returns true is the Observable has at least one Observer registered
  62282. */
  62283. hasObservers(): boolean;
  62284. /**
  62285. * Clear the list of observers
  62286. */
  62287. clear(): void;
  62288. /**
  62289. * Clone the current observable
  62290. * @returns a new observable
  62291. */
  62292. clone(): Observable<T>;
  62293. /**
  62294. * Does this observable handles observer registered with a given mask
  62295. * @param mask defines the mask to be tested
  62296. * @return whether or not one observer registered with the given mask is handeled
  62297. **/
  62298. hasSpecificMask(mask?: number): boolean;
  62299. }
  62300. }
  62301. declare module BABYLON {
  62302. /**
  62303. * Class used to help managing file picking and drag'n'drop
  62304. * File Storage
  62305. */
  62306. export class FilesInputStore {
  62307. /**
  62308. * List of files ready to be loaded
  62309. */
  62310. static FilesToLoad: {
  62311. [key: string]: File;
  62312. };
  62313. }
  62314. }
  62315. declare module BABYLON {
  62316. /** Defines the cross module used constants to avoid circular dependncies */
  62317. export class Constants {
  62318. /** Defines that alpha blending is disabled */
  62319. static readonly ALPHA_DISABLE: number;
  62320. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62321. static readonly ALPHA_ADD: number;
  62322. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62323. static readonly ALPHA_COMBINE: number;
  62324. /** Defines that alpha blending to DEST - SRC * DEST */
  62325. static readonly ALPHA_SUBTRACT: number;
  62326. /** Defines that alpha blending to SRC * DEST */
  62327. static readonly ALPHA_MULTIPLY: number;
  62328. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62329. static readonly ALPHA_MAXIMIZED: number;
  62330. /** Defines that alpha blending to SRC + DEST */
  62331. static readonly ALPHA_ONEONE: number;
  62332. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62333. static readonly ALPHA_PREMULTIPLIED: number;
  62334. /**
  62335. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62336. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62337. */
  62338. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62339. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62340. static readonly ALPHA_INTERPOLATE: number;
  62341. /**
  62342. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62343. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62344. */
  62345. static readonly ALPHA_SCREENMODE: number;
  62346. /** Defines that the ressource is not delayed*/
  62347. static readonly DELAYLOADSTATE_NONE: number;
  62348. /** Defines that the ressource was successfully delay loaded */
  62349. static readonly DELAYLOADSTATE_LOADED: number;
  62350. /** Defines that the ressource is currently delay loading */
  62351. static readonly DELAYLOADSTATE_LOADING: number;
  62352. /** Defines that the ressource is delayed and has not started loading */
  62353. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62354. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62355. static readonly NEVER: number;
  62356. /** 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 */
  62357. static readonly ALWAYS: number;
  62358. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62359. static readonly LESS: number;
  62360. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62361. static readonly EQUAL: number;
  62362. /** 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 */
  62363. static readonly LEQUAL: number;
  62364. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62365. static readonly GREATER: number;
  62366. /** 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 */
  62367. static readonly GEQUAL: number;
  62368. /** 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 */
  62369. static readonly NOTEQUAL: number;
  62370. /** Passed to stencilOperation to specify that stencil value must be kept */
  62371. static readonly KEEP: number;
  62372. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62373. static readonly REPLACE: number;
  62374. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62375. static readonly INCR: number;
  62376. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62377. static readonly DECR: number;
  62378. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62379. static readonly INVERT: number;
  62380. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62381. static readonly INCR_WRAP: number;
  62382. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62383. static readonly DECR_WRAP: number;
  62384. /** Texture is not repeating outside of 0..1 UVs */
  62385. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62386. /** Texture is repeating outside of 0..1 UVs */
  62387. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62388. /** Texture is repeating and mirrored */
  62389. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62390. /** ALPHA */
  62391. static readonly TEXTUREFORMAT_ALPHA: number;
  62392. /** LUMINANCE */
  62393. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62394. /** LUMINANCE_ALPHA */
  62395. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62396. /** RGB */
  62397. static readonly TEXTUREFORMAT_RGB: number;
  62398. /** RGBA */
  62399. static readonly TEXTUREFORMAT_RGBA: number;
  62400. /** RED */
  62401. static readonly TEXTUREFORMAT_RED: number;
  62402. /** RED (2nd reference) */
  62403. static readonly TEXTUREFORMAT_R: number;
  62404. /** RG */
  62405. static readonly TEXTUREFORMAT_RG: number;
  62406. /** RED_INTEGER */
  62407. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62408. /** RED_INTEGER (2nd reference) */
  62409. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62410. /** RG_INTEGER */
  62411. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62412. /** RGB_INTEGER */
  62413. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62414. /** RGBA_INTEGER */
  62415. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62416. /** UNSIGNED_BYTE */
  62417. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62418. /** UNSIGNED_BYTE (2nd reference) */
  62419. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62420. /** FLOAT */
  62421. static readonly TEXTURETYPE_FLOAT: number;
  62422. /** HALF_FLOAT */
  62423. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62424. /** BYTE */
  62425. static readonly TEXTURETYPE_BYTE: number;
  62426. /** SHORT */
  62427. static readonly TEXTURETYPE_SHORT: number;
  62428. /** UNSIGNED_SHORT */
  62429. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62430. /** INT */
  62431. static readonly TEXTURETYPE_INT: number;
  62432. /** UNSIGNED_INT */
  62433. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62434. /** UNSIGNED_SHORT_4_4_4_4 */
  62435. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62436. /** UNSIGNED_SHORT_5_5_5_1 */
  62437. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62438. /** UNSIGNED_SHORT_5_6_5 */
  62439. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62440. /** UNSIGNED_INT_2_10_10_10_REV */
  62441. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62442. /** UNSIGNED_INT_24_8 */
  62443. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62444. /** UNSIGNED_INT_10F_11F_11F_REV */
  62445. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62446. /** UNSIGNED_INT_5_9_9_9_REV */
  62447. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62448. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62449. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62450. /** nearest is mag = nearest and min = nearest and mip = linear */
  62451. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62452. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62453. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62454. /** Trilinear is mag = linear and min = linear and mip = linear */
  62455. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62456. /** nearest is mag = nearest and min = nearest and mip = linear */
  62457. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62458. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62459. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62460. /** Trilinear is mag = linear and min = linear and mip = linear */
  62461. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62462. /** mag = nearest and min = nearest and mip = nearest */
  62463. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62464. /** mag = nearest and min = linear and mip = nearest */
  62465. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62466. /** mag = nearest and min = linear and mip = linear */
  62467. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62468. /** mag = nearest and min = linear and mip = none */
  62469. static readonly TEXTURE_NEAREST_LINEAR: number;
  62470. /** mag = nearest and min = nearest and mip = none */
  62471. static readonly TEXTURE_NEAREST_NEAREST: number;
  62472. /** mag = linear and min = nearest and mip = nearest */
  62473. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62474. /** mag = linear and min = nearest and mip = linear */
  62475. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62476. /** mag = linear and min = linear and mip = none */
  62477. static readonly TEXTURE_LINEAR_LINEAR: number;
  62478. /** mag = linear and min = nearest and mip = none */
  62479. static readonly TEXTURE_LINEAR_NEAREST: number;
  62480. /** Explicit coordinates mode */
  62481. static readonly TEXTURE_EXPLICIT_MODE: number;
  62482. /** Spherical coordinates mode */
  62483. static readonly TEXTURE_SPHERICAL_MODE: number;
  62484. /** Planar coordinates mode */
  62485. static readonly TEXTURE_PLANAR_MODE: number;
  62486. /** Cubic coordinates mode */
  62487. static readonly TEXTURE_CUBIC_MODE: number;
  62488. /** Projection coordinates mode */
  62489. static readonly TEXTURE_PROJECTION_MODE: number;
  62490. /** Skybox coordinates mode */
  62491. static readonly TEXTURE_SKYBOX_MODE: number;
  62492. /** Inverse Cubic coordinates mode */
  62493. static readonly TEXTURE_INVCUBIC_MODE: number;
  62494. /** Equirectangular coordinates mode */
  62495. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62496. /** Equirectangular Fixed coordinates mode */
  62497. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62498. /** Equirectangular Fixed Mirrored coordinates mode */
  62499. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62500. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62501. static readonly SCALEMODE_FLOOR: number;
  62502. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62503. static readonly SCALEMODE_NEAREST: number;
  62504. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62505. static readonly SCALEMODE_CEILING: number;
  62506. /**
  62507. * The dirty texture flag value
  62508. */
  62509. static readonly MATERIAL_TextureDirtyFlag: number;
  62510. /**
  62511. * The dirty light flag value
  62512. */
  62513. static readonly MATERIAL_LightDirtyFlag: number;
  62514. /**
  62515. * The dirty fresnel flag value
  62516. */
  62517. static readonly MATERIAL_FresnelDirtyFlag: number;
  62518. /**
  62519. * The dirty attribute flag value
  62520. */
  62521. static readonly MATERIAL_AttributesDirtyFlag: number;
  62522. /**
  62523. * The dirty misc flag value
  62524. */
  62525. static readonly MATERIAL_MiscDirtyFlag: number;
  62526. /**
  62527. * The all dirty flag value
  62528. */
  62529. static readonly MATERIAL_AllDirtyFlag: number;
  62530. /**
  62531. * Returns the triangle fill mode
  62532. */
  62533. static readonly MATERIAL_TriangleFillMode: number;
  62534. /**
  62535. * Returns the wireframe mode
  62536. */
  62537. static readonly MATERIAL_WireFrameFillMode: number;
  62538. /**
  62539. * Returns the point fill mode
  62540. */
  62541. static readonly MATERIAL_PointFillMode: number;
  62542. /**
  62543. * Returns the point list draw mode
  62544. */
  62545. static readonly MATERIAL_PointListDrawMode: number;
  62546. /**
  62547. * Returns the line list draw mode
  62548. */
  62549. static readonly MATERIAL_LineListDrawMode: number;
  62550. /**
  62551. * Returns the line loop draw mode
  62552. */
  62553. static readonly MATERIAL_LineLoopDrawMode: number;
  62554. /**
  62555. * Returns the line strip draw mode
  62556. */
  62557. static readonly MATERIAL_LineStripDrawMode: number;
  62558. /**
  62559. * Returns the triangle strip draw mode
  62560. */
  62561. static readonly MATERIAL_TriangleStripDrawMode: number;
  62562. /**
  62563. * Returns the triangle fan draw mode
  62564. */
  62565. static readonly MATERIAL_TriangleFanDrawMode: number;
  62566. /**
  62567. * Stores the clock-wise side orientation
  62568. */
  62569. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62570. /**
  62571. * Stores the counter clock-wise side orientation
  62572. */
  62573. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62574. /**
  62575. * Nothing
  62576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62577. */
  62578. static readonly ACTION_NothingTrigger: number;
  62579. /**
  62580. * On pick
  62581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62582. */
  62583. static readonly ACTION_OnPickTrigger: number;
  62584. /**
  62585. * On left pick
  62586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62587. */
  62588. static readonly ACTION_OnLeftPickTrigger: number;
  62589. /**
  62590. * On right pick
  62591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62592. */
  62593. static readonly ACTION_OnRightPickTrigger: number;
  62594. /**
  62595. * On center pick
  62596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62597. */
  62598. static readonly ACTION_OnCenterPickTrigger: number;
  62599. /**
  62600. * On pick down
  62601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62602. */
  62603. static readonly ACTION_OnPickDownTrigger: number;
  62604. /**
  62605. * On double pick
  62606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62607. */
  62608. static readonly ACTION_OnDoublePickTrigger: number;
  62609. /**
  62610. * On pick up
  62611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62612. */
  62613. static readonly ACTION_OnPickUpTrigger: number;
  62614. /**
  62615. * On pick out.
  62616. * This trigger will only be raised if you also declared a OnPickDown
  62617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62618. */
  62619. static readonly ACTION_OnPickOutTrigger: number;
  62620. /**
  62621. * On long press
  62622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62623. */
  62624. static readonly ACTION_OnLongPressTrigger: number;
  62625. /**
  62626. * On pointer over
  62627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62628. */
  62629. static readonly ACTION_OnPointerOverTrigger: number;
  62630. /**
  62631. * On pointer out
  62632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62633. */
  62634. static readonly ACTION_OnPointerOutTrigger: number;
  62635. /**
  62636. * On every frame
  62637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62638. */
  62639. static readonly ACTION_OnEveryFrameTrigger: number;
  62640. /**
  62641. * On intersection enter
  62642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62643. */
  62644. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62645. /**
  62646. * On intersection exit
  62647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62648. */
  62649. static readonly ACTION_OnIntersectionExitTrigger: number;
  62650. /**
  62651. * On key down
  62652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62653. */
  62654. static readonly ACTION_OnKeyDownTrigger: number;
  62655. /**
  62656. * On key up
  62657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62658. */
  62659. static readonly ACTION_OnKeyUpTrigger: number;
  62660. /**
  62661. * Billboard mode will only apply to Y axis
  62662. */
  62663. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62664. /**
  62665. * Billboard mode will apply to all axes
  62666. */
  62667. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62668. /**
  62669. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62670. */
  62671. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62672. /**
  62673. * Gets or sets base Assets URL
  62674. */
  62675. static readonly PARTICLES_BaseAssetsUrl: string;
  62676. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62677. * Test order :
  62678. * Is the bounding sphere outside the frustum ?
  62679. * If not, are the bounding box vertices outside the frustum ?
  62680. * It not, then the cullable object is in the frustum.
  62681. */
  62682. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62683. /** Culling strategy : Bounding Sphere Only.
  62684. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62685. * It's also less accurate than the standard because some not visible objects can still be selected.
  62686. * Test : is the bounding sphere outside the frustum ?
  62687. * If not, then the cullable object is in the frustum.
  62688. */
  62689. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62690. /** Culling strategy : Optimistic Inclusion.
  62691. * This in an inclusion test first, then the standard exclusion test.
  62692. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62693. * 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.
  62694. * Anyway, it's as accurate as the standard strategy.
  62695. * Test :
  62696. * Is the cullable object bounding sphere center in the frustum ?
  62697. * If not, apply the default culling strategy.
  62698. */
  62699. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62700. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62701. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62702. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62703. * 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.
  62704. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62705. * Test :
  62706. * Is the cullable object bounding sphere center in the frustum ?
  62707. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62708. */
  62709. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62710. /**
  62711. * No logging while loading
  62712. */
  62713. static readonly SCENELOADER_NO_LOGGING: number;
  62714. /**
  62715. * Minimal logging while loading
  62716. */
  62717. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62718. /**
  62719. * Summary logging while loading
  62720. */
  62721. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62722. /**
  62723. * Detailled logging while loading
  62724. */
  62725. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62726. }
  62727. }
  62728. declare module BABYLON {
  62729. /**
  62730. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62731. * Babylon.js
  62732. */
  62733. export class DomManagement {
  62734. /**
  62735. * Checks if the window object exists
  62736. * @returns true if the window object exists
  62737. */
  62738. static IsWindowObjectExist(): boolean;
  62739. /**
  62740. * Extracts text content from a DOM element hierarchy
  62741. * @param element defines the root element
  62742. * @returns a string
  62743. */
  62744. static GetDOMTextContent(element: HTMLElement): string;
  62745. }
  62746. }
  62747. declare module BABYLON {
  62748. /**
  62749. * Logger used througouht the application to allow configuration of
  62750. * the log level required for the messages.
  62751. */
  62752. export class Logger {
  62753. /**
  62754. * No log
  62755. */
  62756. static readonly NoneLogLevel: number;
  62757. /**
  62758. * Only message logs
  62759. */
  62760. static readonly MessageLogLevel: number;
  62761. /**
  62762. * Only warning logs
  62763. */
  62764. static readonly WarningLogLevel: number;
  62765. /**
  62766. * Only error logs
  62767. */
  62768. static readonly ErrorLogLevel: number;
  62769. /**
  62770. * All logs
  62771. */
  62772. static readonly AllLogLevel: number;
  62773. private static _LogCache;
  62774. /**
  62775. * Gets a value indicating the number of loading errors
  62776. * @ignorenaming
  62777. */
  62778. static errorsCount: number;
  62779. /**
  62780. * Callback called when a new log is added
  62781. */
  62782. static OnNewCacheEntry: (entry: string) => void;
  62783. private static _AddLogEntry;
  62784. private static _FormatMessage;
  62785. private static _LogDisabled;
  62786. private static _LogEnabled;
  62787. private static _WarnDisabled;
  62788. private static _WarnEnabled;
  62789. private static _ErrorDisabled;
  62790. private static _ErrorEnabled;
  62791. /**
  62792. * Log a message to the console
  62793. */
  62794. static Log: (message: string) => void;
  62795. /**
  62796. * Write a warning message to the console
  62797. */
  62798. static Warn: (message: string) => void;
  62799. /**
  62800. * Write an error message to the console
  62801. */
  62802. static Error: (message: string) => void;
  62803. /**
  62804. * Gets current log cache (list of logs)
  62805. */
  62806. static readonly LogCache: string;
  62807. /**
  62808. * Clears the log cache
  62809. */
  62810. static ClearLogCache(): void;
  62811. /**
  62812. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62813. */
  62814. static LogLevels: number;
  62815. }
  62816. }
  62817. declare module BABYLON {
  62818. /** @hidden */
  62819. export class _TypeStore {
  62820. /** @hidden */
  62821. static RegisteredTypes: {
  62822. [key: string]: Object;
  62823. };
  62824. /** @hidden */
  62825. static GetClass(fqdn: string): any;
  62826. }
  62827. }
  62828. declare module BABYLON {
  62829. /**
  62830. * Class containing a set of static utilities functions for deep copy.
  62831. */
  62832. export class DeepCopier {
  62833. /**
  62834. * Tries to copy an object by duplicating every property
  62835. * @param source defines the source object
  62836. * @param destination defines the target object
  62837. * @param doNotCopyList defines a list of properties to avoid
  62838. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62839. */
  62840. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62841. }
  62842. }
  62843. declare module BABYLON {
  62844. /**
  62845. * Class containing a set of static utilities functions for precision date
  62846. */
  62847. export class PrecisionDate {
  62848. /**
  62849. * Gets either window.performance.now() if supported or Date.now() else
  62850. */
  62851. static readonly Now: number;
  62852. }
  62853. }
  62854. declare module BABYLON {
  62855. /** @hidden */
  62856. export class _DevTools {
  62857. static WarnImport(name: string): string;
  62858. }
  62859. }
  62860. declare module BABYLON {
  62861. /**
  62862. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  62863. */
  62864. export class WebRequest {
  62865. private _xhr;
  62866. /**
  62867. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  62868. * i.e. when loading files, where the server/service expects an Authorization header
  62869. */
  62870. static CustomRequestHeaders: {
  62871. [key: string]: string;
  62872. };
  62873. /**
  62874. * Add callback functions in this array to update all the requests before they get sent to the network
  62875. */
  62876. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  62877. private _injectCustomRequestHeaders;
  62878. /**
  62879. * Gets or sets a function to be called when loading progress changes
  62880. */
  62881. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  62882. /**
  62883. * Returns client's state
  62884. */
  62885. readonly readyState: number;
  62886. /**
  62887. * Returns client's status
  62888. */
  62889. readonly status: number;
  62890. /**
  62891. * Returns client's status as a text
  62892. */
  62893. readonly statusText: string;
  62894. /**
  62895. * Returns client's response
  62896. */
  62897. readonly response: any;
  62898. /**
  62899. * Returns client's response url
  62900. */
  62901. readonly responseURL: string;
  62902. /**
  62903. * Returns client's response as text
  62904. */
  62905. readonly responseText: string;
  62906. /**
  62907. * Gets or sets the expected response type
  62908. */
  62909. responseType: XMLHttpRequestResponseType;
  62910. /** @hidden */
  62911. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  62912. /** @hidden */
  62913. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  62914. /**
  62915. * Cancels any network activity
  62916. */
  62917. abort(): void;
  62918. /**
  62919. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  62920. * @param body defines an optional request body
  62921. */
  62922. send(body?: Document | BodyInit | null): void;
  62923. /**
  62924. * Sets the request method, request URL
  62925. * @param method defines the method to use (GET, POST, etc..)
  62926. * @param url defines the url to connect with
  62927. */
  62928. open(method: string, url: string): void;
  62929. }
  62930. }
  62931. declare module BABYLON {
  62932. /**
  62933. * Class used to evalaute queries containing `and` and `or` operators
  62934. */
  62935. export class AndOrNotEvaluator {
  62936. /**
  62937. * Evaluate a query
  62938. * @param query defines the query to evaluate
  62939. * @param evaluateCallback defines the callback used to filter result
  62940. * @returns true if the query matches
  62941. */
  62942. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62943. private static _HandleParenthesisContent;
  62944. private static _SimplifyNegation;
  62945. }
  62946. }
  62947. declare module BABYLON {
  62948. /**
  62949. * Class used to store custom tags
  62950. */
  62951. export class Tags {
  62952. /**
  62953. * Adds support for tags on the given object
  62954. * @param obj defines the object to use
  62955. */
  62956. static EnableFor(obj: any): void;
  62957. /**
  62958. * Removes tags support
  62959. * @param obj defines the object to use
  62960. */
  62961. static DisableFor(obj: any): void;
  62962. /**
  62963. * Gets a boolean indicating if the given object has tags
  62964. * @param obj defines the object to use
  62965. * @returns a boolean
  62966. */
  62967. static HasTags(obj: any): boolean;
  62968. /**
  62969. * Gets the tags available on a given object
  62970. * @param obj defines the object to use
  62971. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62972. * @returns the tags
  62973. */
  62974. static GetTags(obj: any, asString?: boolean): any;
  62975. /**
  62976. * Adds tags to an object
  62977. * @param obj defines the object to use
  62978. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62979. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62980. */
  62981. static AddTagsTo(obj: any, tagsString: string): void;
  62982. /**
  62983. * @hidden
  62984. */
  62985. static _AddTagTo(obj: any, tag: string): void;
  62986. /**
  62987. * Removes specific tags from a specific object
  62988. * @param obj defines the object to use
  62989. * @param tagsString defines the tags to remove
  62990. */
  62991. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62992. /**
  62993. * @hidden
  62994. */
  62995. static _RemoveTagFrom(obj: any, tag: string): void;
  62996. /**
  62997. * Defines if tags hosted on an object match a given query
  62998. * @param obj defines the object to use
  62999. * @param tagsQuery defines the tag query
  63000. * @returns a boolean
  63001. */
  63002. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  63003. }
  63004. }
  63005. declare module BABYLON {
  63006. /**
  63007. * Manages the defines for the Material
  63008. */
  63009. export class MaterialDefines {
  63010. private _keys;
  63011. private _isDirty;
  63012. /** @hidden */
  63013. _renderId: number;
  63014. /** @hidden */
  63015. _areLightsDirty: boolean;
  63016. /** @hidden */
  63017. _areAttributesDirty: boolean;
  63018. /** @hidden */
  63019. _areTexturesDirty: boolean;
  63020. /** @hidden */
  63021. _areFresnelDirty: boolean;
  63022. /** @hidden */
  63023. _areMiscDirty: boolean;
  63024. /** @hidden */
  63025. _areImageProcessingDirty: boolean;
  63026. /** @hidden */
  63027. _normals: boolean;
  63028. /** @hidden */
  63029. _uvs: boolean;
  63030. /** @hidden */
  63031. _needNormals: boolean;
  63032. /** @hidden */
  63033. _needUVs: boolean;
  63034. /**
  63035. * Specifies if the material needs to be re-calculated
  63036. */
  63037. readonly isDirty: boolean;
  63038. /**
  63039. * Marks the material to indicate that it has been re-calculated
  63040. */
  63041. markAsProcessed(): void;
  63042. /**
  63043. * Marks the material to indicate that it needs to be re-calculated
  63044. */
  63045. markAsUnprocessed(): void;
  63046. /**
  63047. * Marks the material to indicate all of its defines need to be re-calculated
  63048. */
  63049. markAllAsDirty(): void;
  63050. /**
  63051. * Marks the material to indicate that image processing needs to be re-calculated
  63052. */
  63053. markAsImageProcessingDirty(): void;
  63054. /**
  63055. * Marks the material to indicate the lights need to be re-calculated
  63056. */
  63057. markAsLightDirty(): void;
  63058. /**
  63059. * Marks the attribute state as changed
  63060. */
  63061. markAsAttributesDirty(): void;
  63062. /**
  63063. * Marks the texture state as changed
  63064. */
  63065. markAsTexturesDirty(): void;
  63066. /**
  63067. * Marks the fresnel state as changed
  63068. */
  63069. markAsFresnelDirty(): void;
  63070. /**
  63071. * Marks the misc state as changed
  63072. */
  63073. markAsMiscDirty(): void;
  63074. /**
  63075. * Rebuilds the material defines
  63076. */
  63077. rebuild(): void;
  63078. /**
  63079. * Specifies if two material defines are equal
  63080. * @param other - A material define instance to compare to
  63081. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63082. */
  63083. isEqual(other: MaterialDefines): boolean;
  63084. /**
  63085. * Clones this instance's defines to another instance
  63086. * @param other - material defines to clone values to
  63087. */
  63088. cloneTo(other: MaterialDefines): void;
  63089. /**
  63090. * Resets the material define values
  63091. */
  63092. reset(): void;
  63093. /**
  63094. * Converts the material define values to a string
  63095. * @returns - String of material define information
  63096. */
  63097. toString(): string;
  63098. }
  63099. }
  63100. declare module BABYLON {
  63101. /**
  63102. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  63103. */
  63104. export class PerformanceMonitor {
  63105. private _enabled;
  63106. private _rollingFrameTime;
  63107. private _lastFrameTimeMs;
  63108. /**
  63109. * constructor
  63110. * @param frameSampleSize The number of samples required to saturate the sliding window
  63111. */
  63112. constructor(frameSampleSize?: number);
  63113. /**
  63114. * Samples current frame
  63115. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  63116. */
  63117. sampleFrame(timeMs?: number): void;
  63118. /**
  63119. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63120. */
  63121. readonly averageFrameTime: number;
  63122. /**
  63123. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63124. */
  63125. readonly averageFrameTimeVariance: number;
  63126. /**
  63127. * Returns the frame time of the most recent frame
  63128. */
  63129. readonly instantaneousFrameTime: number;
  63130. /**
  63131. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63132. */
  63133. readonly averageFPS: number;
  63134. /**
  63135. * Returns the average framerate in frames per second using the most recent frame time
  63136. */
  63137. readonly instantaneousFPS: number;
  63138. /**
  63139. * Returns true if enough samples have been taken to completely fill the sliding window
  63140. */
  63141. readonly isSaturated: boolean;
  63142. /**
  63143. * Enables contributions to the sliding window sample set
  63144. */
  63145. enable(): void;
  63146. /**
  63147. * Disables contributions to the sliding window sample set
  63148. * Samples will not be interpolated over the disabled period
  63149. */
  63150. disable(): void;
  63151. /**
  63152. * Returns true if sampling is enabled
  63153. */
  63154. readonly isEnabled: boolean;
  63155. /**
  63156. * Resets performance monitor
  63157. */
  63158. reset(): void;
  63159. }
  63160. /**
  63161. * RollingAverage
  63162. *
  63163. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63164. */
  63165. export class RollingAverage {
  63166. /**
  63167. * Current average
  63168. */
  63169. average: number;
  63170. /**
  63171. * Current variance
  63172. */
  63173. variance: number;
  63174. protected _samples: Array<number>;
  63175. protected _sampleCount: number;
  63176. protected _pos: number;
  63177. protected _m2: number;
  63178. /**
  63179. * constructor
  63180. * @param length The number of samples required to saturate the sliding window
  63181. */
  63182. constructor(length: number);
  63183. /**
  63184. * Adds a sample to the sample set
  63185. * @param v The sample value
  63186. */
  63187. add(v: number): void;
  63188. /**
  63189. * Returns previously added values or null if outside of history or outside the sliding window domain
  63190. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63191. * @return Value previously recorded with add() or null if outside of range
  63192. */
  63193. history(i: number): number;
  63194. /**
  63195. * Returns true if enough samples have been taken to completely fill the sliding window
  63196. * @return true if sample-set saturated
  63197. */
  63198. isSaturated(): boolean;
  63199. /**
  63200. * Resets the rolling average (equivalent to 0 samples taken so far)
  63201. */
  63202. reset(): void;
  63203. /**
  63204. * Wraps a value around the sample range boundaries
  63205. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63206. * @return Wrapped position in sample range
  63207. */
  63208. protected _wrapPosition(i: number): number;
  63209. }
  63210. }
  63211. declare module BABYLON {
  63212. /**
  63213. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63214. * The underlying implementation relies on an associative array to ensure the best performances.
  63215. * The value can be anything including 'null' but except 'undefined'
  63216. */
  63217. export class StringDictionary<T> {
  63218. /**
  63219. * This will clear this dictionary and copy the content from the 'source' one.
  63220. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63221. * @param source the dictionary to take the content from and copy to this dictionary
  63222. */
  63223. copyFrom(source: StringDictionary<T>): void;
  63224. /**
  63225. * Get a value based from its key
  63226. * @param key the given key to get the matching value from
  63227. * @return the value if found, otherwise undefined is returned
  63228. */
  63229. get(key: string): T | undefined;
  63230. /**
  63231. * Get a value from its key or add it if it doesn't exist.
  63232. * This method will ensure you that a given key/data will be present in the dictionary.
  63233. * @param key the given key to get the matching value from
  63234. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63235. * The factory will only be invoked if there's no data for the given key.
  63236. * @return the value corresponding to the key.
  63237. */
  63238. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63239. /**
  63240. * Get a value from its key if present in the dictionary otherwise add it
  63241. * @param key the key to get the value from
  63242. * @param val if there's no such key/value pair in the dictionary add it with this value
  63243. * @return the value corresponding to the key
  63244. */
  63245. getOrAdd(key: string, val: T): T;
  63246. /**
  63247. * Check if there's a given key in the dictionary
  63248. * @param key the key to check for
  63249. * @return true if the key is present, false otherwise
  63250. */
  63251. contains(key: string): boolean;
  63252. /**
  63253. * Add a new key and its corresponding value
  63254. * @param key the key to add
  63255. * @param value the value corresponding to the key
  63256. * @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
  63257. */
  63258. add(key: string, value: T): boolean;
  63259. /**
  63260. * Update a specific value associated to a key
  63261. * @param key defines the key to use
  63262. * @param value defines the value to store
  63263. * @returns true if the value was updated (or false if the key was not found)
  63264. */
  63265. set(key: string, value: T): boolean;
  63266. /**
  63267. * Get the element of the given key and remove it from the dictionary
  63268. * @param key defines the key to search
  63269. * @returns the value associated with the key or null if not found
  63270. */
  63271. getAndRemove(key: string): Nullable<T>;
  63272. /**
  63273. * Remove a key/value from the dictionary.
  63274. * @param key the key to remove
  63275. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  63276. */
  63277. remove(key: string): boolean;
  63278. /**
  63279. * Clear the whole content of the dictionary
  63280. */
  63281. clear(): void;
  63282. /**
  63283. * Gets the current count
  63284. */
  63285. readonly count: number;
  63286. /**
  63287. * Execute a callback on each key/val of the dictionary.
  63288. * Note that you can remove any element in this dictionary in the callback implementation
  63289. * @param callback the callback to execute on a given key/value pair
  63290. */
  63291. forEach(callback: (key: string, val: T) => void): void;
  63292. /**
  63293. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63294. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63295. * Note that you can remove any element in this dictionary in the callback implementation
  63296. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63297. * @returns the first item
  63298. */
  63299. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63300. private _count;
  63301. private _data;
  63302. }
  63303. }
  63304. declare module BABYLON {
  63305. /**
  63306. * Helper class that provides a small promise polyfill
  63307. */
  63308. export class PromisePolyfill {
  63309. /**
  63310. * Static function used to check if the polyfill is required
  63311. * If this is the case then the function will inject the polyfill to window.Promise
  63312. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  63313. */
  63314. static Apply(force?: boolean): void;
  63315. }
  63316. }
  63317. declare module BABYLON {
  63318. /**
  63319. * Class used to store data that will be store in GPU memory
  63320. */
  63321. export class Buffer {
  63322. private _engine;
  63323. private _buffer;
  63324. /** @hidden */
  63325. _data: Nullable<DataArray>;
  63326. private _updatable;
  63327. private _instanced;
  63328. /**
  63329. * Gets the byte stride.
  63330. */
  63331. readonly byteStride: number;
  63332. /**
  63333. * Constructor
  63334. * @param engine the engine
  63335. * @param data the data to use for this buffer
  63336. * @param updatable whether the data is updatable
  63337. * @param stride the stride (optional)
  63338. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63339. * @param instanced whether the buffer is instanced (optional)
  63340. * @param useBytes set to true if the stride in in bytes (optional)
  63341. */
  63342. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63343. /**
  63344. * Create a new VertexBuffer based on the current buffer
  63345. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63346. * @param offset defines offset in the buffer (0 by default)
  63347. * @param size defines the size in floats of attributes (position is 3 for instance)
  63348. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63349. * @param instanced defines if the vertex buffer contains indexed data
  63350. * @param useBytes defines if the offset and stride are in bytes
  63351. * @returns the new vertex buffer
  63352. */
  63353. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63354. /**
  63355. * Gets a boolean indicating if the Buffer is updatable?
  63356. * @returns true if the buffer is updatable
  63357. */
  63358. isUpdatable(): boolean;
  63359. /**
  63360. * Gets current buffer's data
  63361. * @returns a DataArray or null
  63362. */
  63363. getData(): Nullable<DataArray>;
  63364. /**
  63365. * Gets underlying native buffer
  63366. * @returns underlying native buffer
  63367. */
  63368. getBuffer(): Nullable<WebGLBuffer>;
  63369. /**
  63370. * Gets the stride in float32 units (i.e. byte stride / 4).
  63371. * May not be an integer if the byte stride is not divisible by 4.
  63372. * DEPRECATED. Use byteStride instead.
  63373. * @returns the stride in float32 units
  63374. */
  63375. getStrideSize(): number;
  63376. /**
  63377. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63378. * @param data defines the data to store
  63379. */
  63380. create(data?: Nullable<DataArray>): void;
  63381. /** @hidden */
  63382. _rebuild(): void;
  63383. /**
  63384. * Update current buffer data
  63385. * @param data defines the data to store
  63386. */
  63387. update(data: DataArray): void;
  63388. /**
  63389. * Updates the data directly.
  63390. * @param data the new data
  63391. * @param offset the new offset
  63392. * @param vertexCount the vertex count (optional)
  63393. * @param useBytes set to true if the offset is in bytes
  63394. */
  63395. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63396. /**
  63397. * Release all resources
  63398. */
  63399. dispose(): void;
  63400. }
  63401. /**
  63402. * Specialized buffer used to store vertex data
  63403. */
  63404. export class VertexBuffer {
  63405. /** @hidden */
  63406. _buffer: Buffer;
  63407. private _kind;
  63408. private _size;
  63409. private _ownsBuffer;
  63410. private _instanced;
  63411. private _instanceDivisor;
  63412. /**
  63413. * The byte type.
  63414. */
  63415. static readonly BYTE: number;
  63416. /**
  63417. * The unsigned byte type.
  63418. */
  63419. static readonly UNSIGNED_BYTE: number;
  63420. /**
  63421. * The short type.
  63422. */
  63423. static readonly SHORT: number;
  63424. /**
  63425. * The unsigned short type.
  63426. */
  63427. static readonly UNSIGNED_SHORT: number;
  63428. /**
  63429. * The integer type.
  63430. */
  63431. static readonly INT: number;
  63432. /**
  63433. * The unsigned integer type.
  63434. */
  63435. static readonly UNSIGNED_INT: number;
  63436. /**
  63437. * The float type.
  63438. */
  63439. static readonly FLOAT: number;
  63440. /**
  63441. * Gets or sets the instance divisor when in instanced mode
  63442. */
  63443. instanceDivisor: number;
  63444. /**
  63445. * Gets the byte stride.
  63446. */
  63447. readonly byteStride: number;
  63448. /**
  63449. * Gets the byte offset.
  63450. */
  63451. readonly byteOffset: number;
  63452. /**
  63453. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63454. */
  63455. readonly normalized: boolean;
  63456. /**
  63457. * Gets the data type of each component in the array.
  63458. */
  63459. readonly type: number;
  63460. /**
  63461. * Constructor
  63462. * @param engine the engine
  63463. * @param data the data to use for this vertex buffer
  63464. * @param kind the vertex buffer kind
  63465. * @param updatable whether the data is updatable
  63466. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63467. * @param stride the stride (optional)
  63468. * @param instanced whether the buffer is instanced (optional)
  63469. * @param offset the offset of the data (optional)
  63470. * @param size the number of components (optional)
  63471. * @param type the type of the component (optional)
  63472. * @param normalized whether the data contains normalized data (optional)
  63473. * @param useBytes set to true if stride and offset are in bytes (optional)
  63474. */
  63475. 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);
  63476. /** @hidden */
  63477. _rebuild(): void;
  63478. /**
  63479. * Returns the kind of the VertexBuffer (string)
  63480. * @returns a string
  63481. */
  63482. getKind(): string;
  63483. /**
  63484. * Gets a boolean indicating if the VertexBuffer is updatable?
  63485. * @returns true if the buffer is updatable
  63486. */
  63487. isUpdatable(): boolean;
  63488. /**
  63489. * Gets current buffer's data
  63490. * @returns a DataArray or null
  63491. */
  63492. getData(): Nullable<DataArray>;
  63493. /**
  63494. * Gets underlying native buffer
  63495. * @returns underlying native buffer
  63496. */
  63497. getBuffer(): Nullable<WebGLBuffer>;
  63498. /**
  63499. * Gets the stride in float32 units (i.e. byte stride / 4).
  63500. * May not be an integer if the byte stride is not divisible by 4.
  63501. * DEPRECATED. Use byteStride instead.
  63502. * @returns the stride in float32 units
  63503. */
  63504. getStrideSize(): number;
  63505. /**
  63506. * Returns the offset as a multiple of the type byte length.
  63507. * DEPRECATED. Use byteOffset instead.
  63508. * @returns the offset in bytes
  63509. */
  63510. getOffset(): number;
  63511. /**
  63512. * Returns the number of components per vertex attribute (integer)
  63513. * @returns the size in float
  63514. */
  63515. getSize(): number;
  63516. /**
  63517. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  63518. * @returns true if this buffer is instanced
  63519. */
  63520. getIsInstanced(): boolean;
  63521. /**
  63522. * Returns the instancing divisor, zero for non-instanced (integer).
  63523. * @returns a number
  63524. */
  63525. getInstanceDivisor(): number;
  63526. /**
  63527. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63528. * @param data defines the data to store
  63529. */
  63530. create(data?: DataArray): void;
  63531. /**
  63532. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  63533. * This function will create a new buffer if the current one is not updatable
  63534. * @param data defines the data to store
  63535. */
  63536. update(data: DataArray): void;
  63537. /**
  63538. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  63539. * Returns the directly updated WebGLBuffer.
  63540. * @param data the new data
  63541. * @param offset the new offset
  63542. * @param useBytes set to true if the offset is in bytes
  63543. */
  63544. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  63545. /**
  63546. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  63547. */
  63548. dispose(): void;
  63549. /**
  63550. * Enumerates each value of this vertex buffer as numbers.
  63551. * @param count the number of values to enumerate
  63552. * @param callback the callback function called for each value
  63553. */
  63554. forEach(count: number, callback: (value: number, index: number) => void): void;
  63555. /**
  63556. * Positions
  63557. */
  63558. static readonly PositionKind: string;
  63559. /**
  63560. * Normals
  63561. */
  63562. static readonly NormalKind: string;
  63563. /**
  63564. * Tangents
  63565. */
  63566. static readonly TangentKind: string;
  63567. /**
  63568. * Texture coordinates
  63569. */
  63570. static readonly UVKind: string;
  63571. /**
  63572. * Texture coordinates 2
  63573. */
  63574. static readonly UV2Kind: string;
  63575. /**
  63576. * Texture coordinates 3
  63577. */
  63578. static readonly UV3Kind: string;
  63579. /**
  63580. * Texture coordinates 4
  63581. */
  63582. static readonly UV4Kind: string;
  63583. /**
  63584. * Texture coordinates 5
  63585. */
  63586. static readonly UV5Kind: string;
  63587. /**
  63588. * Texture coordinates 6
  63589. */
  63590. static readonly UV6Kind: string;
  63591. /**
  63592. * Colors
  63593. */
  63594. static readonly ColorKind: string;
  63595. /**
  63596. * Matrix indices (for bones)
  63597. */
  63598. static readonly MatricesIndicesKind: string;
  63599. /**
  63600. * Matrix weights (for bones)
  63601. */
  63602. static readonly MatricesWeightsKind: string;
  63603. /**
  63604. * Additional matrix indices (for bones)
  63605. */
  63606. static readonly MatricesIndicesExtraKind: string;
  63607. /**
  63608. * Additional matrix weights (for bones)
  63609. */
  63610. static readonly MatricesWeightsExtraKind: string;
  63611. /**
  63612. * Deduces the stride given a kind.
  63613. * @param kind The kind string to deduce
  63614. * @returns The deduced stride
  63615. */
  63616. static DeduceStride(kind: string): number;
  63617. /**
  63618. * Gets the byte length of the given type.
  63619. * @param type the type
  63620. * @returns the number of bytes
  63621. */
  63622. static GetTypeByteLength(type: number): number;
  63623. /**
  63624. * Enumerates each value of the given parameters as numbers.
  63625. * @param data the data to enumerate
  63626. * @param byteOffset the byte offset of the data
  63627. * @param byteStride the byte stride of the data
  63628. * @param componentCount the number of components per element
  63629. * @param componentType the type of the component
  63630. * @param count the total number of components
  63631. * @param normalized whether the data is normalized
  63632. * @param callback the callback function called for each value
  63633. */
  63634. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63635. private static _GetFloatValue;
  63636. }
  63637. }
  63638. declare module BABYLON {
  63639. /**
  63640. * Class representing spherical polynomial coefficients to the 3rd degree
  63641. */
  63642. export class SphericalPolynomial {
  63643. /**
  63644. * The x coefficients of the spherical polynomial
  63645. */
  63646. x: Vector3;
  63647. /**
  63648. * The y coefficients of the spherical polynomial
  63649. */
  63650. y: Vector3;
  63651. /**
  63652. * The z coefficients of the spherical polynomial
  63653. */
  63654. z: Vector3;
  63655. /**
  63656. * The xx coefficients of the spherical polynomial
  63657. */
  63658. xx: Vector3;
  63659. /**
  63660. * The yy coefficients of the spherical polynomial
  63661. */
  63662. yy: Vector3;
  63663. /**
  63664. * The zz coefficients of the spherical polynomial
  63665. */
  63666. zz: Vector3;
  63667. /**
  63668. * The xy coefficients of the spherical polynomial
  63669. */
  63670. xy: Vector3;
  63671. /**
  63672. * The yz coefficients of the spherical polynomial
  63673. */
  63674. yz: Vector3;
  63675. /**
  63676. * The zx coefficients of the spherical polynomial
  63677. */
  63678. zx: Vector3;
  63679. /**
  63680. * Adds an ambient color to the spherical polynomial
  63681. * @param color the color to add
  63682. */
  63683. addAmbient(color: Color3): void;
  63684. /**
  63685. * Scales the spherical polynomial by the given amount
  63686. * @param scale the amount to scale
  63687. */
  63688. scale(scale: number): void;
  63689. /**
  63690. * Gets the spherical polynomial from harmonics
  63691. * @param harmonics the spherical harmonics
  63692. * @returns the spherical polynomial
  63693. */
  63694. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63695. /**
  63696. * Constructs a spherical polynomial from an array.
  63697. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63698. * @returns the spherical polynomial
  63699. */
  63700. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63701. }
  63702. /**
  63703. * Class representing spherical harmonics coefficients to the 3rd degree
  63704. */
  63705. export class SphericalHarmonics {
  63706. /**
  63707. * The l0,0 coefficients of the spherical harmonics
  63708. */
  63709. l00: Vector3;
  63710. /**
  63711. * The l1,-1 coefficients of the spherical harmonics
  63712. */
  63713. l1_1: Vector3;
  63714. /**
  63715. * The l1,0 coefficients of the spherical harmonics
  63716. */
  63717. l10: Vector3;
  63718. /**
  63719. * The l1,1 coefficients of the spherical harmonics
  63720. */
  63721. l11: Vector3;
  63722. /**
  63723. * The l2,-2 coefficients of the spherical harmonics
  63724. */
  63725. l2_2: Vector3;
  63726. /**
  63727. * The l2,-1 coefficients of the spherical harmonics
  63728. */
  63729. l2_1: Vector3;
  63730. /**
  63731. * The l2,0 coefficients of the spherical harmonics
  63732. */
  63733. l20: Vector3;
  63734. /**
  63735. * The l2,1 coefficients of the spherical harmonics
  63736. */
  63737. l21: Vector3;
  63738. /**
  63739. * The l2,2 coefficients of the spherical harmonics
  63740. */
  63741. lL22: Vector3;
  63742. /**
  63743. * Adds a light to the spherical harmonics
  63744. * @param direction the direction of the light
  63745. * @param color the color of the light
  63746. * @param deltaSolidAngle the delta solid angle of the light
  63747. */
  63748. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63749. /**
  63750. * Scales the spherical harmonics by the given amount
  63751. * @param scale the amount to scale
  63752. */
  63753. scale(scale: number): void;
  63754. /**
  63755. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63756. *
  63757. * ```
  63758. * E_lm = A_l * L_lm
  63759. * ```
  63760. *
  63761. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63762. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63763. * the scaling factors are given in equation 9.
  63764. */
  63765. convertIncidentRadianceToIrradiance(): void;
  63766. /**
  63767. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63768. *
  63769. * ```
  63770. * L = (1/pi) * E * rho
  63771. * ```
  63772. *
  63773. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63774. */
  63775. convertIrradianceToLambertianRadiance(): void;
  63776. /**
  63777. * Gets the spherical harmonics from polynomial
  63778. * @param polynomial the spherical polynomial
  63779. * @returns the spherical harmonics
  63780. */
  63781. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63782. /**
  63783. * Constructs a spherical harmonics from an array.
  63784. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63785. * @returns the spherical harmonics
  63786. */
  63787. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63788. }
  63789. }
  63790. declare module BABYLON {
  63791. /**
  63792. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63793. */
  63794. export interface CubeMapInfo {
  63795. /**
  63796. * The pixel array for the front face.
  63797. * This is stored in format, left to right, up to down format.
  63798. */
  63799. front: Nullable<ArrayBufferView>;
  63800. /**
  63801. * The pixel array for the back face.
  63802. * This is stored in format, left to right, up to down format.
  63803. */
  63804. back: Nullable<ArrayBufferView>;
  63805. /**
  63806. * The pixel array for the left face.
  63807. * This is stored in format, left to right, up to down format.
  63808. */
  63809. left: Nullable<ArrayBufferView>;
  63810. /**
  63811. * The pixel array for the right face.
  63812. * This is stored in format, left to right, up to down format.
  63813. */
  63814. right: Nullable<ArrayBufferView>;
  63815. /**
  63816. * The pixel array for the up face.
  63817. * This is stored in format, left to right, up to down format.
  63818. */
  63819. up: Nullable<ArrayBufferView>;
  63820. /**
  63821. * The pixel array for the down face.
  63822. * This is stored in format, left to right, up to down format.
  63823. */
  63824. down: Nullable<ArrayBufferView>;
  63825. /**
  63826. * The size of the cubemap stored.
  63827. *
  63828. * Each faces will be size * size pixels.
  63829. */
  63830. size: number;
  63831. /**
  63832. * The format of the texture.
  63833. *
  63834. * RGBA, RGB.
  63835. */
  63836. format: number;
  63837. /**
  63838. * The type of the texture data.
  63839. *
  63840. * UNSIGNED_INT, FLOAT.
  63841. */
  63842. type: number;
  63843. /**
  63844. * Specifies whether the texture is in gamma space.
  63845. */
  63846. gammaSpace: boolean;
  63847. }
  63848. /**
  63849. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63850. */
  63851. export class PanoramaToCubeMapTools {
  63852. private static FACE_FRONT;
  63853. private static FACE_BACK;
  63854. private static FACE_RIGHT;
  63855. private static FACE_LEFT;
  63856. private static FACE_DOWN;
  63857. private static FACE_UP;
  63858. /**
  63859. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63860. *
  63861. * @param float32Array The source data.
  63862. * @param inputWidth The width of the input panorama.
  63863. * @param inputHeight The height of the input panorama.
  63864. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63865. * @return The cubemap data
  63866. */
  63867. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63868. private static CreateCubemapTexture;
  63869. private static CalcProjectionSpherical;
  63870. }
  63871. }
  63872. declare module BABYLON {
  63873. /**
  63874. * Helper class dealing with the extraction of spherical polynomial dataArray
  63875. * from a cube map.
  63876. */
  63877. export class CubeMapToSphericalPolynomialTools {
  63878. private static FileFaces;
  63879. /**
  63880. * Converts a texture to the according Spherical Polynomial data.
  63881. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63882. *
  63883. * @param texture The texture to extract the information from.
  63884. * @return The Spherical Polynomial data.
  63885. */
  63886. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63887. /**
  63888. * Converts a cubemap to the according Spherical Polynomial data.
  63889. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63890. *
  63891. * @param cubeInfo The Cube map to extract the information from.
  63892. * @return The Spherical Polynomial data.
  63893. */
  63894. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63895. }
  63896. }
  63897. declare module BABYLON {
  63898. /**
  63899. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63900. * during the life time of the application.
  63901. */
  63902. export class EngineStore {
  63903. /** Gets the list of created engines */
  63904. static Instances: Engine[];
  63905. /**
  63906. * Gets the latest created engine
  63907. */
  63908. static readonly LastCreatedEngine: Nullable<Engine>;
  63909. /**
  63910. * Gets the latest created scene
  63911. */
  63912. static readonly LastCreatedScene: Nullable<Scene>;
  63913. }
  63914. }
  63915. declare module BABYLON {
  63916. /**
  63917. * Define options used to create a render target texture
  63918. */
  63919. export class RenderTargetCreationOptions {
  63920. /**
  63921. * Specifies is mipmaps must be generated
  63922. */
  63923. generateMipMaps?: boolean;
  63924. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63925. generateDepthBuffer?: boolean;
  63926. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63927. generateStencilBuffer?: boolean;
  63928. /** Defines texture type (int by default) */
  63929. type?: number;
  63930. /** Defines sampling mode (trilinear by default) */
  63931. samplingMode?: number;
  63932. /** Defines format (RGBA by default) */
  63933. format?: number;
  63934. }
  63935. }
  63936. declare module BABYLON {
  63937. /**
  63938. * @hidden
  63939. **/
  63940. export class _AlphaState {
  63941. private _isAlphaBlendDirty;
  63942. private _isBlendFunctionParametersDirty;
  63943. private _isBlendEquationParametersDirty;
  63944. private _isBlendConstantsDirty;
  63945. private _alphaBlend;
  63946. private _blendFunctionParameters;
  63947. private _blendEquationParameters;
  63948. private _blendConstants;
  63949. /**
  63950. * Initializes the state.
  63951. */
  63952. constructor();
  63953. readonly isDirty: boolean;
  63954. alphaBlend: boolean;
  63955. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63956. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63957. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63958. reset(): void;
  63959. apply(gl: WebGLRenderingContext): void;
  63960. }
  63961. }
  63962. declare module BABYLON {
  63963. /**
  63964. * @hidden
  63965. **/
  63966. export class _DepthCullingState {
  63967. private _isDepthTestDirty;
  63968. private _isDepthMaskDirty;
  63969. private _isDepthFuncDirty;
  63970. private _isCullFaceDirty;
  63971. private _isCullDirty;
  63972. private _isZOffsetDirty;
  63973. private _isFrontFaceDirty;
  63974. private _depthTest;
  63975. private _depthMask;
  63976. private _depthFunc;
  63977. private _cull;
  63978. private _cullFace;
  63979. private _zOffset;
  63980. private _frontFace;
  63981. /**
  63982. * Initializes the state.
  63983. */
  63984. constructor();
  63985. readonly isDirty: boolean;
  63986. zOffset: number;
  63987. cullFace: Nullable<number>;
  63988. cull: Nullable<boolean>;
  63989. depthFunc: Nullable<number>;
  63990. depthMask: boolean;
  63991. depthTest: boolean;
  63992. frontFace: Nullable<number>;
  63993. reset(): void;
  63994. apply(gl: WebGLRenderingContext): void;
  63995. }
  63996. }
  63997. declare module BABYLON {
  63998. /**
  63999. * @hidden
  64000. **/
  64001. export class _StencilState {
  64002. /** 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 */
  64003. static readonly ALWAYS: number;
  64004. /** Passed to stencilOperation to specify that stencil value must be kept */
  64005. static readonly KEEP: number;
  64006. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64007. static readonly REPLACE: number;
  64008. private _isStencilTestDirty;
  64009. private _isStencilMaskDirty;
  64010. private _isStencilFuncDirty;
  64011. private _isStencilOpDirty;
  64012. private _stencilTest;
  64013. private _stencilMask;
  64014. private _stencilFunc;
  64015. private _stencilFuncRef;
  64016. private _stencilFuncMask;
  64017. private _stencilOpStencilFail;
  64018. private _stencilOpDepthFail;
  64019. private _stencilOpStencilDepthPass;
  64020. readonly isDirty: boolean;
  64021. stencilFunc: number;
  64022. stencilFuncRef: number;
  64023. stencilFuncMask: number;
  64024. stencilOpStencilFail: number;
  64025. stencilOpDepthFail: number;
  64026. stencilOpStencilDepthPass: number;
  64027. stencilMask: number;
  64028. stencilTest: boolean;
  64029. constructor();
  64030. reset(): void;
  64031. apply(gl: WebGLRenderingContext): void;
  64032. }
  64033. }
  64034. declare module BABYLON {
  64035. /**
  64036. * @hidden
  64037. **/
  64038. export class _TimeToken {
  64039. _startTimeQuery: Nullable<WebGLQuery>;
  64040. _endTimeQuery: Nullable<WebGLQuery>;
  64041. _timeElapsedQuery: Nullable<WebGLQuery>;
  64042. _timeElapsedQueryEnded: boolean;
  64043. }
  64044. }
  64045. declare module BABYLON {
  64046. /**
  64047. * Internal interface used to track InternalTexture already bound to the GL context
  64048. */
  64049. export interface IInternalTextureTracker {
  64050. /**
  64051. * Gets or set the previous tracker in the list
  64052. */
  64053. previous: Nullable<IInternalTextureTracker>;
  64054. /**
  64055. * Gets or set the next tracker in the list
  64056. */
  64057. next: Nullable<IInternalTextureTracker>;
  64058. }
  64059. /**
  64060. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  64061. */
  64062. export class DummyInternalTextureTracker {
  64063. /**
  64064. * Gets or set the previous tracker in the list
  64065. */
  64066. previous: Nullable<IInternalTextureTracker>;
  64067. /**
  64068. * Gets or set the next tracker in the list
  64069. */
  64070. next: Nullable<IInternalTextureTracker>;
  64071. }
  64072. }
  64073. declare module BABYLON {
  64074. /**
  64075. * Class used to store data associated with WebGL texture data for the engine
  64076. * This class should not be used directly
  64077. */
  64078. export class InternalTexture implements IInternalTextureTracker {
  64079. /** hidden */
  64080. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  64081. /**
  64082. * The source of the texture data is unknown
  64083. */
  64084. static DATASOURCE_UNKNOWN: number;
  64085. /**
  64086. * Texture data comes from an URL
  64087. */
  64088. static DATASOURCE_URL: number;
  64089. /**
  64090. * Texture data is only used for temporary storage
  64091. */
  64092. static DATASOURCE_TEMP: number;
  64093. /**
  64094. * Texture data comes from raw data (ArrayBuffer)
  64095. */
  64096. static DATASOURCE_RAW: number;
  64097. /**
  64098. * Texture content is dynamic (video or dynamic texture)
  64099. */
  64100. static DATASOURCE_DYNAMIC: number;
  64101. /**
  64102. * Texture content is generated by rendering to it
  64103. */
  64104. static DATASOURCE_RENDERTARGET: number;
  64105. /**
  64106. * Texture content is part of a multi render target process
  64107. */
  64108. static DATASOURCE_MULTIRENDERTARGET: number;
  64109. /**
  64110. * Texture data comes from a cube data file
  64111. */
  64112. static DATASOURCE_CUBE: number;
  64113. /**
  64114. * Texture data comes from a raw cube data
  64115. */
  64116. static DATASOURCE_CUBERAW: number;
  64117. /**
  64118. * Texture data come from a prefiltered cube data file
  64119. */
  64120. static DATASOURCE_CUBEPREFILTERED: number;
  64121. /**
  64122. * Texture content is raw 3D data
  64123. */
  64124. static DATASOURCE_RAW3D: number;
  64125. /**
  64126. * Texture content is a depth texture
  64127. */
  64128. static DATASOURCE_DEPTHTEXTURE: number;
  64129. /**
  64130. * Texture data comes from a raw cube data encoded with RGBD
  64131. */
  64132. static DATASOURCE_CUBERAW_RGBD: number;
  64133. /**
  64134. * Defines if the texture is ready
  64135. */
  64136. isReady: boolean;
  64137. /**
  64138. * Defines if the texture is a cube texture
  64139. */
  64140. isCube: boolean;
  64141. /**
  64142. * Defines if the texture contains 3D data
  64143. */
  64144. is3D: boolean;
  64145. /**
  64146. * Gets the URL used to load this texture
  64147. */
  64148. url: string;
  64149. /**
  64150. * Gets the sampling mode of the texture
  64151. */
  64152. samplingMode: number;
  64153. /**
  64154. * Gets a boolean indicating if the texture needs mipmaps generation
  64155. */
  64156. generateMipMaps: boolean;
  64157. /**
  64158. * Gets the number of samples used by the texture (WebGL2+ only)
  64159. */
  64160. samples: number;
  64161. /**
  64162. * Gets the type of the texture (int, float...)
  64163. */
  64164. type: number;
  64165. /**
  64166. * Gets the format of the texture (RGB, RGBA...)
  64167. */
  64168. format: number;
  64169. /**
  64170. * Observable called when the texture is loaded
  64171. */
  64172. onLoadedObservable: Observable<InternalTexture>;
  64173. /**
  64174. * Gets the width of the texture
  64175. */
  64176. width: number;
  64177. /**
  64178. * Gets the height of the texture
  64179. */
  64180. height: number;
  64181. /**
  64182. * Gets the depth of the texture
  64183. */
  64184. depth: number;
  64185. /**
  64186. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64187. */
  64188. baseWidth: number;
  64189. /**
  64190. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64191. */
  64192. baseHeight: number;
  64193. /**
  64194. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64195. */
  64196. baseDepth: number;
  64197. /**
  64198. * Gets a boolean indicating if the texture is inverted on Y axis
  64199. */
  64200. invertY: boolean;
  64201. /**
  64202. * Gets or set the previous tracker in the list
  64203. */
  64204. previous: Nullable<IInternalTextureTracker>;
  64205. /**
  64206. * Gets or set the next tracker in the list
  64207. */
  64208. next: Nullable<IInternalTextureTracker>;
  64209. /** @hidden */
  64210. _invertVScale: boolean;
  64211. /** @hidden */
  64212. _initialSlot: number;
  64213. /** @hidden */
  64214. _designatedSlot: number;
  64215. /** @hidden */
  64216. _dataSource: number;
  64217. /** @hidden */
  64218. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64219. /** @hidden */
  64220. _bufferView: Nullable<ArrayBufferView>;
  64221. /** @hidden */
  64222. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64223. /** @hidden */
  64224. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64225. /** @hidden */
  64226. _size: number;
  64227. /** @hidden */
  64228. _extension: string;
  64229. /** @hidden */
  64230. _files: Nullable<string[]>;
  64231. /** @hidden */
  64232. _workingCanvas: HTMLCanvasElement;
  64233. /** @hidden */
  64234. _workingContext: CanvasRenderingContext2D;
  64235. /** @hidden */
  64236. _framebuffer: Nullable<WebGLFramebuffer>;
  64237. /** @hidden */
  64238. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64239. /** @hidden */
  64240. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  64241. /** @hidden */
  64242. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  64243. /** @hidden */
  64244. _attachments: Nullable<number[]>;
  64245. /** @hidden */
  64246. _cachedCoordinatesMode: Nullable<number>;
  64247. /** @hidden */
  64248. _cachedWrapU: Nullable<number>;
  64249. /** @hidden */
  64250. _cachedWrapV: Nullable<number>;
  64251. /** @hidden */
  64252. _cachedWrapR: Nullable<number>;
  64253. /** @hidden */
  64254. _cachedAnisotropicFilteringLevel: Nullable<number>;
  64255. /** @hidden */
  64256. _isDisabled: boolean;
  64257. /** @hidden */
  64258. _compression: Nullable<string>;
  64259. /** @hidden */
  64260. _generateStencilBuffer: boolean;
  64261. /** @hidden */
  64262. _generateDepthBuffer: boolean;
  64263. /** @hidden */
  64264. _comparisonFunction: number;
  64265. /** @hidden */
  64266. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  64267. /** @hidden */
  64268. _lodGenerationScale: number;
  64269. /** @hidden */
  64270. _lodGenerationOffset: number;
  64271. /** @hidden */
  64272. _lodTextureHigh: BaseTexture;
  64273. /** @hidden */
  64274. _lodTextureMid: BaseTexture;
  64275. /** @hidden */
  64276. _lodTextureLow: BaseTexture;
  64277. /** @hidden */
  64278. _isRGBD: boolean;
  64279. /** @hidden */
  64280. _webGLTexture: Nullable<WebGLTexture>;
  64281. /** @hidden */
  64282. _references: number;
  64283. private _engine;
  64284. /**
  64285. * Gets the Engine the texture belongs to.
  64286. * @returns The babylon engine
  64287. */
  64288. getEngine(): Engine;
  64289. /**
  64290. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  64291. */
  64292. readonly dataSource: number;
  64293. /**
  64294. * Creates a new InternalTexture
  64295. * @param engine defines the engine to use
  64296. * @param dataSource defines the type of data that will be used
  64297. * @param delayAllocation if the texture allocation should be delayed (default: false)
  64298. */
  64299. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  64300. /**
  64301. * Increments the number of references (ie. the number of Texture that point to it)
  64302. */
  64303. incrementReferences(): void;
  64304. /**
  64305. * Change the size of the texture (not the size of the content)
  64306. * @param width defines the new width
  64307. * @param height defines the new height
  64308. * @param depth defines the new depth (1 by default)
  64309. */
  64310. updateSize(width: int, height: int, depth?: int): void;
  64311. /** @hidden */
  64312. _rebuild(): void;
  64313. /** @hidden */
  64314. _swapAndDie(target: InternalTexture): void;
  64315. /**
  64316. * Dispose the current allocated resources
  64317. */
  64318. dispose(): void;
  64319. }
  64320. }
  64321. declare module BABYLON {
  64322. /**
  64323. * This represents the main contract an easing function should follow.
  64324. * Easing functions are used throughout the animation system.
  64325. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64326. */
  64327. export interface IEasingFunction {
  64328. /**
  64329. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64330. * of the easing function.
  64331. * The link below provides some of the most common examples of easing functions.
  64332. * @see https://easings.net/
  64333. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64334. * @returns the corresponding value on the curve defined by the easing function
  64335. */
  64336. ease(gradient: number): number;
  64337. }
  64338. /**
  64339. * Base class used for every default easing function.
  64340. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64341. */
  64342. export class EasingFunction implements IEasingFunction {
  64343. /**
  64344. * Interpolation follows the mathematical formula associated with the easing function.
  64345. */
  64346. static readonly EASINGMODE_EASEIN: number;
  64347. /**
  64348. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64349. */
  64350. static readonly EASINGMODE_EASEOUT: number;
  64351. /**
  64352. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64353. */
  64354. static readonly EASINGMODE_EASEINOUT: number;
  64355. private _easingMode;
  64356. /**
  64357. * Sets the easing mode of the current function.
  64358. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64359. */
  64360. setEasingMode(easingMode: number): void;
  64361. /**
  64362. * Gets the current easing mode.
  64363. * @returns the easing mode
  64364. */
  64365. getEasingMode(): number;
  64366. /**
  64367. * @hidden
  64368. */
  64369. easeInCore(gradient: number): number;
  64370. /**
  64371. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64372. * of the easing function.
  64373. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64374. * @returns the corresponding value on the curve defined by the easing function
  64375. */
  64376. ease(gradient: number): number;
  64377. }
  64378. /**
  64379. * Easing function with a circle shape (see link below).
  64380. * @see https://easings.net/#easeInCirc
  64381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64382. */
  64383. export class CircleEase extends EasingFunction implements IEasingFunction {
  64384. /** @hidden */
  64385. easeInCore(gradient: number): number;
  64386. }
  64387. /**
  64388. * Easing function with a ease back shape (see link below).
  64389. * @see https://easings.net/#easeInBack
  64390. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64391. */
  64392. export class BackEase extends EasingFunction implements IEasingFunction {
  64393. /** Defines the amplitude of the function */
  64394. amplitude: number;
  64395. /**
  64396. * Instantiates a back ease easing
  64397. * @see https://easings.net/#easeInBack
  64398. * @param amplitude Defines the amplitude of the function
  64399. */
  64400. constructor(
  64401. /** Defines the amplitude of the function */
  64402. amplitude?: number);
  64403. /** @hidden */
  64404. easeInCore(gradient: number): number;
  64405. }
  64406. /**
  64407. * Easing function with a bouncing shape (see link below).
  64408. * @see https://easings.net/#easeInBounce
  64409. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64410. */
  64411. export class BounceEase extends EasingFunction implements IEasingFunction {
  64412. /** Defines the number of bounces */
  64413. bounces: number;
  64414. /** Defines the amplitude of the bounce */
  64415. bounciness: number;
  64416. /**
  64417. * Instantiates a bounce easing
  64418. * @see https://easings.net/#easeInBounce
  64419. * @param bounces Defines the number of bounces
  64420. * @param bounciness Defines the amplitude of the bounce
  64421. */
  64422. constructor(
  64423. /** Defines the number of bounces */
  64424. bounces?: number,
  64425. /** Defines the amplitude of the bounce */
  64426. bounciness?: number);
  64427. /** @hidden */
  64428. easeInCore(gradient: number): number;
  64429. }
  64430. /**
  64431. * Easing function with a power of 3 shape (see link below).
  64432. * @see https://easings.net/#easeInCubic
  64433. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64434. */
  64435. export class CubicEase extends EasingFunction implements IEasingFunction {
  64436. /** @hidden */
  64437. easeInCore(gradient: number): number;
  64438. }
  64439. /**
  64440. * Easing function with an elastic shape (see link below).
  64441. * @see https://easings.net/#easeInElastic
  64442. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64443. */
  64444. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64445. /** Defines the number of oscillations*/
  64446. oscillations: number;
  64447. /** Defines the amplitude of the oscillations*/
  64448. springiness: number;
  64449. /**
  64450. * Instantiates an elastic easing function
  64451. * @see https://easings.net/#easeInElastic
  64452. * @param oscillations Defines the number of oscillations
  64453. * @param springiness Defines the amplitude of the oscillations
  64454. */
  64455. constructor(
  64456. /** Defines the number of oscillations*/
  64457. oscillations?: number,
  64458. /** Defines the amplitude of the oscillations*/
  64459. springiness?: number);
  64460. /** @hidden */
  64461. easeInCore(gradient: number): number;
  64462. }
  64463. /**
  64464. * Easing function with an exponential shape (see link below).
  64465. * @see https://easings.net/#easeInExpo
  64466. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64467. */
  64468. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64469. /** Defines the exponent of the function */
  64470. exponent: number;
  64471. /**
  64472. * Instantiates an exponential easing function
  64473. * @see https://easings.net/#easeInExpo
  64474. * @param exponent Defines the exponent of the function
  64475. */
  64476. constructor(
  64477. /** Defines the exponent of the function */
  64478. exponent?: number);
  64479. /** @hidden */
  64480. easeInCore(gradient: number): number;
  64481. }
  64482. /**
  64483. * Easing function with a power shape (see link below).
  64484. * @see https://easings.net/#easeInQuad
  64485. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64486. */
  64487. export class PowerEase extends EasingFunction implements IEasingFunction {
  64488. /** Defines the power of the function */
  64489. power: number;
  64490. /**
  64491. * Instantiates an power base easing function
  64492. * @see https://easings.net/#easeInQuad
  64493. * @param power Defines the power of the function
  64494. */
  64495. constructor(
  64496. /** Defines the power of the function */
  64497. power?: number);
  64498. /** @hidden */
  64499. easeInCore(gradient: number): number;
  64500. }
  64501. /**
  64502. * Easing function with a power of 2 shape (see link below).
  64503. * @see https://easings.net/#easeInQuad
  64504. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64505. */
  64506. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  64507. /** @hidden */
  64508. easeInCore(gradient: number): number;
  64509. }
  64510. /**
  64511. * Easing function with a power of 4 shape (see link below).
  64512. * @see https://easings.net/#easeInQuart
  64513. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64514. */
  64515. export class QuarticEase extends EasingFunction implements IEasingFunction {
  64516. /** @hidden */
  64517. easeInCore(gradient: number): number;
  64518. }
  64519. /**
  64520. * Easing function with a power of 5 shape (see link below).
  64521. * @see https://easings.net/#easeInQuint
  64522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64523. */
  64524. export class QuinticEase extends EasingFunction implements IEasingFunction {
  64525. /** @hidden */
  64526. easeInCore(gradient: number): number;
  64527. }
  64528. /**
  64529. * Easing function with a sin shape (see link below).
  64530. * @see https://easings.net/#easeInSine
  64531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64532. */
  64533. export class SineEase extends EasingFunction implements IEasingFunction {
  64534. /** @hidden */
  64535. easeInCore(gradient: number): number;
  64536. }
  64537. /**
  64538. * Easing function with a bezier shape (see link below).
  64539. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64540. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64541. */
  64542. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  64543. /** Defines the x component of the start tangent in the bezier curve */
  64544. x1: number;
  64545. /** Defines the y component of the start tangent in the bezier curve */
  64546. y1: number;
  64547. /** Defines the x component of the end tangent in the bezier curve */
  64548. x2: number;
  64549. /** Defines the y component of the end tangent in the bezier curve */
  64550. y2: number;
  64551. /**
  64552. * Instantiates a bezier function
  64553. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64554. * @param x1 Defines the x component of the start tangent in the bezier curve
  64555. * @param y1 Defines the y component of the start tangent in the bezier curve
  64556. * @param x2 Defines the x component of the end tangent in the bezier curve
  64557. * @param y2 Defines the y component of the end tangent in the bezier curve
  64558. */
  64559. constructor(
  64560. /** Defines the x component of the start tangent in the bezier curve */
  64561. x1?: number,
  64562. /** Defines the y component of the start tangent in the bezier curve */
  64563. y1?: number,
  64564. /** Defines the x component of the end tangent in the bezier curve */
  64565. x2?: number,
  64566. /** Defines the y component of the end tangent in the bezier curve */
  64567. y2?: number);
  64568. /** @hidden */
  64569. easeInCore(gradient: number): number;
  64570. }
  64571. }
  64572. declare module BABYLON {
  64573. /**
  64574. * Defines an interface which represents an animation key frame
  64575. */
  64576. export interface IAnimationKey {
  64577. /**
  64578. * Frame of the key frame
  64579. */
  64580. frame: number;
  64581. /**
  64582. * Value at the specifies key frame
  64583. */
  64584. value: any;
  64585. /**
  64586. * The input tangent for the cubic hermite spline
  64587. */
  64588. inTangent?: any;
  64589. /**
  64590. * The output tangent for the cubic hermite spline
  64591. */
  64592. outTangent?: any;
  64593. /**
  64594. * The animation interpolation type
  64595. */
  64596. interpolation?: AnimationKeyInterpolation;
  64597. }
  64598. /**
  64599. * Enum for the animation key frame interpolation type
  64600. */
  64601. export enum AnimationKeyInterpolation {
  64602. /**
  64603. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64604. */
  64605. STEP = 1
  64606. }
  64607. }
  64608. declare module BABYLON {
  64609. /**
  64610. * Represents the range of an animation
  64611. */
  64612. export class AnimationRange {
  64613. /**The name of the animation range**/
  64614. name: string;
  64615. /**The starting frame of the animation */
  64616. from: number;
  64617. /**The ending frame of the animation*/
  64618. to: number;
  64619. /**
  64620. * Initializes the range of an animation
  64621. * @param name The name of the animation range
  64622. * @param from The starting frame of the animation
  64623. * @param to The ending frame of the animation
  64624. */
  64625. constructor(
  64626. /**The name of the animation range**/
  64627. name: string,
  64628. /**The starting frame of the animation */
  64629. from: number,
  64630. /**The ending frame of the animation*/
  64631. to: number);
  64632. /**
  64633. * Makes a copy of the animation range
  64634. * @returns A copy of the animation range
  64635. */
  64636. clone(): AnimationRange;
  64637. }
  64638. }
  64639. declare module BABYLON {
  64640. /**
  64641. * Composed of a frame, and an action function
  64642. */
  64643. export class AnimationEvent {
  64644. /** The frame for which the event is triggered **/
  64645. frame: number;
  64646. /** The event to perform when triggered **/
  64647. action: (currentFrame: number) => void;
  64648. /** Specifies if the event should be triggered only once**/
  64649. onlyOnce?: boolean | undefined;
  64650. /**
  64651. * Specifies if the animation event is done
  64652. */
  64653. isDone: boolean;
  64654. /**
  64655. * Initializes the animation event
  64656. * @param frame The frame for which the event is triggered
  64657. * @param action The event to perform when triggered
  64658. * @param onlyOnce Specifies if the event should be triggered only once
  64659. */
  64660. constructor(
  64661. /** The frame for which the event is triggered **/
  64662. frame: number,
  64663. /** The event to perform when triggered **/
  64664. action: (currentFrame: number) => void,
  64665. /** Specifies if the event should be triggered only once**/
  64666. onlyOnce?: boolean | undefined);
  64667. /** @hidden */
  64668. _clone(): AnimationEvent;
  64669. }
  64670. }
  64671. declare module BABYLON {
  64672. /**
  64673. * Interface used to define a behavior
  64674. */
  64675. export interface Behavior<T> {
  64676. /** gets or sets behavior's name */
  64677. name: string;
  64678. /**
  64679. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64680. */
  64681. init(): void;
  64682. /**
  64683. * Called when the behavior is attached to a target
  64684. * @param target defines the target where the behavior is attached to
  64685. */
  64686. attach(target: T): void;
  64687. /**
  64688. * Called when the behavior is detached from its target
  64689. */
  64690. detach(): void;
  64691. }
  64692. /**
  64693. * Interface implemented by classes supporting behaviors
  64694. */
  64695. export interface IBehaviorAware<T> {
  64696. /**
  64697. * Attach a behavior
  64698. * @param behavior defines the behavior to attach
  64699. * @returns the current host
  64700. */
  64701. addBehavior(behavior: Behavior<T>): T;
  64702. /**
  64703. * Remove a behavior from the current object
  64704. * @param behavior defines the behavior to detach
  64705. * @returns the current host
  64706. */
  64707. removeBehavior(behavior: Behavior<T>): T;
  64708. /**
  64709. * Gets a behavior using its name to search
  64710. * @param name defines the name to search
  64711. * @returns the behavior or null if not found
  64712. */
  64713. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64714. }
  64715. }
  64716. declare module BABYLON {
  64717. /**
  64718. * @hidden
  64719. */
  64720. export class IntersectionInfo {
  64721. bu: Nullable<number>;
  64722. bv: Nullable<number>;
  64723. distance: number;
  64724. faceId: number;
  64725. subMeshId: number;
  64726. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64727. }
  64728. }
  64729. declare module BABYLON {
  64730. /**
  64731. * Class used to store bounding sphere information
  64732. */
  64733. export class BoundingSphere {
  64734. /**
  64735. * Gets the center of the bounding sphere in local space
  64736. */
  64737. readonly center: Vector3;
  64738. /**
  64739. * Radius of the bounding sphere in local space
  64740. */
  64741. radius: number;
  64742. /**
  64743. * Gets the center of the bounding sphere in world space
  64744. */
  64745. readonly centerWorld: Vector3;
  64746. /**
  64747. * Radius of the bounding sphere in world space
  64748. */
  64749. radiusWorld: number;
  64750. /**
  64751. * Gets the minimum vector in local space
  64752. */
  64753. readonly minimum: Vector3;
  64754. /**
  64755. * Gets the maximum vector in local space
  64756. */
  64757. readonly maximum: Vector3;
  64758. private _worldMatrix;
  64759. private static readonly TmpVector3;
  64760. /**
  64761. * Creates a new bounding sphere
  64762. * @param min defines the minimum vector (in local space)
  64763. * @param max defines the maximum vector (in local space)
  64764. * @param worldMatrix defines the new world matrix
  64765. */
  64766. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64767. /**
  64768. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64769. * @param min defines the new minimum vector (in local space)
  64770. * @param max defines the new maximum vector (in local space)
  64771. * @param worldMatrix defines the new world matrix
  64772. */
  64773. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64774. /**
  64775. * Scale the current bounding sphere by applying a scale factor
  64776. * @param factor defines the scale factor to apply
  64777. * @returns the current bounding box
  64778. */
  64779. scale(factor: number): BoundingSphere;
  64780. /**
  64781. * Gets the world matrix of the bounding box
  64782. * @returns a matrix
  64783. */
  64784. getWorldMatrix(): DeepImmutable<Matrix>;
  64785. /** @hidden */
  64786. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64787. /**
  64788. * Tests if the bounding sphere is intersecting the frustum planes
  64789. * @param frustumPlanes defines the frustum planes to test
  64790. * @returns true if there is an intersection
  64791. */
  64792. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64793. /**
  64794. * Tests if the bounding sphere center is in between the frustum planes.
  64795. * Used for optimistic fast inclusion.
  64796. * @param frustumPlanes defines the frustum planes to test
  64797. * @returns true if the sphere center is in between the frustum planes
  64798. */
  64799. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64800. /**
  64801. * Tests if a point is inside the bounding sphere
  64802. * @param point defines the point to test
  64803. * @returns true if the point is inside the bounding sphere
  64804. */
  64805. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64806. /**
  64807. * Checks if two sphere intersct
  64808. * @param sphere0 sphere 0
  64809. * @param sphere1 sphere 1
  64810. * @returns true if the speres intersect
  64811. */
  64812. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64813. }
  64814. }
  64815. declare module BABYLON {
  64816. /**
  64817. * Class used to store bounding box information
  64818. */
  64819. export class BoundingBox implements ICullable {
  64820. /**
  64821. * Gets the 8 vectors representing the bounding box in local space
  64822. */
  64823. readonly vectors: Vector3[];
  64824. /**
  64825. * Gets the center of the bounding box in local space
  64826. */
  64827. readonly center: Vector3;
  64828. /**
  64829. * Gets the center of the bounding box in world space
  64830. */
  64831. readonly centerWorld: Vector3;
  64832. /**
  64833. * Gets the extend size in local space
  64834. */
  64835. readonly extendSize: Vector3;
  64836. /**
  64837. * Gets the extend size in world space
  64838. */
  64839. readonly extendSizeWorld: Vector3;
  64840. /**
  64841. * Gets the OBB (object bounding box) directions
  64842. */
  64843. readonly directions: Vector3[];
  64844. /**
  64845. * Gets the 8 vectors representing the bounding box in world space
  64846. */
  64847. readonly vectorsWorld: Vector3[];
  64848. /**
  64849. * Gets the minimum vector in world space
  64850. */
  64851. readonly minimumWorld: Vector3;
  64852. /**
  64853. * Gets the maximum vector in world space
  64854. */
  64855. readonly maximumWorld: Vector3;
  64856. /**
  64857. * Gets the minimum vector in local space
  64858. */
  64859. readonly minimum: Vector3;
  64860. /**
  64861. * Gets the maximum vector in local space
  64862. */
  64863. readonly maximum: Vector3;
  64864. private _worldMatrix;
  64865. private static readonly TmpVector3;
  64866. /**
  64867. * @hidden
  64868. */
  64869. _tag: number;
  64870. /**
  64871. * Creates a new bounding box
  64872. * @param min defines the minimum vector (in local space)
  64873. * @param max defines the maximum vector (in local space)
  64874. * @param worldMatrix defines the new world matrix
  64875. */
  64876. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64877. /**
  64878. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64879. * @param min defines the new minimum vector (in local space)
  64880. * @param max defines the new maximum vector (in local space)
  64881. * @param worldMatrix defines the new world matrix
  64882. */
  64883. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64884. /**
  64885. * Scale the current bounding box by applying a scale factor
  64886. * @param factor defines the scale factor to apply
  64887. * @returns the current bounding box
  64888. */
  64889. scale(factor: number): BoundingBox;
  64890. /**
  64891. * Gets the world matrix of the bounding box
  64892. * @returns a matrix
  64893. */
  64894. getWorldMatrix(): DeepImmutable<Matrix>;
  64895. /** @hidden */
  64896. _update(world: DeepImmutable<Matrix>): void;
  64897. /**
  64898. * Tests if the bounding box is intersecting the frustum planes
  64899. * @param frustumPlanes defines the frustum planes to test
  64900. * @returns true if there is an intersection
  64901. */
  64902. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64903. /**
  64904. * Tests if the bounding box is entirely inside the frustum planes
  64905. * @param frustumPlanes defines the frustum planes to test
  64906. * @returns true if there is an inclusion
  64907. */
  64908. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64909. /**
  64910. * Tests if a point is inside the bounding box
  64911. * @param point defines the point to test
  64912. * @returns true if the point is inside the bounding box
  64913. */
  64914. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64915. /**
  64916. * Tests if the bounding box intersects with a bounding sphere
  64917. * @param sphere defines the sphere to test
  64918. * @returns true if there is an intersection
  64919. */
  64920. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64921. /**
  64922. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64923. * @param min defines the min vector to use
  64924. * @param max defines the max vector to use
  64925. * @returns true if there is an intersection
  64926. */
  64927. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64928. /**
  64929. * Tests if two bounding boxes are intersections
  64930. * @param box0 defines the first box to test
  64931. * @param box1 defines the second box to test
  64932. * @returns true if there is an intersection
  64933. */
  64934. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64935. /**
  64936. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64937. * @param minPoint defines the minimum vector of the bounding box
  64938. * @param maxPoint defines the maximum vector of the bounding box
  64939. * @param sphereCenter defines the sphere center
  64940. * @param sphereRadius defines the sphere radius
  64941. * @returns true if there is an intersection
  64942. */
  64943. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64944. /**
  64945. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64946. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64947. * @param frustumPlanes defines the frustum planes to test
  64948. * @return true if there is an inclusion
  64949. */
  64950. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64951. /**
  64952. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64953. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64954. * @param frustumPlanes defines the frustum planes to test
  64955. * @return true if there is an intersection
  64956. */
  64957. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64958. }
  64959. }
  64960. declare module BABYLON {
  64961. /** @hidden */
  64962. export class Collider {
  64963. /** Define if a collision was found */
  64964. collisionFound: boolean;
  64965. /**
  64966. * Define last intersection point in local space
  64967. */
  64968. intersectionPoint: Vector3;
  64969. /**
  64970. * Define last collided mesh
  64971. */
  64972. collidedMesh: Nullable<AbstractMesh>;
  64973. private _collisionPoint;
  64974. private _planeIntersectionPoint;
  64975. private _tempVector;
  64976. private _tempVector2;
  64977. private _tempVector3;
  64978. private _tempVector4;
  64979. private _edge;
  64980. private _baseToVertex;
  64981. private _destinationPoint;
  64982. private _slidePlaneNormal;
  64983. private _displacementVector;
  64984. /** @hidden */
  64985. _radius: Vector3;
  64986. /** @hidden */
  64987. _retry: number;
  64988. private _velocity;
  64989. private _basePoint;
  64990. private _epsilon;
  64991. /** @hidden */
  64992. _velocityWorldLength: number;
  64993. /** @hidden */
  64994. _basePointWorld: Vector3;
  64995. private _velocityWorld;
  64996. private _normalizedVelocity;
  64997. /** @hidden */
  64998. _initialVelocity: Vector3;
  64999. /** @hidden */
  65000. _initialPosition: Vector3;
  65001. private _nearestDistance;
  65002. private _collisionMask;
  65003. collisionMask: number;
  65004. /**
  65005. * Gets the plane normal used to compute the sliding response (in local space)
  65006. */
  65007. readonly slidePlaneNormal: Vector3;
  65008. /** @hidden */
  65009. _initialize(source: Vector3, dir: Vector3, e: number): void;
  65010. /** @hidden */
  65011. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  65012. /** @hidden */
  65013. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  65014. /** @hidden */
  65015. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  65016. /** @hidden */
  65017. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  65018. /** @hidden */
  65019. _getResponse(pos: Vector3, vel: Vector3): void;
  65020. }
  65021. }
  65022. declare module BABYLON {
  65023. /**
  65024. * Interface for cullable objects
  65025. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  65026. */
  65027. export interface ICullable {
  65028. /**
  65029. * Checks if the object or part of the object is in the frustum
  65030. * @param frustumPlanes Camera near/planes
  65031. * @returns true if the object is in frustum otherwise false
  65032. */
  65033. isInFrustum(frustumPlanes: Plane[]): boolean;
  65034. /**
  65035. * Checks if a cullable object (mesh...) is in the camera frustum
  65036. * Unlike isInFrustum this cheks the full bounding box
  65037. * @param frustumPlanes Camera near/planes
  65038. * @returns true if the object is in frustum otherwise false
  65039. */
  65040. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  65041. }
  65042. /**
  65043. * Info for a bounding data of a mesh
  65044. */
  65045. export class BoundingInfo implements ICullable {
  65046. /**
  65047. * Bounding box for the mesh
  65048. */
  65049. readonly boundingBox: BoundingBox;
  65050. /**
  65051. * Bounding sphere for the mesh
  65052. */
  65053. readonly boundingSphere: BoundingSphere;
  65054. private _isLocked;
  65055. private static readonly TmpVector3;
  65056. /**
  65057. * Constructs bounding info
  65058. * @param minimum min vector of the bounding box/sphere
  65059. * @param maximum max vector of the bounding box/sphere
  65060. * @param worldMatrix defines the new world matrix
  65061. */
  65062. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65063. /**
  65064. * Recreates the entire bounding info from scratch as if we call the constructor in place
  65065. * @param min defines the new minimum vector (in local space)
  65066. * @param max defines the new maximum vector (in local space)
  65067. * @param worldMatrix defines the new world matrix
  65068. */
  65069. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65070. /**
  65071. * min vector of the bounding box/sphere
  65072. */
  65073. readonly minimum: Vector3;
  65074. /**
  65075. * max vector of the bounding box/sphere
  65076. */
  65077. readonly maximum: Vector3;
  65078. /**
  65079. * If the info is locked and won't be updated to avoid perf overhead
  65080. */
  65081. isLocked: boolean;
  65082. /**
  65083. * Updates the bounding sphere and box
  65084. * @param world world matrix to be used to update
  65085. */
  65086. update(world: DeepImmutable<Matrix>): void;
  65087. /**
  65088. * Recreate the bounding info to be centered around a specific point given a specific extend.
  65089. * @param center New center of the bounding info
  65090. * @param extend New extend of the bounding info
  65091. * @returns the current bounding info
  65092. */
  65093. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  65094. /**
  65095. * Scale the current bounding info by applying a scale factor
  65096. * @param factor defines the scale factor to apply
  65097. * @returns the current bounding info
  65098. */
  65099. scale(factor: number): BoundingInfo;
  65100. /**
  65101. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  65102. * @param frustumPlanes defines the frustum to test
  65103. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  65104. * @returns true if the bounding info is in the frustum planes
  65105. */
  65106. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  65107. /**
  65108. * Gets the world distance between the min and max points of the bounding box
  65109. */
  65110. readonly diagonalLength: number;
  65111. /**
  65112. * Checks if a cullable object (mesh...) is in the camera frustum
  65113. * Unlike isInFrustum this cheks the full bounding box
  65114. * @param frustumPlanes Camera near/planes
  65115. * @returns true if the object is in frustum otherwise false
  65116. */
  65117. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65118. /** @hidden */
  65119. _checkCollision(collider: Collider): boolean;
  65120. /**
  65121. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  65122. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65123. * @param point the point to check intersection with
  65124. * @returns if the point intersects
  65125. */
  65126. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65127. /**
  65128. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  65129. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65130. * @param boundingInfo the bounding info to check intersection with
  65131. * @param precise if the intersection should be done using OBB
  65132. * @returns if the bounding info intersects
  65133. */
  65134. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65135. }
  65136. }
  65137. declare module BABYLON {
  65138. /**
  65139. * Defines an array and its length.
  65140. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65141. */
  65142. export interface ISmartArrayLike<T> {
  65143. /**
  65144. * The data of the array.
  65145. */
  65146. data: Array<T>;
  65147. /**
  65148. * The active length of the array.
  65149. */
  65150. length: number;
  65151. }
  65152. /**
  65153. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65154. */
  65155. export class SmartArray<T> implements ISmartArrayLike<T> {
  65156. /**
  65157. * The full set of data from the array.
  65158. */
  65159. data: Array<T>;
  65160. /**
  65161. * The active length of the array.
  65162. */
  65163. length: number;
  65164. protected _id: number;
  65165. /**
  65166. * Instantiates a Smart Array.
  65167. * @param capacity defines the default capacity of the array.
  65168. */
  65169. constructor(capacity: number);
  65170. /**
  65171. * Pushes a value at the end of the active data.
  65172. * @param value defines the object to push in the array.
  65173. */
  65174. push(value: T): void;
  65175. /**
  65176. * Iterates over the active data and apply the lambda to them.
  65177. * @param func defines the action to apply on each value.
  65178. */
  65179. forEach(func: (content: T) => void): void;
  65180. /**
  65181. * Sorts the full sets of data.
  65182. * @param compareFn defines the comparison function to apply.
  65183. */
  65184. sort(compareFn: (a: T, b: T) => number): void;
  65185. /**
  65186. * Resets the active data to an empty array.
  65187. */
  65188. reset(): void;
  65189. /**
  65190. * Releases all the data from the array as well as the array.
  65191. */
  65192. dispose(): void;
  65193. /**
  65194. * Concats the active data with a given array.
  65195. * @param array defines the data to concatenate with.
  65196. */
  65197. concat(array: any): void;
  65198. /**
  65199. * Returns the position of a value in the active data.
  65200. * @param value defines the value to find the index for
  65201. * @returns the index if found in the active data otherwise -1
  65202. */
  65203. indexOf(value: T): number;
  65204. /**
  65205. * Returns whether an element is part of the active data.
  65206. * @param value defines the value to look for
  65207. * @returns true if found in the active data otherwise false
  65208. */
  65209. contains(value: T): boolean;
  65210. private static _GlobalId;
  65211. }
  65212. /**
  65213. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65214. * The data in this array can only be present once
  65215. */
  65216. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65217. private _duplicateId;
  65218. /**
  65219. * Pushes a value at the end of the active data.
  65220. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65221. * @param value defines the object to push in the array.
  65222. */
  65223. push(value: T): void;
  65224. /**
  65225. * Pushes a value at the end of the active data.
  65226. * If the data is already present, it won t be added again
  65227. * @param value defines the object to push in the array.
  65228. * @returns true if added false if it was already present
  65229. */
  65230. pushNoDuplicate(value: T): boolean;
  65231. /**
  65232. * Resets the active data to an empty array.
  65233. */
  65234. reset(): void;
  65235. /**
  65236. * Concats the active data with a given array.
  65237. * This ensures no dupplicate will be present in the result.
  65238. * @param array defines the data to concatenate with.
  65239. */
  65240. concatWithNoDuplicate(array: any): void;
  65241. }
  65242. }
  65243. declare module BABYLON {
  65244. /**
  65245. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65246. * separate meshes. This can be use to improve performances.
  65247. * @see http://doc.babylonjs.com/how_to/multi_materials
  65248. */
  65249. export class MultiMaterial extends Material {
  65250. private _subMaterials;
  65251. /**
  65252. * Gets or Sets the list of Materials used within the multi material.
  65253. * They need to be ordered according to the submeshes order in the associated mesh
  65254. */
  65255. subMaterials: Nullable<Material>[];
  65256. /**
  65257. * Function used to align with Node.getChildren()
  65258. * @returns the list of Materials used within the multi material
  65259. */
  65260. getChildren(): Nullable<Material>[];
  65261. /**
  65262. * Instantiates a new Multi Material
  65263. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65264. * separate meshes. This can be use to improve performances.
  65265. * @see http://doc.babylonjs.com/how_to/multi_materials
  65266. * @param name Define the name in the scene
  65267. * @param scene Define the scene the material belongs to
  65268. */
  65269. constructor(name: string, scene: Scene);
  65270. private _hookArray;
  65271. /**
  65272. * Get one of the submaterial by its index in the submaterials array
  65273. * @param index The index to look the sub material at
  65274. * @returns The Material if the index has been defined
  65275. */
  65276. getSubMaterial(index: number): Nullable<Material>;
  65277. /**
  65278. * Get the list of active textures for the whole sub materials list.
  65279. * @returns All the textures that will be used during the rendering
  65280. */
  65281. getActiveTextures(): BaseTexture[];
  65282. /**
  65283. * Gets the current class name of the material e.g. "MultiMaterial"
  65284. * Mainly use in serialization.
  65285. * @returns the class name
  65286. */
  65287. getClassName(): string;
  65288. /**
  65289. * Checks if the material is ready to render the requested sub mesh
  65290. * @param mesh Define the mesh the submesh belongs to
  65291. * @param subMesh Define the sub mesh to look readyness for
  65292. * @param useInstances Define whether or not the material is used with instances
  65293. * @returns true if ready, otherwise false
  65294. */
  65295. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  65296. /**
  65297. * Clones the current material and its related sub materials
  65298. * @param name Define the name of the newly cloned material
  65299. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65300. * @returns the cloned material
  65301. */
  65302. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  65303. /**
  65304. * Serializes the materials into a JSON representation.
  65305. * @returns the JSON representation
  65306. */
  65307. serialize(): any;
  65308. /**
  65309. * Dispose the material and release its associated resources
  65310. * @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)
  65311. * @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)
  65312. * @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)
  65313. */
  65314. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  65315. /**
  65316. * Creates a MultiMaterial from parsed MultiMaterial data.
  65317. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65318. * @param scene defines the hosting scene
  65319. * @returns a new MultiMaterial
  65320. */
  65321. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  65322. }
  65323. }
  65324. declare module BABYLON {
  65325. /**
  65326. * Class used to represent data loading progression
  65327. */
  65328. export class SceneLoaderFlags {
  65329. private static _ForceFullSceneLoadingForIncremental;
  65330. private static _ShowLoadingScreen;
  65331. private static _CleanBoneMatrixWeights;
  65332. private static _loggingLevel;
  65333. /**
  65334. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65335. */
  65336. static ForceFullSceneLoadingForIncremental: boolean;
  65337. /**
  65338. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65339. */
  65340. static ShowLoadingScreen: boolean;
  65341. /**
  65342. * Defines the current logging level (while loading the scene)
  65343. * @ignorenaming
  65344. */
  65345. static loggingLevel: number;
  65346. /**
  65347. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65348. */
  65349. static CleanBoneMatrixWeights: boolean;
  65350. }
  65351. }
  65352. declare module BABYLON {
  65353. /**
  65354. * 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.
  65355. * @see https://doc.babylonjs.com/how_to/transformnode
  65356. */
  65357. export class TransformNode extends Node {
  65358. /**
  65359. * Object will not rotate to face the camera
  65360. */
  65361. static BILLBOARDMODE_NONE: number;
  65362. /**
  65363. * Object will rotate to face the camera but only on the x axis
  65364. */
  65365. static BILLBOARDMODE_X: number;
  65366. /**
  65367. * Object will rotate to face the camera but only on the y axis
  65368. */
  65369. static BILLBOARDMODE_Y: number;
  65370. /**
  65371. * Object will rotate to face the camera but only on the z axis
  65372. */
  65373. static BILLBOARDMODE_Z: number;
  65374. /**
  65375. * Object will rotate to face the camera
  65376. */
  65377. static BILLBOARDMODE_ALL: number;
  65378. private _forward;
  65379. private _forwardInverted;
  65380. private _up;
  65381. private _right;
  65382. private _rightInverted;
  65383. private _position;
  65384. private _rotation;
  65385. private _rotationQuaternion;
  65386. protected _scaling: Vector3;
  65387. protected _isDirty: boolean;
  65388. private _transformToBoneReferal;
  65389. /**
  65390. * Set the billboard mode. Default is 0.
  65391. *
  65392. * | Value | Type | Description |
  65393. * | --- | --- | --- |
  65394. * | 0 | BILLBOARDMODE_NONE | |
  65395. * | 1 | BILLBOARDMODE_X | |
  65396. * | 2 | BILLBOARDMODE_Y | |
  65397. * | 4 | BILLBOARDMODE_Z | |
  65398. * | 7 | BILLBOARDMODE_ALL | |
  65399. *
  65400. */
  65401. billboardMode: number;
  65402. /**
  65403. * 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
  65404. */
  65405. scalingDeterminant: number;
  65406. /**
  65407. * Sets the distance of the object to max, often used by skybox
  65408. */
  65409. infiniteDistance: boolean;
  65410. /**
  65411. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65412. * By default the system will update normals to compensate
  65413. */
  65414. ignoreNonUniformScaling: boolean;
  65415. /** @hidden */
  65416. _poseMatrix: Matrix;
  65417. /** @hidden */
  65418. _localMatrix: Matrix;
  65419. private _absolutePosition;
  65420. private _pivotMatrix;
  65421. private _pivotMatrixInverse;
  65422. protected _postMultiplyPivotMatrix: boolean;
  65423. private _tempMatrix;
  65424. private _tempMatrix2;
  65425. protected _isWorldMatrixFrozen: boolean;
  65426. /** @hidden */
  65427. _indexInSceneTransformNodesArray: number;
  65428. /**
  65429. * An event triggered after the world matrix is updated
  65430. */
  65431. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65432. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65433. /**
  65434. * Gets a string identifying the name of the class
  65435. * @returns "TransformNode" string
  65436. */
  65437. getClassName(): string;
  65438. /**
  65439. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65440. */
  65441. position: Vector3;
  65442. /**
  65443. * 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)).
  65444. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65445. */
  65446. rotation: Vector3;
  65447. /**
  65448. * 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)).
  65449. */
  65450. scaling: Vector3;
  65451. /**
  65452. * 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).
  65453. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65454. */
  65455. rotationQuaternion: Nullable<Quaternion>;
  65456. /**
  65457. * The forward direction of that transform in world space.
  65458. */
  65459. readonly forward: Vector3;
  65460. /**
  65461. * The up direction of that transform in world space.
  65462. */
  65463. readonly up: Vector3;
  65464. /**
  65465. * The right direction of that transform in world space.
  65466. */
  65467. readonly right: Vector3;
  65468. /**
  65469. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65470. * @param matrix the matrix to copy the pose from
  65471. * @returns this TransformNode.
  65472. */
  65473. updatePoseMatrix(matrix: Matrix): TransformNode;
  65474. /**
  65475. * Returns the mesh Pose matrix.
  65476. * @returns the pose matrix
  65477. */
  65478. getPoseMatrix(): Matrix;
  65479. /** @hidden */
  65480. _isSynchronized(): boolean;
  65481. /** @hidden */
  65482. _initCache(): void;
  65483. /**
  65484. * Flag the transform node as dirty (Forcing it to update everything)
  65485. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65486. * @returns this transform node
  65487. */
  65488. markAsDirty(property: string): TransformNode;
  65489. /**
  65490. * Returns the current mesh absolute position.
  65491. * Returns a Vector3.
  65492. */
  65493. readonly absolutePosition: Vector3;
  65494. /**
  65495. * Sets a new matrix to apply before all other transformation
  65496. * @param matrix defines the transform matrix
  65497. * @returns the current TransformNode
  65498. */
  65499. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65500. /**
  65501. * Sets a new pivot matrix to the current node
  65502. * @param matrix defines the new pivot matrix to use
  65503. * @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
  65504. * @returns the current TransformNode
  65505. */
  65506. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65507. /**
  65508. * Returns the mesh pivot matrix.
  65509. * Default : Identity.
  65510. * @returns the matrix
  65511. */
  65512. getPivotMatrix(): Matrix;
  65513. /**
  65514. * Prevents the World matrix to be computed any longer.
  65515. * @returns the TransformNode.
  65516. */
  65517. freezeWorldMatrix(): TransformNode;
  65518. /**
  65519. * Allows back the World matrix computation.
  65520. * @returns the TransformNode.
  65521. */
  65522. unfreezeWorldMatrix(): this;
  65523. /**
  65524. * True if the World matrix has been frozen.
  65525. */
  65526. readonly isWorldMatrixFrozen: boolean;
  65527. /**
  65528. * Retuns the mesh absolute position in the World.
  65529. * @returns a Vector3.
  65530. */
  65531. getAbsolutePosition(): Vector3;
  65532. /**
  65533. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65534. * @param absolutePosition the absolute position to set
  65535. * @returns the TransformNode.
  65536. */
  65537. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65538. /**
  65539. * Sets the mesh position in its local space.
  65540. * @param vector3 the position to set in localspace
  65541. * @returns the TransformNode.
  65542. */
  65543. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  65544. /**
  65545. * Returns the mesh position in the local space from the current World matrix values.
  65546. * @returns a new Vector3.
  65547. */
  65548. getPositionExpressedInLocalSpace(): Vector3;
  65549. /**
  65550. * Translates the mesh along the passed Vector3 in its local space.
  65551. * @param vector3 the distance to translate in localspace
  65552. * @returns the TransformNode.
  65553. */
  65554. locallyTranslate(vector3: Vector3): TransformNode;
  65555. private static _lookAtVectorCache;
  65556. /**
  65557. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65558. * @param targetPoint the position (must be in same space as current mesh) to look at
  65559. * @param yawCor optional yaw (y-axis) correction in radians
  65560. * @param pitchCor optional pitch (x-axis) correction in radians
  65561. * @param rollCor optional roll (z-axis) correction in radians
  65562. * @param space the choosen space of the target
  65563. * @returns the TransformNode.
  65564. */
  65565. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65566. /**
  65567. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65568. * This Vector3 is expressed in the World space.
  65569. * @param localAxis axis to rotate
  65570. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65571. */
  65572. getDirection(localAxis: Vector3): Vector3;
  65573. /**
  65574. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65575. * localAxis is expressed in the mesh local space.
  65576. * result is computed in the Wordl space from the mesh World matrix.
  65577. * @param localAxis axis to rotate
  65578. * @param result the resulting transformnode
  65579. * @returns this TransformNode.
  65580. */
  65581. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65582. /**
  65583. * Sets this transform node rotation to the given local axis.
  65584. * @param localAxis the axis in local space
  65585. * @param yawCor optional yaw (y-axis) correction in radians
  65586. * @param pitchCor optional pitch (x-axis) correction in radians
  65587. * @param rollCor optional roll (z-axis) correction in radians
  65588. * @returns this TransformNode
  65589. */
  65590. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65591. /**
  65592. * Sets a new pivot point to the current node
  65593. * @param point defines the new pivot point to use
  65594. * @param space defines if the point is in world or local space (local by default)
  65595. * @returns the current TransformNode
  65596. */
  65597. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65598. /**
  65599. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65600. * @returns the pivot point
  65601. */
  65602. getPivotPoint(): Vector3;
  65603. /**
  65604. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65605. * @param result the vector3 to store the result
  65606. * @returns this TransformNode.
  65607. */
  65608. getPivotPointToRef(result: Vector3): TransformNode;
  65609. /**
  65610. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65611. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65612. */
  65613. getAbsolutePivotPoint(): Vector3;
  65614. /**
  65615. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65616. * @param result vector3 to store the result
  65617. * @returns this TransformNode.
  65618. */
  65619. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65620. /**
  65621. * Defines the passed node as the parent of the current node.
  65622. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65623. * @param node the node ot set as the parent
  65624. * @returns this TransformNode.
  65625. */
  65626. setParent(node: Nullable<Node>): TransformNode;
  65627. private _nonUniformScaling;
  65628. /**
  65629. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65630. */
  65631. readonly nonUniformScaling: boolean;
  65632. /** @hidden */
  65633. _updateNonUniformScalingState(value: boolean): boolean;
  65634. /**
  65635. * Attach the current TransformNode to another TransformNode associated with a bone
  65636. * @param bone Bone affecting the TransformNode
  65637. * @param affectedTransformNode TransformNode associated with the bone
  65638. * @returns this object
  65639. */
  65640. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65641. /**
  65642. * Detach the transform node if its associated with a bone
  65643. * @returns this object
  65644. */
  65645. detachFromBone(): TransformNode;
  65646. private static _rotationAxisCache;
  65647. /**
  65648. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65649. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65650. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65651. * The passed axis is also normalized.
  65652. * @param axis the axis to rotate around
  65653. * @param amount the amount to rotate in radians
  65654. * @param space Space to rotate in (Default: local)
  65655. * @returns the TransformNode.
  65656. */
  65657. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65658. /**
  65659. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65660. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65661. * The passed axis is also normalized. .
  65662. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65663. * @param point the point to rotate around
  65664. * @param axis the axis to rotate around
  65665. * @param amount the amount to rotate in radians
  65666. * @returns the TransformNode
  65667. */
  65668. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65669. /**
  65670. * Translates the mesh along the axis vector for the passed distance in the given space.
  65671. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65672. * @param axis the axis to translate in
  65673. * @param distance the distance to translate
  65674. * @param space Space to rotate in (Default: local)
  65675. * @returns the TransformNode.
  65676. */
  65677. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65678. /**
  65679. * Adds a rotation step to the mesh current rotation.
  65680. * x, y, z are Euler angles expressed in radians.
  65681. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65682. * This means this rotation is made in the mesh local space only.
  65683. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65684. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65685. * ```javascript
  65686. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65687. * ```
  65688. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65689. * 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.
  65690. * @param x Rotation to add
  65691. * @param y Rotation to add
  65692. * @param z Rotation to add
  65693. * @returns the TransformNode.
  65694. */
  65695. addRotation(x: number, y: number, z: number): TransformNode;
  65696. /**
  65697. * Computes the world matrix of the node
  65698. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65699. * @returns the world matrix
  65700. */
  65701. computeWorldMatrix(force?: boolean): Matrix;
  65702. protected _afterComputeWorldMatrix(): void;
  65703. /**
  65704. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65705. * @param func callback function to add
  65706. *
  65707. * @returns the TransformNode.
  65708. */
  65709. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65710. /**
  65711. * Removes a registered callback function.
  65712. * @param func callback function to remove
  65713. * @returns the TransformNode.
  65714. */
  65715. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65716. /**
  65717. * Gets the position of the current mesh in camera space
  65718. * @param camera defines the camera to use
  65719. * @returns a position
  65720. */
  65721. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65722. /**
  65723. * Returns the distance from the mesh to the active camera
  65724. * @param camera defines the camera to use
  65725. * @returns the distance
  65726. */
  65727. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65728. /**
  65729. * Clone the current transform node
  65730. * @param name Name of the new clone
  65731. * @param newParent New parent for the clone
  65732. * @param doNotCloneChildren Do not clone children hierarchy
  65733. * @returns the new transform node
  65734. */
  65735. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65736. /**
  65737. * Serializes the objects information.
  65738. * @param currentSerializationObject defines the object to serialize in
  65739. * @returns the serialized object
  65740. */
  65741. serialize(currentSerializationObject?: any): any;
  65742. /**
  65743. * Returns a new TransformNode object parsed from the source provided.
  65744. * @param parsedTransformNode is the source.
  65745. * @param scene the scne the object belongs to
  65746. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65747. * @returns a new TransformNode object parsed from the source provided.
  65748. */
  65749. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65750. /**
  65751. * Get all child-transformNodes of this node
  65752. * @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
  65753. * @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
  65754. * @returns an array of TransformNode
  65755. */
  65756. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65757. /**
  65758. * Releases resources associated with this transform node.
  65759. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65760. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65761. */
  65762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65763. }
  65764. }
  65765. declare module BABYLON {
  65766. /**
  65767. * Class used to override all child animations of a given target
  65768. */
  65769. export class AnimationPropertiesOverride {
  65770. /**
  65771. * Gets or sets a value indicating if animation blending must be used
  65772. */
  65773. enableBlending: boolean;
  65774. /**
  65775. * Gets or sets the blending speed to use when enableBlending is true
  65776. */
  65777. blendingSpeed: number;
  65778. /**
  65779. * Gets or sets the default loop mode to use
  65780. */
  65781. loopMode: number;
  65782. }
  65783. }
  65784. declare module BABYLON {
  65785. /**
  65786. * Class used to store bone information
  65787. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65788. */
  65789. export class Bone extends Node {
  65790. /**
  65791. * defines the bone name
  65792. */
  65793. name: string;
  65794. private static _tmpVecs;
  65795. private static _tmpQuat;
  65796. private static _tmpMats;
  65797. /**
  65798. * Gets the list of child bones
  65799. */
  65800. children: Bone[];
  65801. /** Gets the animations associated with this bone */
  65802. animations: Animation[];
  65803. /**
  65804. * Gets or sets bone length
  65805. */
  65806. length: number;
  65807. /**
  65808. * @hidden Internal only
  65809. * Set this value to map this bone to a different index in the transform matrices
  65810. * Set this value to -1 to exclude the bone from the transform matrices
  65811. */
  65812. _index: Nullable<number>;
  65813. private _skeleton;
  65814. private _localMatrix;
  65815. private _restPose;
  65816. private _baseMatrix;
  65817. private _absoluteTransform;
  65818. private _invertedAbsoluteTransform;
  65819. private _parent;
  65820. private _scalingDeterminant;
  65821. private _worldTransform;
  65822. private _localScaling;
  65823. private _localRotation;
  65824. private _localPosition;
  65825. private _needToDecompose;
  65826. private _needToCompose;
  65827. /** @hidden */
  65828. _linkedTransformNode: Nullable<TransformNode>;
  65829. /** @hidden */
  65830. /** @hidden */
  65831. _matrix: Matrix;
  65832. /**
  65833. * Create a new bone
  65834. * @param name defines the bone name
  65835. * @param skeleton defines the parent skeleton
  65836. * @param parentBone defines the parent (can be null if the bone is the root)
  65837. * @param localMatrix defines the local matrix
  65838. * @param restPose defines the rest pose matrix
  65839. * @param baseMatrix defines the base matrix
  65840. * @param index defines index of the bone in the hiearchy
  65841. */
  65842. constructor(
  65843. /**
  65844. * defines the bone name
  65845. */
  65846. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65847. /**
  65848. * Gets the current object class name.
  65849. * @return the class name
  65850. */
  65851. getClassName(): string;
  65852. /**
  65853. * Gets the parent skeleton
  65854. * @returns a skeleton
  65855. */
  65856. getSkeleton(): Skeleton;
  65857. /**
  65858. * Gets parent bone
  65859. * @returns a bone or null if the bone is the root of the bone hierarchy
  65860. */
  65861. getParent(): Nullable<Bone>;
  65862. /**
  65863. * Returns an array containing the root bones
  65864. * @returns an array containing the root bones
  65865. */
  65866. getChildren(): Array<Bone>;
  65867. /**
  65868. * Sets the parent bone
  65869. * @param parent defines the parent (can be null if the bone is the root)
  65870. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65871. */
  65872. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65873. /**
  65874. * Gets the local matrix
  65875. * @returns a matrix
  65876. */
  65877. getLocalMatrix(): Matrix;
  65878. /**
  65879. * Gets the base matrix (initial matrix which remains unchanged)
  65880. * @returns a matrix
  65881. */
  65882. getBaseMatrix(): Matrix;
  65883. /**
  65884. * Gets the rest pose matrix
  65885. * @returns a matrix
  65886. */
  65887. getRestPose(): Matrix;
  65888. /**
  65889. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65890. */
  65891. getWorldMatrix(): Matrix;
  65892. /**
  65893. * Sets the local matrix to rest pose matrix
  65894. */
  65895. returnToRest(): void;
  65896. /**
  65897. * Gets the inverse of the absolute transform matrix.
  65898. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65899. * @returns a matrix
  65900. */
  65901. getInvertedAbsoluteTransform(): Matrix;
  65902. /**
  65903. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65904. * @returns a matrix
  65905. */
  65906. getAbsoluteTransform(): Matrix;
  65907. /**
  65908. * Links with the given transform node.
  65909. * The local matrix of this bone is copied from the transform node every frame.
  65910. * @param transformNode defines the transform node to link to
  65911. */
  65912. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65913. /** Gets or sets current position (in local space) */
  65914. position: Vector3;
  65915. /** Gets or sets current rotation (in local space) */
  65916. rotation: Vector3;
  65917. /** Gets or sets current rotation quaternion (in local space) */
  65918. rotationQuaternion: Quaternion;
  65919. /** Gets or sets current scaling (in local space) */
  65920. scaling: Vector3;
  65921. /**
  65922. * Gets the animation properties override
  65923. */
  65924. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65925. private _decompose;
  65926. private _compose;
  65927. /**
  65928. * Update the base and local matrices
  65929. * @param matrix defines the new base or local matrix
  65930. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65931. * @param updateLocalMatrix defines if the local matrix should be updated
  65932. */
  65933. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65934. /** @hidden */
  65935. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65936. /**
  65937. * Flag the bone as dirty (Forcing it to update everything)
  65938. */
  65939. markAsDirty(): void;
  65940. private _markAsDirtyAndCompose;
  65941. private _markAsDirtyAndDecompose;
  65942. /**
  65943. * Translate the bone in local or world space
  65944. * @param vec The amount to translate the bone
  65945. * @param space The space that the translation is in
  65946. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65947. */
  65948. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65949. /**
  65950. * Set the postion of the bone in local or world space
  65951. * @param position The position to set the bone
  65952. * @param space The space that the position is in
  65953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65954. */
  65955. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65956. /**
  65957. * Set the absolute position of the bone (world space)
  65958. * @param position The position to set the bone
  65959. * @param mesh The mesh that this bone is attached to
  65960. */
  65961. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65962. /**
  65963. * Scale the bone on the x, y and z axes (in local space)
  65964. * @param x The amount to scale the bone on the x axis
  65965. * @param y The amount to scale the bone on the y axis
  65966. * @param z The amount to scale the bone on the z axis
  65967. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65968. */
  65969. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65970. /**
  65971. * Set the bone scaling in local space
  65972. * @param scale defines the scaling vector
  65973. */
  65974. setScale(scale: Vector3): void;
  65975. /**
  65976. * Gets the current scaling in local space
  65977. * @returns the current scaling vector
  65978. */
  65979. getScale(): Vector3;
  65980. /**
  65981. * Gets the current scaling in local space and stores it in a target vector
  65982. * @param result defines the target vector
  65983. */
  65984. getScaleToRef(result: Vector3): void;
  65985. /**
  65986. * Set the yaw, pitch, and roll of the bone in local or world space
  65987. * @param yaw The rotation of the bone on the y axis
  65988. * @param pitch The rotation of the bone on the x axis
  65989. * @param roll The rotation of the bone on the z axis
  65990. * @param space The space that the axes of rotation are in
  65991. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65992. */
  65993. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65994. /**
  65995. * Add a rotation to the bone on an axis in local or world space
  65996. * @param axis The axis to rotate the bone on
  65997. * @param amount The amount to rotate the bone
  65998. * @param space The space that the axis is in
  65999. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66000. */
  66001. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  66002. /**
  66003. * Set the rotation of the bone to a particular axis angle in local or world space
  66004. * @param axis The axis to rotate the bone on
  66005. * @param angle The angle that the bone should be rotated to
  66006. * @param space The space that the axis is in
  66007. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66008. */
  66009. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  66010. /**
  66011. * Set the euler rotation of the bone in local of world space
  66012. * @param rotation The euler rotation that the bone should be set to
  66013. * @param space The space that the rotation is in
  66014. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66015. */
  66016. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66017. /**
  66018. * Set the quaternion rotation of the bone in local of world space
  66019. * @param quat The quaternion rotation that the bone should be set to
  66020. * @param space The space that the rotation is in
  66021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66022. */
  66023. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  66024. /**
  66025. * Set the rotation matrix of the bone in local of world space
  66026. * @param rotMat The rotation matrix that the bone should be set to
  66027. * @param space The space that the rotation is in
  66028. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66029. */
  66030. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  66031. private _rotateWithMatrix;
  66032. private _getNegativeRotationToRef;
  66033. /**
  66034. * Get the position of the bone in local or world space
  66035. * @param space The space that the returned position is in
  66036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66037. * @returns The position of the bone
  66038. */
  66039. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66040. /**
  66041. * Copy the position of the bone to a vector3 in local or world space
  66042. * @param space The space that the returned position is in
  66043. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66044. * @param result The vector3 to copy the position to
  66045. */
  66046. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  66047. /**
  66048. * Get the absolute position of the bone (world space)
  66049. * @param mesh The mesh that this bone is attached to
  66050. * @returns The absolute position of the bone
  66051. */
  66052. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  66053. /**
  66054. * Copy the absolute position of the bone (world space) to the result param
  66055. * @param mesh The mesh that this bone is attached to
  66056. * @param result The vector3 to copy the absolute position to
  66057. */
  66058. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  66059. /**
  66060. * Compute the absolute transforms of this bone and its children
  66061. */
  66062. computeAbsoluteTransforms(): void;
  66063. /**
  66064. * Get the world direction from an axis that is in the local space of the bone
  66065. * @param localAxis The local direction that is used to compute the world direction
  66066. * @param mesh The mesh that this bone is attached to
  66067. * @returns The world direction
  66068. */
  66069. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66070. /**
  66071. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  66072. * @param localAxis The local direction that is used to compute the world direction
  66073. * @param mesh The mesh that this bone is attached to
  66074. * @param result The vector3 that the world direction will be copied to
  66075. */
  66076. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66077. /**
  66078. * Get the euler rotation of the bone in local or world space
  66079. * @param space The space that the rotation should be in
  66080. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66081. * @returns The euler rotation
  66082. */
  66083. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66084. /**
  66085. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  66086. * @param space The space that the rotation should be in
  66087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66088. * @param result The vector3 that the rotation should be copied to
  66089. */
  66090. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66091. /**
  66092. * Get the quaternion rotation of the bone in either local or world space
  66093. * @param space The space that the rotation should be in
  66094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66095. * @returns The quaternion rotation
  66096. */
  66097. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  66098. /**
  66099. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  66100. * @param space The space that the rotation should be in
  66101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66102. * @param result The quaternion that the rotation should be copied to
  66103. */
  66104. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  66105. /**
  66106. * Get the rotation matrix of the bone in local or world space
  66107. * @param space The space that the rotation should be in
  66108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66109. * @returns The rotation matrix
  66110. */
  66111. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  66112. /**
  66113. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  66114. * @param space The space that the rotation should be in
  66115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66116. * @param result The quaternion that the rotation should be copied to
  66117. */
  66118. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  66119. /**
  66120. * Get the world position of a point that is in the local space of the bone
  66121. * @param position The local position
  66122. * @param mesh The mesh that this bone is attached to
  66123. * @returns The world position
  66124. */
  66125. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66126. /**
  66127. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  66128. * @param position The local position
  66129. * @param mesh The mesh that this bone is attached to
  66130. * @param result The vector3 that the world position should be copied to
  66131. */
  66132. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66133. /**
  66134. * Get the local position of a point that is in world space
  66135. * @param position The world position
  66136. * @param mesh The mesh that this bone is attached to
  66137. * @returns The local position
  66138. */
  66139. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66140. /**
  66141. * Get the local position of a point that is in world space and copy it to the result param
  66142. * @param position The world position
  66143. * @param mesh The mesh that this bone is attached to
  66144. * @param result The vector3 that the local position should be copied to
  66145. */
  66146. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66147. }
  66148. }
  66149. declare module BABYLON {
  66150. /**
  66151. * Class for creating a cube texture
  66152. */
  66153. export class CubeTexture extends BaseTexture {
  66154. private _delayedOnLoad;
  66155. /**
  66156. * The url of the texture
  66157. */
  66158. url: string;
  66159. /**
  66160. * Gets or sets the center of the bounding box associated with the cube texture.
  66161. * It must define where the camera used to render the texture was set
  66162. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66163. */
  66164. boundingBoxPosition: Vector3;
  66165. private _boundingBoxSize;
  66166. /**
  66167. * Gets or sets the size of the bounding box associated with the cube texture
  66168. * When defined, the cubemap will switch to local mode
  66169. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66170. * @example https://www.babylonjs-playground.com/#RNASML
  66171. */
  66172. /**
  66173. * Returns the bounding box size
  66174. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66175. */
  66176. boundingBoxSize: Vector3;
  66177. protected _rotationY: number;
  66178. /**
  66179. * Sets texture matrix rotation angle around Y axis in radians.
  66180. */
  66181. /**
  66182. * Gets texture matrix rotation angle around Y axis radians.
  66183. */
  66184. rotationY: number;
  66185. /**
  66186. * Are mip maps generated for this texture or not.
  66187. */
  66188. readonly noMipmap: boolean;
  66189. private _noMipmap;
  66190. private _files;
  66191. private _extensions;
  66192. private _textureMatrix;
  66193. private _format;
  66194. private _createPolynomials;
  66195. /** @hidden */
  66196. _prefiltered: boolean;
  66197. /**
  66198. * Creates a cube texture from an array of image urls
  66199. * @param files defines an array of image urls
  66200. * @param scene defines the hosting scene
  66201. * @param noMipmap specifies if mip maps are not used
  66202. * @returns a cube texture
  66203. */
  66204. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  66205. /**
  66206. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  66207. * @param url defines the url of the prefiltered texture
  66208. * @param scene defines the scene the texture is attached to
  66209. * @param forcedExtension defines the extension of the file if different from the url
  66210. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66211. * @return the prefiltered texture
  66212. */
  66213. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  66214. /**
  66215. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  66216. * as prefiltered data.
  66217. * @param rootUrl defines the url of the texture or the root name of the six images
  66218. * @param scene defines the scene the texture is attached to
  66219. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  66220. * @param noMipmap defines if mipmaps should be created or not
  66221. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  66222. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  66223. * @param onError defines a callback triggered in case of error during load
  66224. * @param format defines the internal format to use for the texture once loaded
  66225. * @param prefiltered defines whether or not the texture is created from prefiltered data
  66226. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  66227. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66228. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66229. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66230. * @return the cube texture
  66231. */
  66232. 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);
  66233. /**
  66234. * Get the current class name of the texture useful for serialization or dynamic coding.
  66235. * @returns "CubeTexture"
  66236. */
  66237. getClassName(): string;
  66238. /**
  66239. * Update the url (and optional buffer) of this texture if url was null during construction.
  66240. * @param url the url of the texture
  66241. * @param forcedExtension defines the extension to use
  66242. * @param onLoad callback called when the texture is loaded (defaults to null)
  66243. */
  66244. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  66245. /**
  66246. * Delays loading of the cube texture
  66247. * @param forcedExtension defines the extension to use
  66248. */
  66249. delayLoad(forcedExtension?: string): void;
  66250. /**
  66251. * Returns the reflection texture matrix
  66252. * @returns the reflection texture matrix
  66253. */
  66254. getReflectionTextureMatrix(): Matrix;
  66255. /**
  66256. * Sets the reflection texture matrix
  66257. * @param value Reflection texture matrix
  66258. */
  66259. setReflectionTextureMatrix(value: Matrix): void;
  66260. /**
  66261. * Parses text to create a cube texture
  66262. * @param parsedTexture define the serialized text to read from
  66263. * @param scene defines the hosting scene
  66264. * @param rootUrl defines the root url of the cube texture
  66265. * @returns a cube texture
  66266. */
  66267. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  66268. /**
  66269. * Makes a clone, or deep copy, of the cube texture
  66270. * @returns a new cube texture
  66271. */
  66272. clone(): CubeTexture;
  66273. }
  66274. }
  66275. declare module BABYLON {
  66276. /** @hidden */
  66277. export var postprocessVertexShader: {
  66278. name: string;
  66279. shader: string;
  66280. };
  66281. }
  66282. declare module BABYLON {
  66283. /**
  66284. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  66285. * This is the base of the follow, arc rotate cameras and Free camera
  66286. * @see http://doc.babylonjs.com/features/cameras
  66287. */
  66288. export class TargetCamera extends Camera {
  66289. private static _RigCamTransformMatrix;
  66290. private static _TargetTransformMatrix;
  66291. private static _TargetFocalPoint;
  66292. /**
  66293. * Define the current direction the camera is moving to
  66294. */
  66295. cameraDirection: Vector3;
  66296. /**
  66297. * Define the current rotation the camera is rotating to
  66298. */
  66299. cameraRotation: Vector2;
  66300. /**
  66301. * When set, the up vector of the camera will be updated by the rotation of the camera
  66302. */
  66303. updateUpVectorFromRotation: boolean;
  66304. private _tmpQuaternion;
  66305. /**
  66306. * Define the current rotation of the camera
  66307. */
  66308. rotation: Vector3;
  66309. /**
  66310. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  66311. */
  66312. rotationQuaternion: Quaternion;
  66313. /**
  66314. * Define the current speed of the camera
  66315. */
  66316. speed: number;
  66317. /**
  66318. * Add cconstraint to the camera to prevent it to move freely in all directions and
  66319. * around all axis.
  66320. */
  66321. noRotationConstraint: boolean;
  66322. /**
  66323. * Define the current target of the camera as an object or a position.
  66324. */
  66325. lockedTarget: any;
  66326. /** @hidden */
  66327. _currentTarget: Vector3;
  66328. /** @hidden */
  66329. _initialFocalDistance: number;
  66330. /** @hidden */
  66331. _viewMatrix: Matrix;
  66332. /** @hidden */
  66333. _camMatrix: Matrix;
  66334. /** @hidden */
  66335. _cameraTransformMatrix: Matrix;
  66336. /** @hidden */
  66337. _cameraRotationMatrix: Matrix;
  66338. /** @hidden */
  66339. _referencePoint: Vector3;
  66340. /** @hidden */
  66341. _transformedReferencePoint: Vector3;
  66342. protected _globalCurrentTarget: Vector3;
  66343. protected _globalCurrentUpVector: Vector3;
  66344. /** @hidden */
  66345. _reset: () => void;
  66346. private _defaultUp;
  66347. /**
  66348. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66349. * This is the base of the follow, arc rotate cameras and Free camera
  66350. * @see http://doc.babylonjs.com/features/cameras
  66351. * @param name Defines the name of the camera in the scene
  66352. * @param position Defines the start position of the camera in the scene
  66353. * @param scene Defines the scene the camera belongs to
  66354. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66355. */
  66356. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66357. /**
  66358. * Gets the position in front of the camera at a given distance.
  66359. * @param distance The distance from the camera we want the position to be
  66360. * @returns the position
  66361. */
  66362. getFrontPosition(distance: number): Vector3;
  66363. /** @hidden */
  66364. _getLockedTargetPosition(): Nullable<Vector3>;
  66365. private _storedPosition;
  66366. private _storedRotation;
  66367. private _storedRotationQuaternion;
  66368. /**
  66369. * Store current camera state of the camera (fov, position, rotation, etc..)
  66370. * @returns the camera
  66371. */
  66372. storeState(): Camera;
  66373. /**
  66374. * Restored camera state. You must call storeState() first
  66375. * @returns whether it was successful or not
  66376. * @hidden
  66377. */
  66378. _restoreStateValues(): boolean;
  66379. /** @hidden */
  66380. _initCache(): void;
  66381. /** @hidden */
  66382. _updateCache(ignoreParentClass?: boolean): void;
  66383. /** @hidden */
  66384. _isSynchronizedViewMatrix(): boolean;
  66385. /** @hidden */
  66386. _computeLocalCameraSpeed(): number;
  66387. /**
  66388. * Defines the target the camera should look at.
  66389. * This will automatically adapt alpha beta and radius to fit within the new target.
  66390. * @param target Defines the new target as a Vector or a mesh
  66391. */
  66392. setTarget(target: Vector3): void;
  66393. /**
  66394. * Return the current target position of the camera. This value is expressed in local space.
  66395. * @returns the target position
  66396. */
  66397. getTarget(): Vector3;
  66398. /** @hidden */
  66399. _decideIfNeedsToMove(): boolean;
  66400. /** @hidden */
  66401. _updatePosition(): void;
  66402. /** @hidden */
  66403. _checkInputs(): void;
  66404. protected _updateCameraRotationMatrix(): void;
  66405. /**
  66406. * 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)
  66407. * @returns the current camera
  66408. */
  66409. private _rotateUpVectorWithCameraRotationMatrix;
  66410. private _cachedRotationZ;
  66411. private _cachedQuaternionRotationZ;
  66412. /** @hidden */
  66413. _getViewMatrix(): Matrix;
  66414. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66415. /**
  66416. * @hidden
  66417. */
  66418. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66419. /**
  66420. * @hidden
  66421. */
  66422. _updateRigCameras(): void;
  66423. private _getRigCamPositionAndTarget;
  66424. /**
  66425. * Gets the current object class name.
  66426. * @return the class name
  66427. */
  66428. getClassName(): string;
  66429. }
  66430. }
  66431. declare module BABYLON {
  66432. /**
  66433. * @ignore
  66434. * This is a list of all the different input types that are available in the application.
  66435. * Fo instance: ArcRotateCameraGamepadInput...
  66436. */
  66437. export var CameraInputTypes: {};
  66438. /**
  66439. * This is the contract to implement in order to create a new input class.
  66440. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  66441. */
  66442. export interface ICameraInput<TCamera extends Camera> {
  66443. /**
  66444. * Defines the camera the input is attached to.
  66445. */
  66446. camera: Nullable<TCamera>;
  66447. /**
  66448. * Gets the class name of the current intput.
  66449. * @returns the class name
  66450. */
  66451. getClassName(): string;
  66452. /**
  66453. * Get the friendly name associated with the input class.
  66454. * @returns the input friendly name
  66455. */
  66456. getSimpleName(): string;
  66457. /**
  66458. * Attach the input controls to a specific dom element to get the input from.
  66459. * @param element Defines the element the controls should be listened from
  66460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66461. */
  66462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66463. /**
  66464. * Detach the current controls from the specified dom element.
  66465. * @param element Defines the element to stop listening the inputs from
  66466. */
  66467. detachControl(element: Nullable<HTMLElement>): void;
  66468. /**
  66469. * Update the current camera state depending on the inputs that have been used this frame.
  66470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66471. */
  66472. checkInputs?: () => void;
  66473. }
  66474. /**
  66475. * Represents a map of input types to input instance or input index to input instance.
  66476. */
  66477. export interface CameraInputsMap<TCamera extends Camera> {
  66478. /**
  66479. * Accessor to the input by input type.
  66480. */
  66481. [name: string]: ICameraInput<TCamera>;
  66482. /**
  66483. * Accessor to the input by input index.
  66484. */
  66485. [idx: number]: ICameraInput<TCamera>;
  66486. }
  66487. /**
  66488. * This represents the input manager used within a camera.
  66489. * It helps dealing with all the different kind of input attached to a camera.
  66490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66491. */
  66492. export class CameraInputsManager<TCamera extends Camera> {
  66493. /**
  66494. * Defines the list of inputs attahed to the camera.
  66495. */
  66496. attached: CameraInputsMap<TCamera>;
  66497. /**
  66498. * Defines the dom element the camera is collecting inputs from.
  66499. * This is null if the controls have not been attached.
  66500. */
  66501. attachedElement: Nullable<HTMLElement>;
  66502. /**
  66503. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66504. */
  66505. noPreventDefault: boolean;
  66506. /**
  66507. * Defined the camera the input manager belongs to.
  66508. */
  66509. camera: TCamera;
  66510. /**
  66511. * Update the current camera state depending on the inputs that have been used this frame.
  66512. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66513. */
  66514. checkInputs: () => void;
  66515. /**
  66516. * Instantiate a new Camera Input Manager.
  66517. * @param camera Defines the camera the input manager blongs to
  66518. */
  66519. constructor(camera: TCamera);
  66520. /**
  66521. * Add an input method to a camera
  66522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66523. * @param input camera input method
  66524. */
  66525. add(input: ICameraInput<TCamera>): void;
  66526. /**
  66527. * Remove a specific input method from a camera
  66528. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  66529. * @param inputToRemove camera input method
  66530. */
  66531. remove(inputToRemove: ICameraInput<TCamera>): void;
  66532. /**
  66533. * Remove a specific input type from a camera
  66534. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  66535. * @param inputType the type of the input to remove
  66536. */
  66537. removeByType(inputType: string): void;
  66538. private _addCheckInputs;
  66539. /**
  66540. * Attach the input controls to the currently attached dom element to listen the events from.
  66541. * @param input Defines the input to attach
  66542. */
  66543. attachInput(input: ICameraInput<TCamera>): void;
  66544. /**
  66545. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  66546. * @param element Defines the dom element to collect the events from
  66547. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66548. */
  66549. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  66550. /**
  66551. * Detach the current manager inputs controls from a specific dom element.
  66552. * @param element Defines the dom element to collect the events from
  66553. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  66554. */
  66555. detachElement(element: HTMLElement, disconnect?: boolean): void;
  66556. /**
  66557. * Rebuild the dynamic inputCheck function from the current list of
  66558. * defined inputs in the manager.
  66559. */
  66560. rebuildInputCheck(): void;
  66561. /**
  66562. * Remove all attached input methods from a camera
  66563. */
  66564. clear(): void;
  66565. /**
  66566. * Serialize the current input manager attached to a camera.
  66567. * This ensures than once parsed,
  66568. * the input associated to the camera will be identical to the current ones
  66569. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  66570. */
  66571. serialize(serializedCamera: any): void;
  66572. /**
  66573. * Parses an input manager serialized JSON to restore the previous list of inputs
  66574. * and states associated to a camera.
  66575. * @param parsedCamera Defines the JSON to parse
  66576. */
  66577. parse(parsedCamera: any): void;
  66578. }
  66579. }
  66580. declare module BABYLON {
  66581. /**
  66582. * Gather the list of keyboard event types as constants.
  66583. */
  66584. export class KeyboardEventTypes {
  66585. /**
  66586. * The keydown event is fired when a key becomes active (pressed).
  66587. */
  66588. static readonly KEYDOWN: number;
  66589. /**
  66590. * The keyup event is fired when a key has been released.
  66591. */
  66592. static readonly KEYUP: number;
  66593. }
  66594. /**
  66595. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66596. */
  66597. export class KeyboardInfo {
  66598. /**
  66599. * Defines the type of event (KeyboardEventTypes)
  66600. */
  66601. type: number;
  66602. /**
  66603. * Defines the related dom event
  66604. */
  66605. event: KeyboardEvent;
  66606. /**
  66607. * Instantiates a new keyboard info.
  66608. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66609. * @param type Defines the type of event (KeyboardEventTypes)
  66610. * @param event Defines the related dom event
  66611. */
  66612. constructor(
  66613. /**
  66614. * Defines the type of event (KeyboardEventTypes)
  66615. */
  66616. type: number,
  66617. /**
  66618. * Defines the related dom event
  66619. */
  66620. event: KeyboardEvent);
  66621. }
  66622. /**
  66623. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66624. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66625. */
  66626. export class KeyboardInfoPre extends KeyboardInfo {
  66627. /**
  66628. * Defines the type of event (KeyboardEventTypes)
  66629. */
  66630. type: number;
  66631. /**
  66632. * Defines the related dom event
  66633. */
  66634. event: KeyboardEvent;
  66635. /**
  66636. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66637. */
  66638. skipOnPointerObservable: boolean;
  66639. /**
  66640. * Instantiates a new keyboard pre info.
  66641. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66642. * @param type Defines the type of event (KeyboardEventTypes)
  66643. * @param event Defines the related dom event
  66644. */
  66645. constructor(
  66646. /**
  66647. * Defines the type of event (KeyboardEventTypes)
  66648. */
  66649. type: number,
  66650. /**
  66651. * Defines the related dom event
  66652. */
  66653. event: KeyboardEvent);
  66654. }
  66655. }
  66656. declare module BABYLON {
  66657. /**
  66658. * Manage the keyboard inputs to control the movement of a free camera.
  66659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66660. */
  66661. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66662. /**
  66663. * Defines the camera the input is attached to.
  66664. */
  66665. camera: FreeCamera;
  66666. /**
  66667. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66668. */
  66669. keysUp: number[];
  66670. /**
  66671. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66672. */
  66673. keysDown: number[];
  66674. /**
  66675. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66676. */
  66677. keysLeft: number[];
  66678. /**
  66679. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66680. */
  66681. keysRight: number[];
  66682. private _keys;
  66683. private _onCanvasBlurObserver;
  66684. private _onKeyboardObserver;
  66685. private _engine;
  66686. private _scene;
  66687. /**
  66688. * Attach the input controls to a specific dom element to get the input from.
  66689. * @param element Defines the element the controls should be listened from
  66690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66691. */
  66692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66693. /**
  66694. * Detach the current controls from the specified dom element.
  66695. * @param element Defines the element to stop listening the inputs from
  66696. */
  66697. detachControl(element: Nullable<HTMLElement>): void;
  66698. /**
  66699. * Update the current camera state depending on the inputs that have been used this frame.
  66700. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66701. */
  66702. checkInputs(): void;
  66703. /**
  66704. * Gets the class name of the current intput.
  66705. * @returns the class name
  66706. */
  66707. getClassName(): string;
  66708. /** @hidden */
  66709. _onLostFocus(): void;
  66710. /**
  66711. * Get the friendly name associated with the input class.
  66712. * @returns the input friendly name
  66713. */
  66714. getSimpleName(): string;
  66715. }
  66716. }
  66717. declare module BABYLON {
  66718. /**
  66719. * Interface describing all the common properties and methods a shadow light needs to implement.
  66720. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66721. * as well as binding the different shadow properties to the effects.
  66722. */
  66723. export interface IShadowLight extends Light {
  66724. /**
  66725. * The light id in the scene (used in scene.findLighById for instance)
  66726. */
  66727. id: string;
  66728. /**
  66729. * The position the shdow will be casted from.
  66730. */
  66731. position: Vector3;
  66732. /**
  66733. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66734. */
  66735. direction: Vector3;
  66736. /**
  66737. * The transformed position. Position of the light in world space taking parenting in account.
  66738. */
  66739. transformedPosition: Vector3;
  66740. /**
  66741. * The transformed direction. Direction of the light in world space taking parenting in account.
  66742. */
  66743. transformedDirection: Vector3;
  66744. /**
  66745. * The friendly name of the light in the scene.
  66746. */
  66747. name: string;
  66748. /**
  66749. * Defines the shadow projection clipping minimum z value.
  66750. */
  66751. shadowMinZ: number;
  66752. /**
  66753. * Defines the shadow projection clipping maximum z value.
  66754. */
  66755. shadowMaxZ: number;
  66756. /**
  66757. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66758. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66759. */
  66760. computeTransformedInformation(): boolean;
  66761. /**
  66762. * Gets the scene the light belongs to.
  66763. * @returns The scene
  66764. */
  66765. getScene(): Scene;
  66766. /**
  66767. * Callback defining a custom Projection Matrix Builder.
  66768. * This can be used to override the default projection matrix computation.
  66769. */
  66770. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66771. /**
  66772. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66773. * @param matrix The materix to updated with the projection information
  66774. * @param viewMatrix The transform matrix of the light
  66775. * @param renderList The list of mesh to render in the map
  66776. * @returns The current light
  66777. */
  66778. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66779. /**
  66780. * Gets the current depth scale used in ESM.
  66781. * @returns The scale
  66782. */
  66783. getDepthScale(): number;
  66784. /**
  66785. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66786. * @returns true if a cube texture needs to be use
  66787. */
  66788. needCube(): boolean;
  66789. /**
  66790. * Detects if the projection matrix requires to be recomputed this frame.
  66791. * @returns true if it requires to be recomputed otherwise, false.
  66792. */
  66793. needProjectionMatrixCompute(): boolean;
  66794. /**
  66795. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66796. */
  66797. forceProjectionMatrixCompute(): void;
  66798. /**
  66799. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66800. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66801. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66802. */
  66803. getShadowDirection(faceIndex?: number): Vector3;
  66804. /**
  66805. * Gets the minZ used for shadow according to both the scene and the light.
  66806. * @param activeCamera The camera we are returning the min for
  66807. * @returns the depth min z
  66808. */
  66809. getDepthMinZ(activeCamera: Camera): number;
  66810. /**
  66811. * Gets the maxZ used for shadow according to both the scene and the light.
  66812. * @param activeCamera The camera we are returning the max for
  66813. * @returns the depth max z
  66814. */
  66815. getDepthMaxZ(activeCamera: Camera): number;
  66816. }
  66817. /**
  66818. * Base implementation IShadowLight
  66819. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66820. */
  66821. export abstract class ShadowLight extends Light implements IShadowLight {
  66822. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66823. protected _position: Vector3;
  66824. protected _setPosition(value: Vector3): void;
  66825. /**
  66826. * Sets the position the shadow will be casted from. Also use as the light position for both
  66827. * point and spot lights.
  66828. */
  66829. /**
  66830. * Sets the position the shadow will be casted from. Also use as the light position for both
  66831. * point and spot lights.
  66832. */
  66833. position: Vector3;
  66834. protected _direction: Vector3;
  66835. protected _setDirection(value: Vector3): void;
  66836. /**
  66837. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66838. * Also use as the light direction on spot and directional lights.
  66839. */
  66840. /**
  66841. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66842. * Also use as the light direction on spot and directional lights.
  66843. */
  66844. direction: Vector3;
  66845. private _shadowMinZ;
  66846. /**
  66847. * Gets the shadow projection clipping minimum z value.
  66848. */
  66849. /**
  66850. * Sets the shadow projection clipping minimum z value.
  66851. */
  66852. shadowMinZ: number;
  66853. private _shadowMaxZ;
  66854. /**
  66855. * Sets the shadow projection clipping maximum z value.
  66856. */
  66857. /**
  66858. * Gets the shadow projection clipping maximum z value.
  66859. */
  66860. shadowMaxZ: number;
  66861. /**
  66862. * Callback defining a custom Projection Matrix Builder.
  66863. * This can be used to override the default projection matrix computation.
  66864. */
  66865. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66866. /**
  66867. * The transformed position. Position of the light in world space taking parenting in account.
  66868. */
  66869. transformedPosition: Vector3;
  66870. /**
  66871. * The transformed direction. Direction of the light in world space taking parenting in account.
  66872. */
  66873. transformedDirection: Vector3;
  66874. private _needProjectionMatrixCompute;
  66875. /**
  66876. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66877. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66878. */
  66879. computeTransformedInformation(): boolean;
  66880. /**
  66881. * Return the depth scale used for the shadow map.
  66882. * @returns the depth scale.
  66883. */
  66884. getDepthScale(): number;
  66885. /**
  66886. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66887. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66888. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66889. */
  66890. getShadowDirection(faceIndex?: number): Vector3;
  66891. /**
  66892. * Returns the ShadowLight absolute position in the World.
  66893. * @returns the position vector in world space
  66894. */
  66895. getAbsolutePosition(): Vector3;
  66896. /**
  66897. * Sets the ShadowLight direction toward the passed target.
  66898. * @param target The point to target in local space
  66899. * @returns the updated ShadowLight direction
  66900. */
  66901. setDirectionToTarget(target: Vector3): Vector3;
  66902. /**
  66903. * Returns the light rotation in euler definition.
  66904. * @returns the x y z rotation in local space.
  66905. */
  66906. getRotation(): Vector3;
  66907. /**
  66908. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66909. * @returns true if a cube texture needs to be use
  66910. */
  66911. needCube(): boolean;
  66912. /**
  66913. * Detects if the projection matrix requires to be recomputed this frame.
  66914. * @returns true if it requires to be recomputed otherwise, false.
  66915. */
  66916. needProjectionMatrixCompute(): boolean;
  66917. /**
  66918. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66919. */
  66920. forceProjectionMatrixCompute(): void;
  66921. /** @hidden */
  66922. _initCache(): void;
  66923. /** @hidden */
  66924. _isSynchronized(): boolean;
  66925. /**
  66926. * Computes the world matrix of the node
  66927. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66928. * @returns the world matrix
  66929. */
  66930. computeWorldMatrix(force?: boolean): Matrix;
  66931. /**
  66932. * Gets the minZ used for shadow according to both the scene and the light.
  66933. * @param activeCamera The camera we are returning the min for
  66934. * @returns the depth min z
  66935. */
  66936. getDepthMinZ(activeCamera: Camera): number;
  66937. /**
  66938. * Gets the maxZ used for shadow according to both the scene and the light.
  66939. * @param activeCamera The camera we are returning the max for
  66940. * @returns the depth max z
  66941. */
  66942. getDepthMaxZ(activeCamera: Camera): number;
  66943. /**
  66944. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66945. * @param matrix The materix to updated with the projection information
  66946. * @param viewMatrix The transform matrix of the light
  66947. * @param renderList The list of mesh to render in the map
  66948. * @returns The current light
  66949. */
  66950. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66951. }
  66952. }
  66953. declare module BABYLON {
  66954. /**
  66955. * "Static Class" containing the most commonly used helper while dealing with material for
  66956. * rendering purpose.
  66957. *
  66958. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66959. *
  66960. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66961. */
  66962. export class MaterialHelper {
  66963. /**
  66964. * Bind the current view position to an effect.
  66965. * @param effect The effect to be bound
  66966. * @param scene The scene the eyes position is used from
  66967. */
  66968. static BindEyePosition(effect: Effect, scene: Scene): void;
  66969. /**
  66970. * Helps preparing the defines values about the UVs in used in the effect.
  66971. * UVs are shared as much as we can accross channels in the shaders.
  66972. * @param texture The texture we are preparing the UVs for
  66973. * @param defines The defines to update
  66974. * @param key The channel key "diffuse", "specular"... used in the shader
  66975. */
  66976. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66977. /**
  66978. * Binds a texture matrix value to its corrsponding uniform
  66979. * @param texture The texture to bind the matrix for
  66980. * @param uniformBuffer The uniform buffer receivin the data
  66981. * @param key The channel key "diffuse", "specular"... used in the shader
  66982. */
  66983. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66984. /**
  66985. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66986. * @param mesh defines the current mesh
  66987. * @param scene defines the current scene
  66988. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66989. * @param pointsCloud defines if point cloud rendering has to be turned on
  66990. * @param fogEnabled defines if fog has to be turned on
  66991. * @param alphaTest defines if alpha testing has to be turned on
  66992. * @param defines defines the current list of defines
  66993. */
  66994. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66995. /**
  66996. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66997. * @param scene defines the current scene
  66998. * @param engine defines the current engine
  66999. * @param defines specifies the list of active defines
  67000. * @param useInstances defines if instances have to be turned on
  67001. * @param useClipPlane defines if clip plane have to be turned on
  67002. */
  67003. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  67004. /**
  67005. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  67006. * @param mesh The mesh containing the geometry data we will draw
  67007. * @param defines The defines to update
  67008. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  67009. * @param useBones Precise whether bones should be used or not (override mesh info)
  67010. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  67011. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  67012. * @returns false if defines are considered not dirty and have not been checked
  67013. */
  67014. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  67015. /**
  67016. * Prepares the defines related to the light information passed in parameter
  67017. * @param scene The scene we are intending to draw
  67018. * @param mesh The mesh the effect is compiling for
  67019. * @param defines The defines to update
  67020. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67021. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67022. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67023. * @returns true if normals will be required for the rest of the effect
  67024. */
  67025. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  67026. /**
  67027. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67028. * that won t be acctive due to defines being turned off.
  67029. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67030. * @param samplersList The samplers list
  67031. * @param defines The defines helping in the list generation
  67032. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67033. */
  67034. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  67035. /**
  67036. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67037. * @param defines The defines to update while falling back
  67038. * @param fallbacks The authorized effect fallbacks
  67039. * @param maxSimultaneousLights The maximum number of lights allowed
  67040. * @param rank the current rank of the Effect
  67041. * @returns The newly affected rank
  67042. */
  67043. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  67044. /**
  67045. * Prepares the list of attributes required for morph targets according to the effect defines.
  67046. * @param attribs The current list of supported attribs
  67047. * @param mesh The mesh to prepare the morph targets attributes for
  67048. * @param defines The current Defines of the effect
  67049. */
  67050. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  67051. /**
  67052. * Prepares the list of attributes required for bones according to the effect defines.
  67053. * @param attribs The current list of supported attribs
  67054. * @param mesh The mesh to prepare the bones attributes for
  67055. * @param defines The current Defines of the effect
  67056. * @param fallbacks The current efffect fallback strategy
  67057. */
  67058. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  67059. /**
  67060. * Prepares the list of attributes required for instances according to the effect defines.
  67061. * @param attribs The current list of supported attribs
  67062. * @param defines The current Defines of the effect
  67063. */
  67064. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  67065. /**
  67066. * Binds the light shadow information to the effect for the given mesh.
  67067. * @param light The light containing the generator
  67068. * @param scene The scene the lights belongs to
  67069. * @param mesh The mesh we are binding the information to render
  67070. * @param lightIndex The light index in the effect used to render the mesh
  67071. * @param effect The effect we are binding the data to
  67072. */
  67073. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  67074. /**
  67075. * Binds the light information to the effect.
  67076. * @param light The light containing the generator
  67077. * @param effect The effect we are binding the data to
  67078. * @param lightIndex The light index in the effect used to render
  67079. */
  67080. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  67081. /**
  67082. * Binds the lights information from the scene to the effect for the given mesh.
  67083. * @param scene The scene the lights belongs to
  67084. * @param mesh The mesh we are binding the information to render
  67085. * @param effect The effect we are binding the data to
  67086. * @param defines The generated defines for the effect
  67087. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67088. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67089. */
  67090. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  67091. private static _tempFogColor;
  67092. /**
  67093. * Binds the fog information from the scene to the effect for the given mesh.
  67094. * @param scene The scene the lights belongs to
  67095. * @param mesh The mesh we are binding the information to render
  67096. * @param effect The effect we are binding the data to
  67097. * @param linearSpace Defines if the fog effect is applied in linear space
  67098. */
  67099. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  67100. /**
  67101. * Binds the bones information from the mesh to the effect.
  67102. * @param mesh The mesh we are binding the information to render
  67103. * @param effect The effect we are binding the data to
  67104. */
  67105. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  67106. /**
  67107. * Binds the morph targets information from the mesh to the effect.
  67108. * @param abstractMesh The mesh we are binding the information to render
  67109. * @param effect The effect we are binding the data to
  67110. */
  67111. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  67112. /**
  67113. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67114. * @param defines The generated defines used in the effect
  67115. * @param effect The effect we are binding the data to
  67116. * @param scene The scene we are willing to render with logarithmic scale for
  67117. */
  67118. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  67119. /**
  67120. * Binds the clip plane information from the scene to the effect.
  67121. * @param scene The scene the clip plane information are extracted from
  67122. * @param effect The effect we are binding the data to
  67123. */
  67124. static BindClipPlane(effect: Effect, scene: Scene): void;
  67125. }
  67126. }
  67127. declare module BABYLON {
  67128. /** @hidden */
  67129. export var kernelBlurVaryingDeclaration: {
  67130. name: string;
  67131. shader: string;
  67132. };
  67133. }
  67134. declare module BABYLON {
  67135. /** @hidden */
  67136. export var kernelBlurFragment: {
  67137. name: string;
  67138. shader: string;
  67139. };
  67140. }
  67141. declare module BABYLON {
  67142. /** @hidden */
  67143. export var kernelBlurFragment2: {
  67144. name: string;
  67145. shader: string;
  67146. };
  67147. }
  67148. declare module BABYLON {
  67149. /** @hidden */
  67150. export var kernelBlurPixelShader: {
  67151. name: string;
  67152. shader: string;
  67153. };
  67154. }
  67155. declare module BABYLON {
  67156. /** @hidden */
  67157. export var kernelBlurVertex: {
  67158. name: string;
  67159. shader: string;
  67160. };
  67161. }
  67162. declare module BABYLON {
  67163. /** @hidden */
  67164. export var kernelBlurVertexShader: {
  67165. name: string;
  67166. shader: string;
  67167. };
  67168. }
  67169. declare module BABYLON {
  67170. /**
  67171. * The Blur Post Process which blurs an image based on a kernel and direction.
  67172. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67173. */
  67174. export class BlurPostProcess extends PostProcess {
  67175. /** The direction in which to blur the image. */
  67176. direction: Vector2;
  67177. private blockCompilation;
  67178. protected _kernel: number;
  67179. protected _idealKernel: number;
  67180. protected _packedFloat: boolean;
  67181. private _staticDefines;
  67182. /**
  67183. * Sets the length in pixels of the blur sample region
  67184. */
  67185. /**
  67186. * Gets the length in pixels of the blur sample region
  67187. */
  67188. kernel: number;
  67189. /**
  67190. * Sets wether or not the blur needs to unpack/repack floats
  67191. */
  67192. /**
  67193. * Gets wether or not the blur is unpacking/repacking floats
  67194. */
  67195. packedFloat: boolean;
  67196. /**
  67197. * Creates a new instance BlurPostProcess
  67198. * @param name The name of the effect.
  67199. * @param direction The direction in which to blur the image.
  67200. * @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.
  67201. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67202. * @param camera The camera to apply the render pass to.
  67203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67204. * @param engine The engine which the post process will be applied. (default: current engine)
  67205. * @param reusable If the post process can be reused on the same frame. (default: false)
  67206. * @param textureType Type of textures used when performing the post process. (default: 0)
  67207. * @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)
  67208. */
  67209. constructor(name: string,
  67210. /** The direction in which to blur the image. */
  67211. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  67212. /**
  67213. * Updates the effect with the current post process compile time values and recompiles the shader.
  67214. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67215. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67216. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67217. * @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
  67218. * @param onCompiled Called when the shader has been compiled.
  67219. * @param onError Called if there is an error when compiling a shader.
  67220. */
  67221. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67222. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67223. /**
  67224. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  67225. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  67226. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  67227. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  67228. * The gaps between physical kernels are compensated for in the weighting of the samples
  67229. * @param idealKernel Ideal blur kernel.
  67230. * @return Nearest best kernel.
  67231. */
  67232. protected _nearestBestKernel(idealKernel: number): number;
  67233. /**
  67234. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  67235. * @param x The point on the Gaussian distribution to sample.
  67236. * @return the value of the Gaussian function at x.
  67237. */
  67238. protected _gaussianWeight(x: number): number;
  67239. /**
  67240. * Generates a string that can be used as a floating point number in GLSL.
  67241. * @param x Value to print.
  67242. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  67243. * @return GLSL float string.
  67244. */
  67245. protected _glslFloat(x: number, decimalFigures?: number): string;
  67246. }
  67247. }
  67248. declare module BABYLON {
  67249. /** @hidden */
  67250. export var shadowMapPixelShader: {
  67251. name: string;
  67252. shader: string;
  67253. };
  67254. }
  67255. declare module BABYLON {
  67256. /** @hidden */
  67257. export var bonesDeclaration: {
  67258. name: string;
  67259. shader: string;
  67260. };
  67261. }
  67262. declare module BABYLON {
  67263. /** @hidden */
  67264. export var morphTargetsVertexGlobalDeclaration: {
  67265. name: string;
  67266. shader: string;
  67267. };
  67268. }
  67269. declare module BABYLON {
  67270. /** @hidden */
  67271. export var morphTargetsVertexDeclaration: {
  67272. name: string;
  67273. shader: string;
  67274. };
  67275. }
  67276. declare module BABYLON {
  67277. /** @hidden */
  67278. export var instancesDeclaration: {
  67279. name: string;
  67280. shader: string;
  67281. };
  67282. }
  67283. declare module BABYLON {
  67284. /** @hidden */
  67285. export var helperFunctions: {
  67286. name: string;
  67287. shader: string;
  67288. };
  67289. }
  67290. declare module BABYLON {
  67291. /** @hidden */
  67292. export var morphTargetsVertex: {
  67293. name: string;
  67294. shader: string;
  67295. };
  67296. }
  67297. declare module BABYLON {
  67298. /** @hidden */
  67299. export var instancesVertex: {
  67300. name: string;
  67301. shader: string;
  67302. };
  67303. }
  67304. declare module BABYLON {
  67305. /** @hidden */
  67306. export var bonesVertex: {
  67307. name: string;
  67308. shader: string;
  67309. };
  67310. }
  67311. declare module BABYLON {
  67312. /** @hidden */
  67313. export var shadowMapVertexShader: {
  67314. name: string;
  67315. shader: string;
  67316. };
  67317. }
  67318. declare module BABYLON {
  67319. /** @hidden */
  67320. export var depthBoxBlurPixelShader: {
  67321. name: string;
  67322. shader: string;
  67323. };
  67324. }
  67325. declare module BABYLON {
  67326. /**
  67327. * Defines the options associated with the creation of a custom shader for a shadow generator.
  67328. */
  67329. export interface ICustomShaderOptions {
  67330. /**
  67331. * Gets or sets the custom shader name to use
  67332. */
  67333. shaderName: string;
  67334. /**
  67335. * The list of attribute names used in the shader
  67336. */
  67337. attributes?: string[];
  67338. /**
  67339. * The list of unifrom names used in the shader
  67340. */
  67341. uniforms?: string[];
  67342. /**
  67343. * The list of sampler names used in the shader
  67344. */
  67345. samplers?: string[];
  67346. /**
  67347. * The list of defines used in the shader
  67348. */
  67349. defines?: string[];
  67350. }
  67351. /**
  67352. * Interface to implement to create a shadow generator compatible with BJS.
  67353. */
  67354. export interface IShadowGenerator {
  67355. /**
  67356. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67357. * @returns The render target texture if present otherwise, null
  67358. */
  67359. getShadowMap(): Nullable<RenderTargetTexture>;
  67360. /**
  67361. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67362. * @returns The render target texture if the shadow map is present otherwise, null
  67363. */
  67364. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67365. /**
  67366. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67367. * @param subMesh The submesh we want to render in the shadow map
  67368. * @param useInstances Defines wether will draw in the map using instances
  67369. * @returns true if ready otherwise, false
  67370. */
  67371. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67372. /**
  67373. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67374. * @param defines Defines of the material we want to update
  67375. * @param lightIndex Index of the light in the enabled light list of the material
  67376. */
  67377. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67378. /**
  67379. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67380. * defined in the generator but impacting the effect).
  67381. * It implies the unifroms available on the materials are the standard BJS ones.
  67382. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67383. * @param effect The effect we are binfing the information for
  67384. */
  67385. bindShadowLight(lightIndex: string, effect: Effect): void;
  67386. /**
  67387. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67388. * (eq to shadow prjection matrix * light transform matrix)
  67389. * @returns The transform matrix used to create the shadow map
  67390. */
  67391. getTransformMatrix(): Matrix;
  67392. /**
  67393. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67394. * Cube and 2D textures for instance.
  67395. */
  67396. recreateShadowMap(): void;
  67397. /**
  67398. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67399. * @param onCompiled Callback triggered at the and of the effects compilation
  67400. * @param options Sets of optional options forcing the compilation with different modes
  67401. */
  67402. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67403. useInstances: boolean;
  67404. }>): void;
  67405. /**
  67406. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67407. * @param options Sets of optional options forcing the compilation with different modes
  67408. * @returns A promise that resolves when the compilation completes
  67409. */
  67410. forceCompilationAsync(options?: Partial<{
  67411. useInstances: boolean;
  67412. }>): Promise<void>;
  67413. /**
  67414. * Serializes the shadow generator setup to a json object.
  67415. * @returns The serialized JSON object
  67416. */
  67417. serialize(): any;
  67418. /**
  67419. * Disposes the Shadow map and related Textures and effects.
  67420. */
  67421. dispose(): void;
  67422. }
  67423. /**
  67424. * Default implementation IShadowGenerator.
  67425. * This is the main object responsible of generating shadows in the framework.
  67426. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67427. */
  67428. export class ShadowGenerator implements IShadowGenerator {
  67429. /**
  67430. * Shadow generator mode None: no filtering applied.
  67431. */
  67432. static readonly FILTER_NONE: number;
  67433. /**
  67434. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67435. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67436. */
  67437. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67438. /**
  67439. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67440. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67441. */
  67442. static readonly FILTER_POISSONSAMPLING: number;
  67443. /**
  67444. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67445. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67446. */
  67447. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67448. /**
  67449. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  67450. * edge artifacts on steep falloff.
  67451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67452. */
  67453. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  67454. /**
  67455. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67456. * edge artifacts on steep falloff.
  67457. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67458. */
  67459. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67460. /**
  67461. * Shadow generator mode PCF: Percentage Closer Filtering
  67462. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67463. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67464. */
  67465. static readonly FILTER_PCF: number;
  67466. /**
  67467. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  67468. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67469. * Contact Hardening
  67470. */
  67471. static readonly FILTER_PCSS: number;
  67472. /**
  67473. * Reserved for PCF and PCSS
  67474. * Highest Quality.
  67475. *
  67476. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  67477. *
  67478. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  67479. */
  67480. static readonly QUALITY_HIGH: number;
  67481. /**
  67482. * Reserved for PCF and PCSS
  67483. * Good tradeoff for quality/perf cross devices
  67484. *
  67485. * Execute PCF on a 3*3 kernel.
  67486. *
  67487. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  67488. */
  67489. static readonly QUALITY_MEDIUM: number;
  67490. /**
  67491. * Reserved for PCF and PCSS
  67492. * The lowest quality but the fastest.
  67493. *
  67494. * Execute PCF on a 1*1 kernel.
  67495. *
  67496. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  67497. */
  67498. static readonly QUALITY_LOW: number;
  67499. /** Gets or sets the custom shader name to use */
  67500. customShaderOptions: ICustomShaderOptions;
  67501. /**
  67502. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  67503. */
  67504. onBeforeShadowMapRenderObservable: Observable<Effect>;
  67505. /**
  67506. * Observable triggered before a mesh is rendered in the shadow map.
  67507. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  67508. */
  67509. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  67510. private _bias;
  67511. /**
  67512. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  67513. */
  67514. /**
  67515. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  67516. */
  67517. bias: number;
  67518. private _normalBias;
  67519. /**
  67520. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67521. */
  67522. /**
  67523. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67524. */
  67525. normalBias: number;
  67526. private _blurBoxOffset;
  67527. /**
  67528. * Gets the blur box offset: offset applied during the blur pass.
  67529. * Only useful if useKernelBlur = false
  67530. */
  67531. /**
  67532. * Sets the blur box offset: offset applied during the blur pass.
  67533. * Only useful if useKernelBlur = false
  67534. */
  67535. blurBoxOffset: number;
  67536. private _blurScale;
  67537. /**
  67538. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  67539. * 2 means half of the size.
  67540. */
  67541. /**
  67542. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  67543. * 2 means half of the size.
  67544. */
  67545. blurScale: number;
  67546. private _blurKernel;
  67547. /**
  67548. * Gets the blur kernel: kernel size of the blur pass.
  67549. * Only useful if useKernelBlur = true
  67550. */
  67551. /**
  67552. * Sets the blur kernel: kernel size of the blur pass.
  67553. * Only useful if useKernelBlur = true
  67554. */
  67555. blurKernel: number;
  67556. private _useKernelBlur;
  67557. /**
  67558. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  67559. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67560. */
  67561. /**
  67562. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67563. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67564. */
  67565. useKernelBlur: boolean;
  67566. private _depthScale;
  67567. /**
  67568. * Gets the depth scale used in ESM mode.
  67569. */
  67570. /**
  67571. * Sets the depth scale used in ESM mode.
  67572. * This can override the scale stored on the light.
  67573. */
  67574. depthScale: number;
  67575. private _filter;
  67576. /**
  67577. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67578. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67579. */
  67580. /**
  67581. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67582. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67583. */
  67584. filter: number;
  67585. /**
  67586. * Gets if the current filter is set to Poisson Sampling.
  67587. */
  67588. /**
  67589. * Sets the current filter to Poisson Sampling.
  67590. */
  67591. usePoissonSampling: boolean;
  67592. /**
  67593. * Gets if the current filter is set to ESM.
  67594. */
  67595. /**
  67596. * Sets the current filter is to ESM.
  67597. */
  67598. useExponentialShadowMap: boolean;
  67599. /**
  67600. * Gets if the current filter is set to filtered ESM.
  67601. */
  67602. /**
  67603. * Gets if the current filter is set to filtered ESM.
  67604. */
  67605. useBlurExponentialShadowMap: boolean;
  67606. /**
  67607. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67608. * exponential to prevent steep falloff artifacts).
  67609. */
  67610. /**
  67611. * Sets the current filter to "close ESM" (using the inverse of the
  67612. * exponential to prevent steep falloff artifacts).
  67613. */
  67614. useCloseExponentialShadowMap: boolean;
  67615. /**
  67616. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67617. * exponential to prevent steep falloff artifacts).
  67618. */
  67619. /**
  67620. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67621. * exponential to prevent steep falloff artifacts).
  67622. */
  67623. useBlurCloseExponentialShadowMap: boolean;
  67624. /**
  67625. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67626. */
  67627. /**
  67628. * Sets the current filter to "PCF" (percentage closer filtering).
  67629. */
  67630. usePercentageCloserFiltering: boolean;
  67631. private _filteringQuality;
  67632. /**
  67633. * Gets the PCF or PCSS Quality.
  67634. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67635. */
  67636. /**
  67637. * Sets the PCF or PCSS Quality.
  67638. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67639. */
  67640. filteringQuality: number;
  67641. /**
  67642. * Gets if the current filter is set to "PCSS" (contact hardening).
  67643. */
  67644. /**
  67645. * Sets the current filter to "PCSS" (contact hardening).
  67646. */
  67647. useContactHardeningShadow: boolean;
  67648. private _contactHardeningLightSizeUVRatio;
  67649. /**
  67650. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67651. * Using a ratio helps keeping shape stability independently of the map size.
  67652. *
  67653. * It does not account for the light projection as it was having too much
  67654. * instability during the light setup or during light position changes.
  67655. *
  67656. * Only valid if useContactHardeningShadow is true.
  67657. */
  67658. /**
  67659. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67660. * Using a ratio helps keeping shape stability independently of the map size.
  67661. *
  67662. * It does not account for the light projection as it was having too much
  67663. * instability during the light setup or during light position changes.
  67664. *
  67665. * Only valid if useContactHardeningShadow is true.
  67666. */
  67667. contactHardeningLightSizeUVRatio: number;
  67668. private _darkness;
  67669. /**
  67670. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67671. * 0 means strongest and 1 would means no shadow.
  67672. * @returns the darkness.
  67673. */
  67674. getDarkness(): number;
  67675. /**
  67676. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67677. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67678. * @returns the shadow generator allowing fluent coding.
  67679. */
  67680. setDarkness(darkness: number): ShadowGenerator;
  67681. private _transparencyShadow;
  67682. /**
  67683. * Sets the ability to have transparent shadow (boolean).
  67684. * @param transparent True if transparent else False
  67685. * @returns the shadow generator allowing fluent coding
  67686. */
  67687. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67688. private _shadowMap;
  67689. private _shadowMap2;
  67690. /**
  67691. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67692. * @returns The render target texture if present otherwise, null
  67693. */
  67694. getShadowMap(): Nullable<RenderTargetTexture>;
  67695. /**
  67696. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67697. * @returns The render target texture if the shadow map is present otherwise, null
  67698. */
  67699. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67700. /**
  67701. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67702. * @param mesh Mesh to add
  67703. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67704. * @returns the Shadow Generator itself
  67705. */
  67706. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67707. /**
  67708. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67709. * @param mesh Mesh to remove
  67710. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67711. * @returns the Shadow Generator itself
  67712. */
  67713. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67714. /**
  67715. * Controls the extent to which the shadows fade out at the edge of the frustum
  67716. * Used only by directionals and spots
  67717. */
  67718. frustumEdgeFalloff: number;
  67719. private _light;
  67720. /**
  67721. * Returns the associated light object.
  67722. * @returns the light generating the shadow
  67723. */
  67724. getLight(): IShadowLight;
  67725. /**
  67726. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67727. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67728. * It might on the other hand introduce peter panning.
  67729. */
  67730. forceBackFacesOnly: boolean;
  67731. private _scene;
  67732. private _lightDirection;
  67733. private _effect;
  67734. private _viewMatrix;
  67735. private _projectionMatrix;
  67736. private _transformMatrix;
  67737. private _cachedPosition;
  67738. private _cachedDirection;
  67739. private _cachedDefines;
  67740. private _currentRenderID;
  67741. private _boxBlurPostprocess;
  67742. private _kernelBlurXPostprocess;
  67743. private _kernelBlurYPostprocess;
  67744. private _blurPostProcesses;
  67745. private _mapSize;
  67746. private _currentFaceIndex;
  67747. private _currentFaceIndexCache;
  67748. private _textureType;
  67749. private _defaultTextureMatrix;
  67750. /** @hidden */
  67751. static _SceneComponentInitialization: (scene: Scene) => void;
  67752. /**
  67753. * Creates a ShadowGenerator object.
  67754. * A ShadowGenerator is the required tool to use the shadows.
  67755. * Each light casting shadows needs to use its own ShadowGenerator.
  67756. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67757. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67758. * @param light The light object generating the shadows.
  67759. * @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.
  67760. */
  67761. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67762. private _initializeGenerator;
  67763. private _initializeShadowMap;
  67764. private _initializeBlurRTTAndPostProcesses;
  67765. private _renderForShadowMap;
  67766. private _renderSubMeshForShadowMap;
  67767. private _applyFilterValues;
  67768. /**
  67769. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67770. * @param onCompiled Callback triggered at the and of the effects compilation
  67771. * @param options Sets of optional options forcing the compilation with different modes
  67772. */
  67773. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67774. useInstances: boolean;
  67775. }>): void;
  67776. /**
  67777. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67778. * @param options Sets of optional options forcing the compilation with different modes
  67779. * @returns A promise that resolves when the compilation completes
  67780. */
  67781. forceCompilationAsync(options?: Partial<{
  67782. useInstances: boolean;
  67783. }>): Promise<void>;
  67784. /**
  67785. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67786. * @param subMesh The submesh we want to render in the shadow map
  67787. * @param useInstances Defines wether will draw in the map using instances
  67788. * @returns true if ready otherwise, false
  67789. */
  67790. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67791. /**
  67792. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67793. * @param defines Defines of the material we want to update
  67794. * @param lightIndex Index of the light in the enabled light list of the material
  67795. */
  67796. prepareDefines(defines: any, lightIndex: number): void;
  67797. /**
  67798. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67799. * defined in the generator but impacting the effect).
  67800. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67801. * @param effect The effect we are binfing the information for
  67802. */
  67803. bindShadowLight(lightIndex: string, effect: Effect): void;
  67804. /**
  67805. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67806. * (eq to shadow prjection matrix * light transform matrix)
  67807. * @returns The transform matrix used to create the shadow map
  67808. */
  67809. getTransformMatrix(): Matrix;
  67810. /**
  67811. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67812. * Cube and 2D textures for instance.
  67813. */
  67814. recreateShadowMap(): void;
  67815. private _disposeBlurPostProcesses;
  67816. private _disposeRTTandPostProcesses;
  67817. /**
  67818. * Disposes the ShadowGenerator.
  67819. * Returns nothing.
  67820. */
  67821. dispose(): void;
  67822. /**
  67823. * Serializes the shadow generator setup to a json object.
  67824. * @returns The serialized JSON object
  67825. */
  67826. serialize(): any;
  67827. /**
  67828. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67829. * @param parsedShadowGenerator The JSON object to parse
  67830. * @param scene The scene to create the shadow map for
  67831. * @returns The parsed shadow generator
  67832. */
  67833. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67834. }
  67835. }
  67836. declare module BABYLON {
  67837. /**
  67838. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67839. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67840. * 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.
  67841. */
  67842. export abstract class Light extends Node {
  67843. /**
  67844. * Falloff Default: light is falling off following the material specification:
  67845. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67846. */
  67847. static readonly FALLOFF_DEFAULT: number;
  67848. /**
  67849. * Falloff Physical: light is falling off following the inverse squared distance law.
  67850. */
  67851. static readonly FALLOFF_PHYSICAL: number;
  67852. /**
  67853. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67854. * to enhance interoperability with other engines.
  67855. */
  67856. static readonly FALLOFF_GLTF: number;
  67857. /**
  67858. * Falloff Standard: light is falling off like in the standard material
  67859. * to enhance interoperability with other materials.
  67860. */
  67861. static readonly FALLOFF_STANDARD: number;
  67862. /**
  67863. * If every light affecting the material is in this lightmapMode,
  67864. * material.lightmapTexture adds or multiplies
  67865. * (depends on material.useLightmapAsShadowmap)
  67866. * after every other light calculations.
  67867. */
  67868. static readonly LIGHTMAP_DEFAULT: number;
  67869. /**
  67870. * material.lightmapTexture as only diffuse lighting from this light
  67871. * adds only specular lighting from this light
  67872. * adds dynamic shadows
  67873. */
  67874. static readonly LIGHTMAP_SPECULAR: number;
  67875. /**
  67876. * material.lightmapTexture as only lighting
  67877. * no light calculation from this light
  67878. * only adds dynamic shadows from this light
  67879. */
  67880. static readonly LIGHTMAP_SHADOWSONLY: number;
  67881. /**
  67882. * Each light type uses the default quantity according to its type:
  67883. * point/spot lights use luminous intensity
  67884. * directional lights use illuminance
  67885. */
  67886. static readonly INTENSITYMODE_AUTOMATIC: number;
  67887. /**
  67888. * lumen (lm)
  67889. */
  67890. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67891. /**
  67892. * candela (lm/sr)
  67893. */
  67894. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67895. /**
  67896. * lux (lm/m^2)
  67897. */
  67898. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67899. /**
  67900. * nit (cd/m^2)
  67901. */
  67902. static readonly INTENSITYMODE_LUMINANCE: number;
  67903. /**
  67904. * Light type const id of the point light.
  67905. */
  67906. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67907. /**
  67908. * Light type const id of the directional light.
  67909. */
  67910. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67911. /**
  67912. * Light type const id of the spot light.
  67913. */
  67914. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67915. /**
  67916. * Light type const id of the hemispheric light.
  67917. */
  67918. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67919. /**
  67920. * Diffuse gives the basic color to an object.
  67921. */
  67922. diffuse: Color3;
  67923. /**
  67924. * Specular produces a highlight color on an object.
  67925. * Note: This is note affecting PBR materials.
  67926. */
  67927. specular: Color3;
  67928. /**
  67929. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67930. * falling off base on range or angle.
  67931. * This can be set to any values in Light.FALLOFF_x.
  67932. *
  67933. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67934. * other types of materials.
  67935. */
  67936. falloffType: number;
  67937. /**
  67938. * Strength of the light.
  67939. * Note: By default it is define in the framework own unit.
  67940. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67941. */
  67942. intensity: number;
  67943. private _range;
  67944. protected _inverseSquaredRange: number;
  67945. /**
  67946. * Defines how far from the source the light is impacting in scene units.
  67947. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67948. */
  67949. /**
  67950. * Defines how far from the source the light is impacting in scene units.
  67951. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67952. */
  67953. range: number;
  67954. /**
  67955. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67956. * of light.
  67957. */
  67958. private _photometricScale;
  67959. private _intensityMode;
  67960. /**
  67961. * Gets the photometric scale used to interpret the intensity.
  67962. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67963. */
  67964. /**
  67965. * Sets the photometric scale used to interpret the intensity.
  67966. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67967. */
  67968. intensityMode: number;
  67969. private _radius;
  67970. /**
  67971. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67972. */
  67973. /**
  67974. * sets the light radius used by PBR Materials to simulate soft area lights.
  67975. */
  67976. radius: number;
  67977. private _renderPriority;
  67978. /**
  67979. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67980. * exceeding the number allowed of the materials.
  67981. */
  67982. renderPriority: number;
  67983. private _shadowEnabled;
  67984. /**
  67985. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67986. * the current shadow generator.
  67987. */
  67988. /**
  67989. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67990. * the current shadow generator.
  67991. */
  67992. shadowEnabled: boolean;
  67993. private _includedOnlyMeshes;
  67994. /**
  67995. * Gets the only meshes impacted by this light.
  67996. */
  67997. /**
  67998. * Sets the only meshes impacted by this light.
  67999. */
  68000. includedOnlyMeshes: AbstractMesh[];
  68001. private _excludedMeshes;
  68002. /**
  68003. * Gets the meshes not impacted by this light.
  68004. */
  68005. /**
  68006. * Sets the meshes not impacted by this light.
  68007. */
  68008. excludedMeshes: AbstractMesh[];
  68009. private _excludeWithLayerMask;
  68010. /**
  68011. * Gets the layer id use to find what meshes are not impacted by the light.
  68012. * Inactive if 0
  68013. */
  68014. /**
  68015. * Sets the layer id use to find what meshes are not impacted by the light.
  68016. * Inactive if 0
  68017. */
  68018. excludeWithLayerMask: number;
  68019. private _includeOnlyWithLayerMask;
  68020. /**
  68021. * Gets the layer id use to find what meshes are impacted by the light.
  68022. * Inactive if 0
  68023. */
  68024. /**
  68025. * Sets the layer id use to find what meshes are impacted by the light.
  68026. * Inactive if 0
  68027. */
  68028. includeOnlyWithLayerMask: number;
  68029. private _lightmapMode;
  68030. /**
  68031. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68032. */
  68033. /**
  68034. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68035. */
  68036. lightmapMode: number;
  68037. /**
  68038. * Shadow generator associted to the light.
  68039. * @hidden Internal use only.
  68040. */
  68041. _shadowGenerator: Nullable<IShadowGenerator>;
  68042. /**
  68043. * @hidden Internal use only.
  68044. */
  68045. _excludedMeshesIds: string[];
  68046. /**
  68047. * @hidden Internal use only.
  68048. */
  68049. _includedOnlyMeshesIds: string[];
  68050. /**
  68051. * The current light unifom buffer.
  68052. * @hidden Internal use only.
  68053. */
  68054. _uniformBuffer: UniformBuffer;
  68055. /**
  68056. * Creates a Light object in the scene.
  68057. * Documentation : https://doc.babylonjs.com/babylon101/lights
  68058. * @param name The firendly name of the light
  68059. * @param scene The scene the light belongs too
  68060. */
  68061. constructor(name: string, scene: Scene);
  68062. protected abstract _buildUniformLayout(): void;
  68063. /**
  68064. * Sets the passed Effect "effect" with the Light information.
  68065. * @param effect The effect to update
  68066. * @param lightIndex The index of the light in the effect to update
  68067. * @returns The light
  68068. */
  68069. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  68070. /**
  68071. * Returns the string "Light".
  68072. * @returns the class name
  68073. */
  68074. getClassName(): string;
  68075. /** @hidden */
  68076. readonly _isLight: boolean;
  68077. /**
  68078. * Converts the light information to a readable string for debug purpose.
  68079. * @param fullDetails Supports for multiple levels of logging within scene loading
  68080. * @returns the human readable light info
  68081. */
  68082. toString(fullDetails?: boolean): string;
  68083. /** @hidden */
  68084. protected _syncParentEnabledState(): void;
  68085. /**
  68086. * Set the enabled state of this node.
  68087. * @param value - the new enabled state
  68088. */
  68089. setEnabled(value: boolean): void;
  68090. /**
  68091. * Returns the Light associated shadow generator if any.
  68092. * @return the associated shadow generator.
  68093. */
  68094. getShadowGenerator(): Nullable<IShadowGenerator>;
  68095. /**
  68096. * Returns a Vector3, the absolute light position in the World.
  68097. * @returns the world space position of the light
  68098. */
  68099. getAbsolutePosition(): Vector3;
  68100. /**
  68101. * Specifies if the light will affect the passed mesh.
  68102. * @param mesh The mesh to test against the light
  68103. * @return true the mesh is affected otherwise, false.
  68104. */
  68105. canAffectMesh(mesh: AbstractMesh): boolean;
  68106. /**
  68107. * Sort function to order lights for rendering.
  68108. * @param a First Light object to compare to second.
  68109. * @param b Second Light object to compare first.
  68110. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  68111. */
  68112. static CompareLightsPriority(a: Light, b: Light): number;
  68113. /**
  68114. * Releases resources associated with this node.
  68115. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  68116. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  68117. */
  68118. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  68119. /**
  68120. * Returns the light type ID (integer).
  68121. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68122. */
  68123. getTypeID(): number;
  68124. /**
  68125. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  68126. * @returns the scaled intensity in intensity mode unit
  68127. */
  68128. getScaledIntensity(): number;
  68129. /**
  68130. * Returns a new Light object, named "name", from the current one.
  68131. * @param name The name of the cloned light
  68132. * @returns the new created light
  68133. */
  68134. clone(name: string): Nullable<Light>;
  68135. /**
  68136. * Serializes the current light into a Serialization object.
  68137. * @returns the serialized object.
  68138. */
  68139. serialize(): any;
  68140. /**
  68141. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68142. * This new light is named "name" and added to the passed scene.
  68143. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68144. * @param name The friendly name of the light
  68145. * @param scene The scene the new light will belong to
  68146. * @returns the constructor function
  68147. */
  68148. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68149. /**
  68150. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68151. * @param parsedLight The JSON representation of the light
  68152. * @param scene The scene to create the parsed light in
  68153. * @returns the created light after parsing
  68154. */
  68155. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68156. private _hookArrayForExcluded;
  68157. private _hookArrayForIncludedOnly;
  68158. private _resyncMeshes;
  68159. /**
  68160. * Forces the meshes to update their light related information in their rendering used effects
  68161. * @hidden Internal Use Only
  68162. */
  68163. _markMeshesAsLightDirty(): void;
  68164. /**
  68165. * Recomputes the cached photometric scale if needed.
  68166. */
  68167. private _computePhotometricScale;
  68168. /**
  68169. * Returns the Photometric Scale according to the light type and intensity mode.
  68170. */
  68171. private _getPhotometricScale;
  68172. /**
  68173. * Reorder the light in the scene according to their defined priority.
  68174. * @hidden Internal Use Only
  68175. */
  68176. _reorderLightsInScene(): void;
  68177. /**
  68178. * Prepares the list of defines specific to the light type.
  68179. * @param defines the list of defines
  68180. * @param lightIndex defines the index of the light for the effect
  68181. */
  68182. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68183. }
  68184. }
  68185. declare module BABYLON {
  68186. /**
  68187. * Interface used to define Action
  68188. */
  68189. export interface IAction {
  68190. /**
  68191. * Trigger for the action
  68192. */
  68193. trigger: number;
  68194. /** Options of the trigger */
  68195. triggerOptions: any;
  68196. /**
  68197. * Gets the trigger parameters
  68198. * @returns the trigger parameters
  68199. */
  68200. getTriggerParameter(): any;
  68201. /**
  68202. * Internal only - executes current action event
  68203. * @hidden
  68204. */
  68205. _executeCurrent(evt?: ActionEvent): void;
  68206. /**
  68207. * Serialize placeholder for child classes
  68208. * @param parent of child
  68209. * @returns the serialized object
  68210. */
  68211. serialize(parent: any): any;
  68212. /**
  68213. * Internal only
  68214. * @hidden
  68215. */
  68216. _prepare(): void;
  68217. /**
  68218. * Internal only - manager for action
  68219. * @hidden
  68220. */
  68221. _actionManager: AbstractActionManager;
  68222. }
  68223. /**
  68224. * The action to be carried out following a trigger
  68225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  68226. */
  68227. export class Action implements IAction {
  68228. /** the trigger, with or without parameters, for the action */
  68229. triggerOptions: any;
  68230. /**
  68231. * Trigger for the action
  68232. */
  68233. trigger: number;
  68234. /**
  68235. * Internal only - manager for action
  68236. * @hidden
  68237. */
  68238. _actionManager: ActionManager;
  68239. private _nextActiveAction;
  68240. private _child;
  68241. private _condition?;
  68242. private _triggerParameter;
  68243. /**
  68244. * An event triggered prior to action being executed.
  68245. */
  68246. onBeforeExecuteObservable: Observable<Action>;
  68247. /**
  68248. * Creates a new Action
  68249. * @param triggerOptions the trigger, with or without parameters, for the action
  68250. * @param condition an optional determinant of action
  68251. */
  68252. constructor(
  68253. /** the trigger, with or without parameters, for the action */
  68254. triggerOptions: any, condition?: Condition);
  68255. /**
  68256. * Internal only
  68257. * @hidden
  68258. */
  68259. _prepare(): void;
  68260. /**
  68261. * Gets the trigger parameters
  68262. * @returns the trigger parameters
  68263. */
  68264. getTriggerParameter(): any;
  68265. /**
  68266. * Internal only - executes current action event
  68267. * @hidden
  68268. */
  68269. _executeCurrent(evt?: ActionEvent): void;
  68270. /**
  68271. * Execute placeholder for child classes
  68272. * @param evt optional action event
  68273. */
  68274. execute(evt?: ActionEvent): void;
  68275. /**
  68276. * Skips to next active action
  68277. */
  68278. skipToNextActiveAction(): void;
  68279. /**
  68280. * Adds action to chain of actions, may be a DoNothingAction
  68281. * @param action defines the next action to execute
  68282. * @returns The action passed in
  68283. * @see https://www.babylonjs-playground.com/#1T30HR#0
  68284. */
  68285. then(action: Action): Action;
  68286. /**
  68287. * Internal only
  68288. * @hidden
  68289. */
  68290. _getProperty(propertyPath: string): string;
  68291. /**
  68292. * Internal only
  68293. * @hidden
  68294. */
  68295. _getEffectiveTarget(target: any, propertyPath: string): any;
  68296. /**
  68297. * Serialize placeholder for child classes
  68298. * @param parent of child
  68299. * @returns the serialized object
  68300. */
  68301. serialize(parent: any): any;
  68302. /**
  68303. * Internal only called by serialize
  68304. * @hidden
  68305. */
  68306. protected _serialize(serializedAction: any, parent?: any): any;
  68307. /**
  68308. * Internal only
  68309. * @hidden
  68310. */
  68311. static _SerializeValueAsString: (value: any) => string;
  68312. /**
  68313. * Internal only
  68314. * @hidden
  68315. */
  68316. static _GetTargetProperty: (target: Scene | Node) => {
  68317. name: string;
  68318. targetType: string;
  68319. value: string;
  68320. };
  68321. }
  68322. }
  68323. declare module BABYLON {
  68324. /**
  68325. * A Condition applied to an Action
  68326. */
  68327. export class Condition {
  68328. /**
  68329. * Internal only - manager for action
  68330. * @hidden
  68331. */
  68332. _actionManager: ActionManager;
  68333. /**
  68334. * Internal only
  68335. * @hidden
  68336. */
  68337. _evaluationId: number;
  68338. /**
  68339. * Internal only
  68340. * @hidden
  68341. */
  68342. _currentResult: boolean;
  68343. /**
  68344. * Creates a new Condition
  68345. * @param actionManager the manager of the action the condition is applied to
  68346. */
  68347. constructor(actionManager: ActionManager);
  68348. /**
  68349. * Check if the current condition is valid
  68350. * @returns a boolean
  68351. */
  68352. isValid(): boolean;
  68353. /**
  68354. * Internal only
  68355. * @hidden
  68356. */
  68357. _getProperty(propertyPath: string): string;
  68358. /**
  68359. * Internal only
  68360. * @hidden
  68361. */
  68362. _getEffectiveTarget(target: any, propertyPath: string): any;
  68363. /**
  68364. * Serialize placeholder for child classes
  68365. * @returns the serialized object
  68366. */
  68367. serialize(): any;
  68368. /**
  68369. * Internal only
  68370. * @hidden
  68371. */
  68372. protected _serialize(serializedCondition: any): any;
  68373. }
  68374. /**
  68375. * Defines specific conditional operators as extensions of Condition
  68376. */
  68377. export class ValueCondition extends Condition {
  68378. /** path to specify the property of the target the conditional operator uses */
  68379. propertyPath: string;
  68380. /** the value compared by the conditional operator against the current value of the property */
  68381. value: any;
  68382. /** the conditional operator, default ValueCondition.IsEqual */
  68383. operator: number;
  68384. /**
  68385. * Internal only
  68386. * @hidden
  68387. */
  68388. private static _IsEqual;
  68389. /**
  68390. * Internal only
  68391. * @hidden
  68392. */
  68393. private static _IsDifferent;
  68394. /**
  68395. * Internal only
  68396. * @hidden
  68397. */
  68398. private static _IsGreater;
  68399. /**
  68400. * Internal only
  68401. * @hidden
  68402. */
  68403. private static _IsLesser;
  68404. /**
  68405. * returns the number for IsEqual
  68406. */
  68407. static readonly IsEqual: number;
  68408. /**
  68409. * Returns the number for IsDifferent
  68410. */
  68411. static readonly IsDifferent: number;
  68412. /**
  68413. * Returns the number for IsGreater
  68414. */
  68415. static readonly IsGreater: number;
  68416. /**
  68417. * Returns the number for IsLesser
  68418. */
  68419. static readonly IsLesser: number;
  68420. /**
  68421. * Internal only The action manager for the condition
  68422. * @hidden
  68423. */
  68424. _actionManager: ActionManager;
  68425. /**
  68426. * Internal only
  68427. * @hidden
  68428. */
  68429. private _target;
  68430. /**
  68431. * Internal only
  68432. * @hidden
  68433. */
  68434. private _effectiveTarget;
  68435. /**
  68436. * Internal only
  68437. * @hidden
  68438. */
  68439. private _property;
  68440. /**
  68441. * Creates a new ValueCondition
  68442. * @param actionManager manager for the action the condition applies to
  68443. * @param target for the action
  68444. * @param propertyPath path to specify the property of the target the conditional operator uses
  68445. * @param value the value compared by the conditional operator against the current value of the property
  68446. * @param operator the conditional operator, default ValueCondition.IsEqual
  68447. */
  68448. constructor(actionManager: ActionManager, target: any,
  68449. /** path to specify the property of the target the conditional operator uses */
  68450. propertyPath: string,
  68451. /** the value compared by the conditional operator against the current value of the property */
  68452. value: any,
  68453. /** the conditional operator, default ValueCondition.IsEqual */
  68454. operator?: number);
  68455. /**
  68456. * Compares the given value with the property value for the specified conditional operator
  68457. * @returns the result of the comparison
  68458. */
  68459. isValid(): boolean;
  68460. /**
  68461. * Serialize the ValueCondition into a JSON compatible object
  68462. * @returns serialization object
  68463. */
  68464. serialize(): any;
  68465. /**
  68466. * Gets the name of the conditional operator for the ValueCondition
  68467. * @param operator the conditional operator
  68468. * @returns the name
  68469. */
  68470. static GetOperatorName(operator: number): string;
  68471. }
  68472. /**
  68473. * Defines a predicate condition as an extension of Condition
  68474. */
  68475. export class PredicateCondition extends Condition {
  68476. /** defines the predicate function used to validate the condition */
  68477. predicate: () => boolean;
  68478. /**
  68479. * Internal only - manager for action
  68480. * @hidden
  68481. */
  68482. _actionManager: ActionManager;
  68483. /**
  68484. * Creates a new PredicateCondition
  68485. * @param actionManager manager for the action the condition applies to
  68486. * @param predicate defines the predicate function used to validate the condition
  68487. */
  68488. constructor(actionManager: ActionManager,
  68489. /** defines the predicate function used to validate the condition */
  68490. predicate: () => boolean);
  68491. /**
  68492. * @returns the validity of the predicate condition
  68493. */
  68494. isValid(): boolean;
  68495. }
  68496. /**
  68497. * Defines a state condition as an extension of Condition
  68498. */
  68499. export class StateCondition extends Condition {
  68500. /** Value to compare with target state */
  68501. value: string;
  68502. /**
  68503. * Internal only - manager for action
  68504. * @hidden
  68505. */
  68506. _actionManager: ActionManager;
  68507. /**
  68508. * Internal only
  68509. * @hidden
  68510. */
  68511. private _target;
  68512. /**
  68513. * Creates a new StateCondition
  68514. * @param actionManager manager for the action the condition applies to
  68515. * @param target of the condition
  68516. * @param value to compare with target state
  68517. */
  68518. constructor(actionManager: ActionManager, target: any,
  68519. /** Value to compare with target state */
  68520. value: string);
  68521. /**
  68522. * Gets a boolean indicating if the current condition is met
  68523. * @returns the validity of the state
  68524. */
  68525. isValid(): boolean;
  68526. /**
  68527. * Serialize the StateCondition into a JSON compatible object
  68528. * @returns serialization object
  68529. */
  68530. serialize(): any;
  68531. }
  68532. }
  68533. declare module BABYLON {
  68534. /**
  68535. * This defines an action responsible to toggle a boolean once triggered.
  68536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68537. */
  68538. export class SwitchBooleanAction extends Action {
  68539. /**
  68540. * The path to the boolean property in the target object
  68541. */
  68542. propertyPath: string;
  68543. private _target;
  68544. private _effectiveTarget;
  68545. private _property;
  68546. /**
  68547. * Instantiate the action
  68548. * @param triggerOptions defines the trigger options
  68549. * @param target defines the object containing the boolean
  68550. * @param propertyPath defines the path to the boolean property in the target object
  68551. * @param condition defines the trigger related conditions
  68552. */
  68553. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  68554. /** @hidden */
  68555. _prepare(): void;
  68556. /**
  68557. * Execute the action toggle the boolean value.
  68558. */
  68559. execute(): void;
  68560. /**
  68561. * Serializes the actions and its related information.
  68562. * @param parent defines the object to serialize in
  68563. * @returns the serialized object
  68564. */
  68565. serialize(parent: any): any;
  68566. }
  68567. /**
  68568. * This defines an action responsible to set a the state field of the target
  68569. * to a desired value once triggered.
  68570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68571. */
  68572. export class SetStateAction extends Action {
  68573. /**
  68574. * The value to store in the state field.
  68575. */
  68576. value: string;
  68577. private _target;
  68578. /**
  68579. * Instantiate the action
  68580. * @param triggerOptions defines the trigger options
  68581. * @param target defines the object containing the state property
  68582. * @param value defines the value to store in the state field
  68583. * @param condition defines the trigger related conditions
  68584. */
  68585. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  68586. /**
  68587. * Execute the action and store the value on the target state property.
  68588. */
  68589. execute(): void;
  68590. /**
  68591. * Serializes the actions and its related information.
  68592. * @param parent defines the object to serialize in
  68593. * @returns the serialized object
  68594. */
  68595. serialize(parent: any): any;
  68596. }
  68597. /**
  68598. * This defines an action responsible to set a property of the target
  68599. * to a desired value once triggered.
  68600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68601. */
  68602. export class SetValueAction extends Action {
  68603. /**
  68604. * The path of the property to set in the target.
  68605. */
  68606. propertyPath: string;
  68607. /**
  68608. * The value to set in the property
  68609. */
  68610. value: any;
  68611. private _target;
  68612. private _effectiveTarget;
  68613. private _property;
  68614. /**
  68615. * Instantiate the action
  68616. * @param triggerOptions defines the trigger options
  68617. * @param target defines the object containing the property
  68618. * @param propertyPath defines the path of the property to set in the target
  68619. * @param value defines the value to set in the property
  68620. * @param condition defines the trigger related conditions
  68621. */
  68622. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68623. /** @hidden */
  68624. _prepare(): void;
  68625. /**
  68626. * Execute the action and set the targetted property to the desired value.
  68627. */
  68628. execute(): void;
  68629. /**
  68630. * Serializes the actions and its related information.
  68631. * @param parent defines the object to serialize in
  68632. * @returns the serialized object
  68633. */
  68634. serialize(parent: any): any;
  68635. }
  68636. /**
  68637. * This defines an action responsible to increment the target value
  68638. * to a desired value once triggered.
  68639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68640. */
  68641. export class IncrementValueAction extends Action {
  68642. /**
  68643. * The path of the property to increment in the target.
  68644. */
  68645. propertyPath: string;
  68646. /**
  68647. * The value we should increment the property by.
  68648. */
  68649. value: any;
  68650. private _target;
  68651. private _effectiveTarget;
  68652. private _property;
  68653. /**
  68654. * Instantiate the action
  68655. * @param triggerOptions defines the trigger options
  68656. * @param target defines the object containing the property
  68657. * @param propertyPath defines the path of the property to increment in the target
  68658. * @param value defines the value value we should increment the property by
  68659. * @param condition defines the trigger related conditions
  68660. */
  68661. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68662. /** @hidden */
  68663. _prepare(): void;
  68664. /**
  68665. * Execute the action and increment the target of the value amount.
  68666. */
  68667. execute(): void;
  68668. /**
  68669. * Serializes the actions and its related information.
  68670. * @param parent defines the object to serialize in
  68671. * @returns the serialized object
  68672. */
  68673. serialize(parent: any): any;
  68674. }
  68675. /**
  68676. * This defines an action responsible to start an animation once triggered.
  68677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68678. */
  68679. export class PlayAnimationAction extends Action {
  68680. /**
  68681. * Where the animation should start (animation frame)
  68682. */
  68683. from: number;
  68684. /**
  68685. * Where the animation should stop (animation frame)
  68686. */
  68687. to: number;
  68688. /**
  68689. * Define if the animation should loop or stop after the first play.
  68690. */
  68691. loop?: boolean;
  68692. private _target;
  68693. /**
  68694. * Instantiate the action
  68695. * @param triggerOptions defines the trigger options
  68696. * @param target defines the target animation or animation name
  68697. * @param from defines from where the animation should start (animation frame)
  68698. * @param end defines where the animation should stop (animation frame)
  68699. * @param loop defines if the animation should loop or stop after the first play
  68700. * @param condition defines the trigger related conditions
  68701. */
  68702. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68703. /** @hidden */
  68704. _prepare(): void;
  68705. /**
  68706. * Execute the action and play the animation.
  68707. */
  68708. execute(): void;
  68709. /**
  68710. * Serializes the actions and its related information.
  68711. * @param parent defines the object to serialize in
  68712. * @returns the serialized object
  68713. */
  68714. serialize(parent: any): any;
  68715. }
  68716. /**
  68717. * This defines an action responsible to stop an animation once triggered.
  68718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68719. */
  68720. export class StopAnimationAction extends Action {
  68721. private _target;
  68722. /**
  68723. * Instantiate the action
  68724. * @param triggerOptions defines the trigger options
  68725. * @param target defines the target animation or animation name
  68726. * @param condition defines the trigger related conditions
  68727. */
  68728. constructor(triggerOptions: any, target: any, condition?: Condition);
  68729. /** @hidden */
  68730. _prepare(): void;
  68731. /**
  68732. * Execute the action and stop the animation.
  68733. */
  68734. execute(): void;
  68735. /**
  68736. * Serializes the actions and its related information.
  68737. * @param parent defines the object to serialize in
  68738. * @returns the serialized object
  68739. */
  68740. serialize(parent: any): any;
  68741. }
  68742. /**
  68743. * This defines an action responsible that does nothing once triggered.
  68744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68745. */
  68746. export class DoNothingAction extends Action {
  68747. /**
  68748. * Instantiate the action
  68749. * @param triggerOptions defines the trigger options
  68750. * @param condition defines the trigger related conditions
  68751. */
  68752. constructor(triggerOptions?: any, condition?: Condition);
  68753. /**
  68754. * Execute the action and do nothing.
  68755. */
  68756. execute(): void;
  68757. /**
  68758. * Serializes the actions and its related information.
  68759. * @param parent defines the object to serialize in
  68760. * @returns the serialized object
  68761. */
  68762. serialize(parent: any): any;
  68763. }
  68764. /**
  68765. * This defines an action responsible to trigger several actions once triggered.
  68766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68767. */
  68768. export class CombineAction extends Action {
  68769. /**
  68770. * The list of aggregated animations to run.
  68771. */
  68772. children: Action[];
  68773. /**
  68774. * Instantiate the action
  68775. * @param triggerOptions defines the trigger options
  68776. * @param children defines the list of aggregated animations to run
  68777. * @param condition defines the trigger related conditions
  68778. */
  68779. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68780. /** @hidden */
  68781. _prepare(): void;
  68782. /**
  68783. * Execute the action and executes all the aggregated actions.
  68784. */
  68785. execute(evt: ActionEvent): void;
  68786. /**
  68787. * Serializes the actions and its related information.
  68788. * @param parent defines the object to serialize in
  68789. * @returns the serialized object
  68790. */
  68791. serialize(parent: any): any;
  68792. }
  68793. /**
  68794. * This defines an action responsible to run code (external event) once triggered.
  68795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68796. */
  68797. export class ExecuteCodeAction extends Action {
  68798. /**
  68799. * The callback function to run.
  68800. */
  68801. func: (evt: ActionEvent) => void;
  68802. /**
  68803. * Instantiate the action
  68804. * @param triggerOptions defines the trigger options
  68805. * @param func defines the callback function to run
  68806. * @param condition defines the trigger related conditions
  68807. */
  68808. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68809. /**
  68810. * Execute the action and run the attached code.
  68811. */
  68812. execute(evt: ActionEvent): void;
  68813. }
  68814. /**
  68815. * This defines an action responsible to set the parent property of the target once triggered.
  68816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68817. */
  68818. export class SetParentAction extends Action {
  68819. private _parent;
  68820. private _target;
  68821. /**
  68822. * Instantiate the action
  68823. * @param triggerOptions defines the trigger options
  68824. * @param target defines the target containing the parent property
  68825. * @param parent defines from where the animation should start (animation frame)
  68826. * @param condition defines the trigger related conditions
  68827. */
  68828. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68829. /** @hidden */
  68830. _prepare(): void;
  68831. /**
  68832. * Execute the action and set the parent property.
  68833. */
  68834. execute(): void;
  68835. /**
  68836. * Serializes the actions and its related information.
  68837. * @param parent defines the object to serialize in
  68838. * @returns the serialized object
  68839. */
  68840. serialize(parent: any): any;
  68841. }
  68842. }
  68843. declare module BABYLON {
  68844. /**
  68845. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68846. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68848. */
  68849. export class ActionManager extends AbstractActionManager {
  68850. /**
  68851. * Nothing
  68852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68853. */
  68854. static readonly NothingTrigger: number;
  68855. /**
  68856. * On pick
  68857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68858. */
  68859. static readonly OnPickTrigger: number;
  68860. /**
  68861. * On left pick
  68862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68863. */
  68864. static readonly OnLeftPickTrigger: number;
  68865. /**
  68866. * On right pick
  68867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68868. */
  68869. static readonly OnRightPickTrigger: number;
  68870. /**
  68871. * On center pick
  68872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68873. */
  68874. static readonly OnCenterPickTrigger: number;
  68875. /**
  68876. * On pick down
  68877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68878. */
  68879. static readonly OnPickDownTrigger: number;
  68880. /**
  68881. * On double pick
  68882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68883. */
  68884. static readonly OnDoublePickTrigger: number;
  68885. /**
  68886. * On pick up
  68887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68888. */
  68889. static readonly OnPickUpTrigger: number;
  68890. /**
  68891. * On pick out.
  68892. * This trigger will only be raised if you also declared a OnPickDown
  68893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68894. */
  68895. static readonly OnPickOutTrigger: number;
  68896. /**
  68897. * On long press
  68898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68899. */
  68900. static readonly OnLongPressTrigger: number;
  68901. /**
  68902. * On pointer over
  68903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68904. */
  68905. static readonly OnPointerOverTrigger: number;
  68906. /**
  68907. * On pointer out
  68908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68909. */
  68910. static readonly OnPointerOutTrigger: number;
  68911. /**
  68912. * On every frame
  68913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68914. */
  68915. static readonly OnEveryFrameTrigger: number;
  68916. /**
  68917. * On intersection enter
  68918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68919. */
  68920. static readonly OnIntersectionEnterTrigger: number;
  68921. /**
  68922. * On intersection exit
  68923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68924. */
  68925. static readonly OnIntersectionExitTrigger: number;
  68926. /**
  68927. * On key down
  68928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68929. */
  68930. static readonly OnKeyDownTrigger: number;
  68931. /**
  68932. * On key up
  68933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68934. */
  68935. static readonly OnKeyUpTrigger: number;
  68936. private _scene;
  68937. /**
  68938. * Creates a new action manager
  68939. * @param scene defines the hosting scene
  68940. */
  68941. constructor(scene: Scene);
  68942. /**
  68943. * Releases all associated resources
  68944. */
  68945. dispose(): void;
  68946. /**
  68947. * Gets hosting scene
  68948. * @returns the hosting scene
  68949. */
  68950. getScene(): Scene;
  68951. /**
  68952. * Does this action manager handles actions of any of the given triggers
  68953. * @param triggers defines the triggers to be tested
  68954. * @return a boolean indicating whether one (or more) of the triggers is handled
  68955. */
  68956. hasSpecificTriggers(triggers: number[]): boolean;
  68957. /**
  68958. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68959. * speed.
  68960. * @param triggerA defines the trigger to be tested
  68961. * @param triggerB defines the trigger to be tested
  68962. * @return a boolean indicating whether one (or more) of the triggers is handled
  68963. */
  68964. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68965. /**
  68966. * Does this action manager handles actions of a given trigger
  68967. * @param trigger defines the trigger to be tested
  68968. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68969. * @return whether the trigger is handled
  68970. */
  68971. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68972. /**
  68973. * Does this action manager has pointer triggers
  68974. */
  68975. readonly hasPointerTriggers: boolean;
  68976. /**
  68977. * Does this action manager has pick triggers
  68978. */
  68979. readonly hasPickTriggers: boolean;
  68980. /**
  68981. * Registers an action to this action manager
  68982. * @param action defines the action to be registered
  68983. * @return the action amended (prepared) after registration
  68984. */
  68985. registerAction(action: IAction): Nullable<IAction>;
  68986. /**
  68987. * Unregisters an action to this action manager
  68988. * @param action defines the action to be unregistered
  68989. * @return a boolean indicating whether the action has been unregistered
  68990. */
  68991. unregisterAction(action: IAction): Boolean;
  68992. /**
  68993. * Process a specific trigger
  68994. * @param trigger defines the trigger to process
  68995. * @param evt defines the event details to be processed
  68996. */
  68997. processTrigger(trigger: number, evt?: IActionEvent): void;
  68998. /** @hidden */
  68999. _getEffectiveTarget(target: any, propertyPath: string): any;
  69000. /** @hidden */
  69001. _getProperty(propertyPath: string): string;
  69002. /**
  69003. * Serialize this manager to a JSON object
  69004. * @param name defines the property name to store this manager
  69005. * @returns a JSON representation of this manager
  69006. */
  69007. serialize(name: string): any;
  69008. /**
  69009. * Creates a new ActionManager from a JSON data
  69010. * @param parsedActions defines the JSON data to read from
  69011. * @param object defines the hosting mesh
  69012. * @param scene defines the hosting scene
  69013. */
  69014. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  69015. /**
  69016. * Get a trigger name by index
  69017. * @param trigger defines the trigger index
  69018. * @returns a trigger name
  69019. */
  69020. static GetTriggerName(trigger: number): string;
  69021. }
  69022. }
  69023. declare module BABYLON {
  69024. /**
  69025. * Class representing a ray with position and direction
  69026. */
  69027. export class Ray {
  69028. /** origin point */
  69029. origin: Vector3;
  69030. /** direction */
  69031. direction: Vector3;
  69032. /** length of the ray */
  69033. length: number;
  69034. private static readonly TmpVector3;
  69035. private _tmpRay;
  69036. /**
  69037. * Creates a new ray
  69038. * @param origin origin point
  69039. * @param direction direction
  69040. * @param length length of the ray
  69041. */
  69042. constructor(
  69043. /** origin point */
  69044. origin: Vector3,
  69045. /** direction */
  69046. direction: Vector3,
  69047. /** length of the ray */
  69048. length?: number);
  69049. /**
  69050. * Checks if the ray intersects a box
  69051. * @param minimum bound of the box
  69052. * @param maximum bound of the box
  69053. * @param intersectionTreshold extra extend to be added to the box in all direction
  69054. * @returns if the box was hit
  69055. */
  69056. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  69057. /**
  69058. * Checks if the ray intersects a box
  69059. * @param box the bounding box to check
  69060. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  69061. * @returns if the box was hit
  69062. */
  69063. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  69064. /**
  69065. * If the ray hits a sphere
  69066. * @param sphere the bounding sphere to check
  69067. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  69068. * @returns true if it hits the sphere
  69069. */
  69070. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  69071. /**
  69072. * If the ray hits a triange
  69073. * @param vertex0 triangle vertex
  69074. * @param vertex1 triangle vertex
  69075. * @param vertex2 triangle vertex
  69076. * @returns intersection information if hit
  69077. */
  69078. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  69079. /**
  69080. * Checks if ray intersects a plane
  69081. * @param plane the plane to check
  69082. * @returns the distance away it was hit
  69083. */
  69084. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  69085. /**
  69086. * Checks if ray intersects a mesh
  69087. * @param mesh the mesh to check
  69088. * @param fastCheck if only the bounding box should checked
  69089. * @returns picking info of the intersecton
  69090. */
  69091. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  69092. /**
  69093. * Checks if ray intersects a mesh
  69094. * @param meshes the meshes to check
  69095. * @param fastCheck if only the bounding box should checked
  69096. * @param results array to store result in
  69097. * @returns Array of picking infos
  69098. */
  69099. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  69100. private _comparePickingInfo;
  69101. private static smallnum;
  69102. private static rayl;
  69103. /**
  69104. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  69105. * @param sega the first point of the segment to test the intersection against
  69106. * @param segb the second point of the segment to test the intersection against
  69107. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  69108. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  69109. */
  69110. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  69111. /**
  69112. * Update the ray from viewport position
  69113. * @param x position
  69114. * @param y y position
  69115. * @param viewportWidth viewport width
  69116. * @param viewportHeight viewport height
  69117. * @param world world matrix
  69118. * @param view view matrix
  69119. * @param projection projection matrix
  69120. * @returns this ray updated
  69121. */
  69122. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69123. /**
  69124. * Creates a ray with origin and direction of 0,0,0
  69125. * @returns the new ray
  69126. */
  69127. static Zero(): Ray;
  69128. /**
  69129. * Creates a new ray from screen space and viewport
  69130. * @param x position
  69131. * @param y y position
  69132. * @param viewportWidth viewport width
  69133. * @param viewportHeight viewport height
  69134. * @param world world matrix
  69135. * @param view view matrix
  69136. * @param projection projection matrix
  69137. * @returns new ray
  69138. */
  69139. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69140. /**
  69141. * 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
  69142. * transformed to the given world matrix.
  69143. * @param origin The origin point
  69144. * @param end The end point
  69145. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69146. * @returns the new ray
  69147. */
  69148. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69149. /**
  69150. * Transforms a ray by a matrix
  69151. * @param ray ray to transform
  69152. * @param matrix matrix to apply
  69153. * @returns the resulting new ray
  69154. */
  69155. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69156. /**
  69157. * Transforms a ray by a matrix
  69158. * @param ray ray to transform
  69159. * @param matrix matrix to apply
  69160. * @param result ray to store result in
  69161. */
  69162. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69163. /**
  69164. * Unproject a ray from screen space to object space
  69165. * @param sourceX defines the screen space x coordinate to use
  69166. * @param sourceY defines the screen space y coordinate to use
  69167. * @param viewportWidth defines the current width of the viewport
  69168. * @param viewportHeight defines the current height of the viewport
  69169. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69170. * @param view defines the view matrix to use
  69171. * @param projection defines the projection matrix to use
  69172. */
  69173. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69174. }
  69175. /**
  69176. * Type used to define predicate used to select faces when a mesh intersection is detected
  69177. */
  69178. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  69179. interface Scene {
  69180. /** @hidden */
  69181. _tempPickingRay: Nullable<Ray>;
  69182. /** @hidden */
  69183. _cachedRayForTransform: Ray;
  69184. /** @hidden */
  69185. _pickWithRayInverseMatrix: Matrix;
  69186. /** @hidden */
  69187. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  69188. /** @hidden */
  69189. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  69190. }
  69191. }
  69192. declare module BABYLON {
  69193. /**
  69194. * Groups all the scene component constants in one place to ease maintenance.
  69195. * @hidden
  69196. */
  69197. export class SceneComponentConstants {
  69198. static readonly NAME_EFFECTLAYER: string;
  69199. static readonly NAME_LAYER: string;
  69200. static readonly NAME_LENSFLARESYSTEM: string;
  69201. static readonly NAME_BOUNDINGBOXRENDERER: string;
  69202. static readonly NAME_PARTICLESYSTEM: string;
  69203. static readonly NAME_GAMEPAD: string;
  69204. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  69205. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  69206. static readonly NAME_DEPTHRENDERER: string;
  69207. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  69208. static readonly NAME_SPRITE: string;
  69209. static readonly NAME_OUTLINERENDERER: string;
  69210. static readonly NAME_PROCEDURALTEXTURE: string;
  69211. static readonly NAME_SHADOWGENERATOR: string;
  69212. static readonly NAME_OCTREE: string;
  69213. static readonly NAME_PHYSICSENGINE: string;
  69214. static readonly NAME_AUDIO: string;
  69215. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  69216. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69217. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  69218. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69219. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  69220. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  69221. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  69222. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  69223. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  69224. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  69225. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  69226. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  69227. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  69228. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  69229. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  69230. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  69231. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  69232. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  69233. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  69234. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  69235. static readonly STEP_AFTERRENDER_AUDIO: number;
  69236. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  69237. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  69238. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  69239. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  69240. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  69241. static readonly STEP_POINTERMOVE_SPRITE: number;
  69242. static readonly STEP_POINTERDOWN_SPRITE: number;
  69243. static readonly STEP_POINTERUP_SPRITE: number;
  69244. }
  69245. /**
  69246. * This represents a scene component.
  69247. *
  69248. * This is used to decouple the dependency the scene is having on the different workloads like
  69249. * layers, post processes...
  69250. */
  69251. export interface ISceneComponent {
  69252. /**
  69253. * The name of the component. Each component must have a unique name.
  69254. */
  69255. name: string;
  69256. /**
  69257. * The scene the component belongs to.
  69258. */
  69259. scene: Scene;
  69260. /**
  69261. * Register the component to one instance of a scene.
  69262. */
  69263. register(): void;
  69264. /**
  69265. * Rebuilds the elements related to this component in case of
  69266. * context lost for instance.
  69267. */
  69268. rebuild(): void;
  69269. /**
  69270. * Disposes the component and the associated ressources.
  69271. */
  69272. dispose(): void;
  69273. }
  69274. /**
  69275. * This represents a SERIALIZABLE scene component.
  69276. *
  69277. * This extends Scene Component to add Serialization methods on top.
  69278. */
  69279. export interface ISceneSerializableComponent extends ISceneComponent {
  69280. /**
  69281. * Adds all the element from the container to the scene
  69282. * @param container the container holding the elements
  69283. */
  69284. addFromContainer(container: AbstractScene): void;
  69285. /**
  69286. * Removes all the elements in the container from the scene
  69287. * @param container contains the elements to remove
  69288. */
  69289. removeFromContainer(container: AbstractScene): void;
  69290. /**
  69291. * Serializes the component data to the specified json object
  69292. * @param serializationObject The object to serialize to
  69293. */
  69294. serialize(serializationObject: any): void;
  69295. }
  69296. /**
  69297. * Strong typing of a Mesh related stage step action
  69298. */
  69299. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69300. /**
  69301. * Strong typing of a Evaluate Sub Mesh related stage step action
  69302. */
  69303. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69304. /**
  69305. * Strong typing of a Active Mesh related stage step action
  69306. */
  69307. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69308. /**
  69309. * Strong typing of a Camera related stage step action
  69310. */
  69311. export type CameraStageAction = (camera: Camera) => void;
  69312. /**
  69313. * Strong typing of a Render Target related stage step action
  69314. */
  69315. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69316. /**
  69317. * Strong typing of a RenderingGroup related stage step action
  69318. */
  69319. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69320. /**
  69321. * Strong typing of a Mesh Render related stage step action
  69322. */
  69323. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  69324. /**
  69325. * Strong typing of a simple stage step action
  69326. */
  69327. export type SimpleStageAction = () => void;
  69328. /**
  69329. * Strong typing of a render target action.
  69330. */
  69331. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  69332. /**
  69333. * Strong typing of a pointer move action.
  69334. */
  69335. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69336. /**
  69337. * Strong typing of a pointer up/down action.
  69338. */
  69339. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69340. /**
  69341. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69342. * @hidden
  69343. */
  69344. export class Stage<T extends Function> extends Array<{
  69345. index: number;
  69346. component: ISceneComponent;
  69347. action: T;
  69348. }> {
  69349. /**
  69350. * Hide ctor from the rest of the world.
  69351. * @param items The items to add.
  69352. */
  69353. private constructor();
  69354. /**
  69355. * Creates a new Stage.
  69356. * @returns A new instance of a Stage
  69357. */
  69358. static Create<T extends Function>(): Stage<T>;
  69359. /**
  69360. * Registers a step in an ordered way in the targeted stage.
  69361. * @param index Defines the position to register the step in
  69362. * @param component Defines the component attached to the step
  69363. * @param action Defines the action to launch during the step
  69364. */
  69365. registerStep(index: number, component: ISceneComponent, action: T): void;
  69366. /**
  69367. * Clears all the steps from the stage.
  69368. */
  69369. clear(): void;
  69370. }
  69371. }
  69372. declare module BABYLON {
  69373. interface Scene {
  69374. /** @hidden */
  69375. _pointerOverSprite: Nullable<Sprite>;
  69376. /** @hidden */
  69377. _pickedDownSprite: Nullable<Sprite>;
  69378. /** @hidden */
  69379. _tempSpritePickingRay: Nullable<Ray>;
  69380. /**
  69381. * All of the sprite managers added to this scene
  69382. * @see http://doc.babylonjs.com/babylon101/sprites
  69383. */
  69384. spriteManagers: Array<ISpriteManager>;
  69385. /**
  69386. * An event triggered when sprites rendering is about to start
  69387. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69388. */
  69389. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69390. /**
  69391. * An event triggered when sprites rendering is done
  69392. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69393. */
  69394. onAfterSpritesRenderingObservable: Observable<Scene>;
  69395. /** @hidden */
  69396. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69397. /** Launch a ray to try to pick a sprite in the scene
  69398. * @param x position on screen
  69399. * @param y position on screen
  69400. * @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
  69401. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69402. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69403. * @returns a PickingInfo
  69404. */
  69405. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69406. /** Use the given ray to pick a sprite in the scene
  69407. * @param ray The ray (in world space) to use to pick meshes
  69408. * @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
  69409. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69410. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69411. * @returns a PickingInfo
  69412. */
  69413. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69414. /**
  69415. * Force the sprite under the pointer
  69416. * @param sprite defines the sprite to use
  69417. */
  69418. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69419. /**
  69420. * Gets the sprite under the pointer
  69421. * @returns a Sprite or null if no sprite is under the pointer
  69422. */
  69423. getPointerOverSprite(): Nullable<Sprite>;
  69424. }
  69425. /**
  69426. * Defines the sprite scene component responsible to manage sprites
  69427. * in a given scene.
  69428. */
  69429. export class SpriteSceneComponent implements ISceneComponent {
  69430. /**
  69431. * The component name helpfull to identify the component in the list of scene components.
  69432. */
  69433. readonly name: string;
  69434. /**
  69435. * The scene the component belongs to.
  69436. */
  69437. scene: Scene;
  69438. /** @hidden */
  69439. private _spritePredicate;
  69440. /**
  69441. * Creates a new instance of the component for the given scene
  69442. * @param scene Defines the scene to register the component in
  69443. */
  69444. constructor(scene: Scene);
  69445. /**
  69446. * Registers the component in a given scene
  69447. */
  69448. register(): void;
  69449. /**
  69450. * Rebuilds the elements related to this component in case of
  69451. * context lost for instance.
  69452. */
  69453. rebuild(): void;
  69454. /**
  69455. * Disposes the component and the associated ressources.
  69456. */
  69457. dispose(): void;
  69458. private _pickSpriteButKeepRay;
  69459. private _pointerMove;
  69460. private _pointerDown;
  69461. private _pointerUp;
  69462. }
  69463. }
  69464. declare module BABYLON {
  69465. /** @hidden */
  69466. export var fogFragmentDeclaration: {
  69467. name: string;
  69468. shader: string;
  69469. };
  69470. }
  69471. declare module BABYLON {
  69472. /** @hidden */
  69473. export var fogFragment: {
  69474. name: string;
  69475. shader: string;
  69476. };
  69477. }
  69478. declare module BABYLON {
  69479. /** @hidden */
  69480. export var spritesPixelShader: {
  69481. name: string;
  69482. shader: string;
  69483. };
  69484. }
  69485. declare module BABYLON {
  69486. /** @hidden */
  69487. export var fogVertexDeclaration: {
  69488. name: string;
  69489. shader: string;
  69490. };
  69491. }
  69492. declare module BABYLON {
  69493. /** @hidden */
  69494. export var spritesVertexShader: {
  69495. name: string;
  69496. shader: string;
  69497. };
  69498. }
  69499. declare module BABYLON {
  69500. /**
  69501. * Defines the minimum interface to fullfil in order to be a sprite manager.
  69502. */
  69503. export interface ISpriteManager extends IDisposable {
  69504. /**
  69505. * Restricts the camera to viewing objects with the same layerMask.
  69506. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  69507. */
  69508. layerMask: number;
  69509. /**
  69510. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  69511. */
  69512. isPickable: boolean;
  69513. /**
  69514. * Specifies the rendering group id for this mesh (0 by default)
  69515. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  69516. */
  69517. renderingGroupId: number;
  69518. /**
  69519. * Defines the list of sprites managed by the manager.
  69520. */
  69521. sprites: Array<Sprite>;
  69522. /**
  69523. * Tests the intersection of a sprite with a specific ray.
  69524. * @param ray The ray we are sending to test the collision
  69525. * @param camera The camera space we are sending rays in
  69526. * @param predicate A predicate allowing excluding sprites from the list of object to test
  69527. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  69528. * @returns picking info or null.
  69529. */
  69530. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69531. /**
  69532. * Renders the list of sprites on screen.
  69533. */
  69534. render(): void;
  69535. }
  69536. /**
  69537. * Class used to manage multiple sprites on the same spritesheet
  69538. * @see http://doc.babylonjs.com/babylon101/sprites
  69539. */
  69540. export class SpriteManager implements ISpriteManager {
  69541. /** defines the manager's name */
  69542. name: string;
  69543. /** Gets the list of sprites */
  69544. sprites: Sprite[];
  69545. /** Gets or sets the rendering group id (0 by default) */
  69546. renderingGroupId: number;
  69547. /** Gets or sets camera layer mask */
  69548. layerMask: number;
  69549. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  69550. fogEnabled: boolean;
  69551. /** Gets or sets a boolean indicating if the sprites are pickable */
  69552. isPickable: boolean;
  69553. /** Defines the default width of a cell in the spritesheet */
  69554. cellWidth: number;
  69555. /** Defines the default height of a cell in the spritesheet */
  69556. cellHeight: number;
  69557. /**
  69558. * An event triggered when the manager is disposed.
  69559. */
  69560. onDisposeObservable: Observable<SpriteManager>;
  69561. private _onDisposeObserver;
  69562. /**
  69563. * Callback called when the manager is disposed
  69564. */
  69565. onDispose: () => void;
  69566. private _capacity;
  69567. private _spriteTexture;
  69568. private _epsilon;
  69569. private _scene;
  69570. private _vertexData;
  69571. private _buffer;
  69572. private _vertexBuffers;
  69573. private _indexBuffer;
  69574. private _effectBase;
  69575. private _effectFog;
  69576. /**
  69577. * Gets or sets the spritesheet texture
  69578. */
  69579. texture: Texture;
  69580. /**
  69581. * Creates a new sprite manager
  69582. * @param name defines the manager's name
  69583. * @param imgUrl defines the sprite sheet url
  69584. * @param capacity defines the maximum allowed number of sprites
  69585. * @param cellSize defines the size of a sprite cell
  69586. * @param scene defines the hosting scene
  69587. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69588. * @param samplingMode defines the smapling mode to use with spritesheet
  69589. */
  69590. constructor(
  69591. /** defines the manager's name */
  69592. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69593. private _appendSpriteVertex;
  69594. /**
  69595. * Intersects the sprites with a ray
  69596. * @param ray defines the ray to intersect with
  69597. * @param camera defines the current active camera
  69598. * @param predicate defines a predicate used to select candidate sprites
  69599. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69600. * @returns null if no hit or a PickingInfo
  69601. */
  69602. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69603. /**
  69604. * Render all child sprites
  69605. */
  69606. render(): void;
  69607. /**
  69608. * Release associated resources
  69609. */
  69610. dispose(): void;
  69611. }
  69612. }
  69613. declare module BABYLON {
  69614. /**
  69615. * Class used to represent a sprite
  69616. * @see http://doc.babylonjs.com/babylon101/sprites
  69617. */
  69618. export class Sprite {
  69619. /** defines the name */
  69620. name: string;
  69621. /** Gets or sets the current world position */
  69622. position: Vector3;
  69623. /** Gets or sets the main color */
  69624. color: Color4;
  69625. /** Gets or sets the width */
  69626. width: number;
  69627. /** Gets or sets the height */
  69628. height: number;
  69629. /** Gets or sets rotation angle */
  69630. angle: number;
  69631. /** Gets or sets the cell index in the sprite sheet */
  69632. cellIndex: number;
  69633. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69634. invertU: number;
  69635. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69636. invertV: number;
  69637. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69638. disposeWhenFinishedAnimating: boolean;
  69639. /** Gets the list of attached animations */
  69640. animations: Animation[];
  69641. /** Gets or sets a boolean indicating if the sprite can be picked */
  69642. isPickable: boolean;
  69643. /**
  69644. * Gets or sets the associated action manager
  69645. */
  69646. actionManager: Nullable<ActionManager>;
  69647. private _animationStarted;
  69648. private _loopAnimation;
  69649. private _fromIndex;
  69650. private _toIndex;
  69651. private _delay;
  69652. private _direction;
  69653. private _manager;
  69654. private _time;
  69655. private _onAnimationEnd;
  69656. /**
  69657. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69658. */
  69659. isVisible: boolean;
  69660. /**
  69661. * Gets or sets the sprite size
  69662. */
  69663. size: number;
  69664. /**
  69665. * Creates a new Sprite
  69666. * @param name defines the name
  69667. * @param manager defines the manager
  69668. */
  69669. constructor(
  69670. /** defines the name */
  69671. name: string, manager: ISpriteManager);
  69672. /**
  69673. * Starts an animation
  69674. * @param from defines the initial key
  69675. * @param to defines the end key
  69676. * @param loop defines if the animation must loop
  69677. * @param delay defines the start delay (in ms)
  69678. * @param onAnimationEnd defines a callback to call when animation ends
  69679. */
  69680. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69681. /** Stops current animation (if any) */
  69682. stopAnimation(): void;
  69683. /** @hidden */
  69684. _animate(deltaTime: number): void;
  69685. /** Release associated resources */
  69686. dispose(): void;
  69687. }
  69688. }
  69689. declare module BABYLON {
  69690. /**
  69691. * Information about the result of picking within a scene
  69692. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69693. */
  69694. export class PickingInfo {
  69695. /** @hidden */
  69696. _pickingUnavailable: boolean;
  69697. /**
  69698. * If the pick collided with an object
  69699. */
  69700. hit: boolean;
  69701. /**
  69702. * Distance away where the pick collided
  69703. */
  69704. distance: number;
  69705. /**
  69706. * The location of pick collision
  69707. */
  69708. pickedPoint: Nullable<Vector3>;
  69709. /**
  69710. * The mesh corresponding the the pick collision
  69711. */
  69712. pickedMesh: Nullable<AbstractMesh>;
  69713. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69714. bu: number;
  69715. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69716. bv: number;
  69717. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69718. faceId: number;
  69719. /** Id of the the submesh that was picked */
  69720. subMeshId: number;
  69721. /** If a sprite was picked, this will be the sprite the pick collided with */
  69722. pickedSprite: Nullable<Sprite>;
  69723. /**
  69724. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69725. */
  69726. originMesh: Nullable<AbstractMesh>;
  69727. /**
  69728. * The ray that was used to perform the picking.
  69729. */
  69730. ray: Nullable<Ray>;
  69731. /**
  69732. * Gets the normal correspodning to the face the pick collided with
  69733. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69734. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69735. * @returns The normal correspodning to the face the pick collided with
  69736. */
  69737. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69738. /**
  69739. * Gets the texture coordinates of where the pick occured
  69740. * @returns the vector containing the coordnates of the texture
  69741. */
  69742. getTextureCoordinates(): Nullable<Vector2>;
  69743. }
  69744. }
  69745. declare module BABYLON {
  69746. /**
  69747. * Gather the list of pointer event types as constants.
  69748. */
  69749. export class PointerEventTypes {
  69750. /**
  69751. * 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.
  69752. */
  69753. static readonly POINTERDOWN: number;
  69754. /**
  69755. * The pointerup event is fired when a pointer is no longer active.
  69756. */
  69757. static readonly POINTERUP: number;
  69758. /**
  69759. * The pointermove event is fired when a pointer changes coordinates.
  69760. */
  69761. static readonly POINTERMOVE: number;
  69762. /**
  69763. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69764. */
  69765. static readonly POINTERWHEEL: number;
  69766. /**
  69767. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69768. */
  69769. static readonly POINTERPICK: number;
  69770. /**
  69771. * The pointertap event is fired when a the object has been touched and released without drag.
  69772. */
  69773. static readonly POINTERTAP: number;
  69774. /**
  69775. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69776. */
  69777. static readonly POINTERDOUBLETAP: number;
  69778. }
  69779. /**
  69780. * Base class of pointer info types.
  69781. */
  69782. export class PointerInfoBase {
  69783. /**
  69784. * Defines the type of event (PointerEventTypes)
  69785. */
  69786. type: number;
  69787. /**
  69788. * Defines the related dom event
  69789. */
  69790. event: PointerEvent | MouseWheelEvent;
  69791. /**
  69792. * Instantiates the base class of pointers info.
  69793. * @param type Defines the type of event (PointerEventTypes)
  69794. * @param event Defines the related dom event
  69795. */
  69796. constructor(
  69797. /**
  69798. * Defines the type of event (PointerEventTypes)
  69799. */
  69800. type: number,
  69801. /**
  69802. * Defines the related dom event
  69803. */
  69804. event: PointerEvent | MouseWheelEvent);
  69805. }
  69806. /**
  69807. * This class is used to store pointer related info for the onPrePointerObservable event.
  69808. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69809. */
  69810. export class PointerInfoPre extends PointerInfoBase {
  69811. /**
  69812. * Ray from a pointer if availible (eg. 6dof controller)
  69813. */
  69814. ray: Nullable<Ray>;
  69815. /**
  69816. * Defines the local position of the pointer on the canvas.
  69817. */
  69818. localPosition: Vector2;
  69819. /**
  69820. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69821. */
  69822. skipOnPointerObservable: boolean;
  69823. /**
  69824. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69825. * @param type Defines the type of event (PointerEventTypes)
  69826. * @param event Defines the related dom event
  69827. * @param localX Defines the local x coordinates of the pointer when the event occured
  69828. * @param localY Defines the local y coordinates of the pointer when the event occured
  69829. */
  69830. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69831. }
  69832. /**
  69833. * This type contains all the data related to a pointer event in Babylon.js.
  69834. * 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.
  69835. */
  69836. export class PointerInfo extends PointerInfoBase {
  69837. /**
  69838. * Defines the picking info associated to the info (if any)\
  69839. */
  69840. pickInfo: Nullable<PickingInfo>;
  69841. /**
  69842. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69843. * @param type Defines the type of event (PointerEventTypes)
  69844. * @param event Defines the related dom event
  69845. * @param pickInfo Defines the picking info associated to the info (if any)\
  69846. */
  69847. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69848. /**
  69849. * Defines the picking info associated to the info (if any)\
  69850. */
  69851. pickInfo: Nullable<PickingInfo>);
  69852. }
  69853. /**
  69854. * Data relating to a touch event on the screen.
  69855. */
  69856. export interface PointerTouch {
  69857. /**
  69858. * X coordinate of touch.
  69859. */
  69860. x: number;
  69861. /**
  69862. * Y coordinate of touch.
  69863. */
  69864. y: number;
  69865. /**
  69866. * Id of touch. Unique for each finger.
  69867. */
  69868. pointerId: number;
  69869. /**
  69870. * Event type passed from DOM.
  69871. */
  69872. type: any;
  69873. }
  69874. }
  69875. declare module BABYLON {
  69876. /**
  69877. * Manage the mouse inputs to control the movement of a free camera.
  69878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69879. */
  69880. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69881. /**
  69882. * Define if touch is enabled in the mouse input
  69883. */
  69884. touchEnabled: boolean;
  69885. /**
  69886. * Defines the camera the input is attached to.
  69887. */
  69888. camera: FreeCamera;
  69889. /**
  69890. * Defines the buttons associated with the input to handle camera move.
  69891. */
  69892. buttons: number[];
  69893. /**
  69894. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69895. */
  69896. angularSensibility: number;
  69897. private _pointerInput;
  69898. private _onMouseMove;
  69899. private _observer;
  69900. private previousPosition;
  69901. /**
  69902. * Manage the mouse inputs to control the movement of a free camera.
  69903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69904. * @param touchEnabled Defines if touch is enabled or not
  69905. */
  69906. constructor(
  69907. /**
  69908. * Define if touch is enabled in the mouse input
  69909. */
  69910. touchEnabled?: boolean);
  69911. /**
  69912. * Attach the input controls to a specific dom element to get the input from.
  69913. * @param element Defines the element the controls should be listened from
  69914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69915. */
  69916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69917. /**
  69918. * Called on JS contextmenu event.
  69919. * Override this method to provide functionality.
  69920. */
  69921. protected onContextMenu(evt: PointerEvent): void;
  69922. /**
  69923. * Detach the current controls from the specified dom element.
  69924. * @param element Defines the element to stop listening the inputs from
  69925. */
  69926. detachControl(element: Nullable<HTMLElement>): void;
  69927. /**
  69928. * Gets the class name of the current intput.
  69929. * @returns the class name
  69930. */
  69931. getClassName(): string;
  69932. /**
  69933. * Get the friendly name associated with the input class.
  69934. * @returns the input friendly name
  69935. */
  69936. getSimpleName(): string;
  69937. }
  69938. }
  69939. declare module BABYLON {
  69940. /**
  69941. * Manage the touch inputs to control the movement of a free camera.
  69942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69943. */
  69944. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69945. /**
  69946. * Defines the camera the input is attached to.
  69947. */
  69948. camera: FreeCamera;
  69949. /**
  69950. * Defines the touch sensibility for rotation.
  69951. * The higher the faster.
  69952. */
  69953. touchAngularSensibility: number;
  69954. /**
  69955. * Defines the touch sensibility for move.
  69956. * The higher the faster.
  69957. */
  69958. touchMoveSensibility: number;
  69959. private _offsetX;
  69960. private _offsetY;
  69961. private _pointerPressed;
  69962. private _pointerInput;
  69963. private _observer;
  69964. private _onLostFocus;
  69965. /**
  69966. * Attach the input controls to a specific dom element to get the input from.
  69967. * @param element Defines the element the controls should be listened from
  69968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69969. */
  69970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69971. /**
  69972. * Detach the current controls from the specified dom element.
  69973. * @param element Defines the element to stop listening the inputs from
  69974. */
  69975. detachControl(element: Nullable<HTMLElement>): void;
  69976. /**
  69977. * Update the current camera state depending on the inputs that have been used this frame.
  69978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69979. */
  69980. checkInputs(): void;
  69981. /**
  69982. * Gets the class name of the current intput.
  69983. * @returns the class name
  69984. */
  69985. getClassName(): string;
  69986. /**
  69987. * Get the friendly name associated with the input class.
  69988. * @returns the input friendly name
  69989. */
  69990. getSimpleName(): string;
  69991. }
  69992. }
  69993. declare module BABYLON {
  69994. /**
  69995. * Default Inputs manager for the FreeCamera.
  69996. * It groups all the default supported inputs for ease of use.
  69997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69998. */
  69999. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  70000. /**
  70001. * Instantiates a new FreeCameraInputsManager.
  70002. * @param camera Defines the camera the inputs belong to
  70003. */
  70004. constructor(camera: FreeCamera);
  70005. /**
  70006. * Add keyboard input support to the input manager.
  70007. * @returns the current input manager
  70008. */
  70009. addKeyboard(): FreeCameraInputsManager;
  70010. /**
  70011. * Add mouse input support to the input manager.
  70012. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  70013. * @returns the current input manager
  70014. */
  70015. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  70016. /**
  70017. * Add touch input support to the input manager.
  70018. * @returns the current input manager
  70019. */
  70020. addTouch(): FreeCameraInputsManager;
  70021. }
  70022. }
  70023. declare module BABYLON {
  70024. /**
  70025. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70026. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  70027. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70028. */
  70029. export class FreeCamera extends TargetCamera {
  70030. /**
  70031. * Define the collision ellipsoid of the camera.
  70032. * This is helpful to simulate a camera body like the player body around the camera
  70033. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  70034. */
  70035. ellipsoid: Vector3;
  70036. /**
  70037. * Define an offset for the position of the ellipsoid around the camera.
  70038. * This can be helpful to determine the center of the body near the gravity center of the body
  70039. * instead of its head.
  70040. */
  70041. ellipsoidOffset: Vector3;
  70042. /**
  70043. * Enable or disable collisions of the camera with the rest of the scene objects.
  70044. */
  70045. checkCollisions: boolean;
  70046. /**
  70047. * Enable or disable gravity on the camera.
  70048. */
  70049. applyGravity: boolean;
  70050. /**
  70051. * Define the input manager associated to the camera.
  70052. */
  70053. inputs: FreeCameraInputsManager;
  70054. /**
  70055. * Gets the input sensibility for a mouse input. (default is 2000.0)
  70056. * Higher values reduce sensitivity.
  70057. */
  70058. /**
  70059. * Sets the input sensibility for a mouse input. (default is 2000.0)
  70060. * Higher values reduce sensitivity.
  70061. */
  70062. angularSensibility: number;
  70063. /**
  70064. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70065. */
  70066. keysUp: number[];
  70067. /**
  70068. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70069. */
  70070. keysDown: number[];
  70071. /**
  70072. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70073. */
  70074. keysLeft: number[];
  70075. /**
  70076. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70077. */
  70078. keysRight: number[];
  70079. /**
  70080. * Event raised when the camera collide with a mesh in the scene.
  70081. */
  70082. onCollide: (collidedMesh: AbstractMesh) => void;
  70083. private _collider;
  70084. private _needMoveForGravity;
  70085. private _oldPosition;
  70086. private _diffPosition;
  70087. private _newPosition;
  70088. /** @hidden */
  70089. _localDirection: Vector3;
  70090. /** @hidden */
  70091. _transformedDirection: Vector3;
  70092. /**
  70093. * Instantiates a Free Camera.
  70094. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70095. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  70096. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70097. * @param name Define the name of the camera in the scene
  70098. * @param position Define the start position of the camera in the scene
  70099. * @param scene Define the scene the camera belongs to
  70100. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70101. */
  70102. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70103. /**
  70104. * Attached controls to the current camera.
  70105. * @param element Defines the element the controls should be listened from
  70106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70107. */
  70108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70109. /**
  70110. * Detach the current controls from the camera.
  70111. * The camera will stop reacting to inputs.
  70112. * @param element Defines the element to stop listening the inputs from
  70113. */
  70114. detachControl(element: HTMLElement): void;
  70115. private _collisionMask;
  70116. /**
  70117. * Define a collision mask to limit the list of object the camera can collide with
  70118. */
  70119. collisionMask: number;
  70120. /** @hidden */
  70121. _collideWithWorld(displacement: Vector3): void;
  70122. private _onCollisionPositionChange;
  70123. /** @hidden */
  70124. _checkInputs(): void;
  70125. /** @hidden */
  70126. _decideIfNeedsToMove(): boolean;
  70127. /** @hidden */
  70128. _updatePosition(): void;
  70129. /**
  70130. * Destroy the camera and release the current resources hold by it.
  70131. */
  70132. dispose(): void;
  70133. /**
  70134. * Gets the current object class name.
  70135. * @return the class name
  70136. */
  70137. getClassName(): string;
  70138. }
  70139. }
  70140. declare module BABYLON {
  70141. /**
  70142. * Represents a gamepad control stick position
  70143. */
  70144. export class StickValues {
  70145. /**
  70146. * The x component of the control stick
  70147. */
  70148. x: number;
  70149. /**
  70150. * The y component of the control stick
  70151. */
  70152. y: number;
  70153. /**
  70154. * Initializes the gamepad x and y control stick values
  70155. * @param x The x component of the gamepad control stick value
  70156. * @param y The y component of the gamepad control stick value
  70157. */
  70158. constructor(
  70159. /**
  70160. * The x component of the control stick
  70161. */
  70162. x: number,
  70163. /**
  70164. * The y component of the control stick
  70165. */
  70166. y: number);
  70167. }
  70168. /**
  70169. * An interface which manages callbacks for gamepad button changes
  70170. */
  70171. export interface GamepadButtonChanges {
  70172. /**
  70173. * Called when a gamepad has been changed
  70174. */
  70175. changed: boolean;
  70176. /**
  70177. * Called when a gamepad press event has been triggered
  70178. */
  70179. pressChanged: boolean;
  70180. /**
  70181. * Called when a touch event has been triggered
  70182. */
  70183. touchChanged: boolean;
  70184. /**
  70185. * Called when a value has changed
  70186. */
  70187. valueChanged: boolean;
  70188. }
  70189. /**
  70190. * Represents a gamepad
  70191. */
  70192. export class Gamepad {
  70193. /**
  70194. * The id of the gamepad
  70195. */
  70196. id: string;
  70197. /**
  70198. * The index of the gamepad
  70199. */
  70200. index: number;
  70201. /**
  70202. * The browser gamepad
  70203. */
  70204. browserGamepad: any;
  70205. /**
  70206. * Specifies what type of gamepad this represents
  70207. */
  70208. type: number;
  70209. private _leftStick;
  70210. private _rightStick;
  70211. /** @hidden */
  70212. _isConnected: boolean;
  70213. private _leftStickAxisX;
  70214. private _leftStickAxisY;
  70215. private _rightStickAxisX;
  70216. private _rightStickAxisY;
  70217. /**
  70218. * Triggered when the left control stick has been changed
  70219. */
  70220. private _onleftstickchanged;
  70221. /**
  70222. * Triggered when the right control stick has been changed
  70223. */
  70224. private _onrightstickchanged;
  70225. /**
  70226. * Represents a gamepad controller
  70227. */
  70228. static GAMEPAD: number;
  70229. /**
  70230. * Represents a generic controller
  70231. */
  70232. static GENERIC: number;
  70233. /**
  70234. * Represents an XBox controller
  70235. */
  70236. static XBOX: number;
  70237. /**
  70238. * Represents a pose-enabled controller
  70239. */
  70240. static POSE_ENABLED: number;
  70241. /**
  70242. * Specifies whether the left control stick should be Y-inverted
  70243. */
  70244. protected _invertLeftStickY: boolean;
  70245. /**
  70246. * Specifies if the gamepad has been connected
  70247. */
  70248. readonly isConnected: boolean;
  70249. /**
  70250. * Initializes the gamepad
  70251. * @param id The id of the gamepad
  70252. * @param index The index of the gamepad
  70253. * @param browserGamepad The browser gamepad
  70254. * @param leftStickX The x component of the left joystick
  70255. * @param leftStickY The y component of the left joystick
  70256. * @param rightStickX The x component of the right joystick
  70257. * @param rightStickY The y component of the right joystick
  70258. */
  70259. constructor(
  70260. /**
  70261. * The id of the gamepad
  70262. */
  70263. id: string,
  70264. /**
  70265. * The index of the gamepad
  70266. */
  70267. index: number,
  70268. /**
  70269. * The browser gamepad
  70270. */
  70271. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  70272. /**
  70273. * Callback triggered when the left joystick has changed
  70274. * @param callback
  70275. */
  70276. onleftstickchanged(callback: (values: StickValues) => void): void;
  70277. /**
  70278. * Callback triggered when the right joystick has changed
  70279. * @param callback
  70280. */
  70281. onrightstickchanged(callback: (values: StickValues) => void): void;
  70282. /**
  70283. * Gets the left joystick
  70284. */
  70285. /**
  70286. * Sets the left joystick values
  70287. */
  70288. leftStick: StickValues;
  70289. /**
  70290. * Gets the right joystick
  70291. */
  70292. /**
  70293. * Sets the right joystick value
  70294. */
  70295. rightStick: StickValues;
  70296. /**
  70297. * Updates the gamepad joystick positions
  70298. */
  70299. update(): void;
  70300. /**
  70301. * Disposes the gamepad
  70302. */
  70303. dispose(): void;
  70304. }
  70305. /**
  70306. * Represents a generic gamepad
  70307. */
  70308. export class GenericPad extends Gamepad {
  70309. private _buttons;
  70310. private _onbuttondown;
  70311. private _onbuttonup;
  70312. /**
  70313. * Observable triggered when a button has been pressed
  70314. */
  70315. onButtonDownObservable: Observable<number>;
  70316. /**
  70317. * Observable triggered when a button has been released
  70318. */
  70319. onButtonUpObservable: Observable<number>;
  70320. /**
  70321. * Callback triggered when a button has been pressed
  70322. * @param callback Called when a button has been pressed
  70323. */
  70324. onbuttondown(callback: (buttonPressed: number) => void): void;
  70325. /**
  70326. * Callback triggered when a button has been released
  70327. * @param callback Called when a button has been released
  70328. */
  70329. onbuttonup(callback: (buttonReleased: number) => void): void;
  70330. /**
  70331. * Initializes the generic gamepad
  70332. * @param id The id of the generic gamepad
  70333. * @param index The index of the generic gamepad
  70334. * @param browserGamepad The browser gamepad
  70335. */
  70336. constructor(id: string, index: number, browserGamepad: any);
  70337. private _setButtonValue;
  70338. /**
  70339. * Updates the generic gamepad
  70340. */
  70341. update(): void;
  70342. /**
  70343. * Disposes the generic gamepad
  70344. */
  70345. dispose(): void;
  70346. }
  70347. }
  70348. declare module BABYLON {
  70349. /**
  70350. * Defines the types of pose enabled controllers that are supported
  70351. */
  70352. export enum PoseEnabledControllerType {
  70353. /**
  70354. * HTC Vive
  70355. */
  70356. VIVE = 0,
  70357. /**
  70358. * Oculus Rift
  70359. */
  70360. OCULUS = 1,
  70361. /**
  70362. * Windows mixed reality
  70363. */
  70364. WINDOWS = 2,
  70365. /**
  70366. * Samsung gear VR
  70367. */
  70368. GEAR_VR = 3,
  70369. /**
  70370. * Google Daydream
  70371. */
  70372. DAYDREAM = 4,
  70373. /**
  70374. * Generic
  70375. */
  70376. GENERIC = 5
  70377. }
  70378. /**
  70379. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70380. */
  70381. export interface MutableGamepadButton {
  70382. /**
  70383. * Value of the button/trigger
  70384. */
  70385. value: number;
  70386. /**
  70387. * If the button/trigger is currently touched
  70388. */
  70389. touched: boolean;
  70390. /**
  70391. * If the button/trigger is currently pressed
  70392. */
  70393. pressed: boolean;
  70394. }
  70395. /**
  70396. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70397. * @hidden
  70398. */
  70399. export interface ExtendedGamepadButton extends GamepadButton {
  70400. /**
  70401. * If the button/trigger is currently pressed
  70402. */
  70403. readonly pressed: boolean;
  70404. /**
  70405. * If the button/trigger is currently touched
  70406. */
  70407. readonly touched: boolean;
  70408. /**
  70409. * Value of the button/trigger
  70410. */
  70411. readonly value: number;
  70412. }
  70413. /** @hidden */
  70414. export interface _GamePadFactory {
  70415. /**
  70416. * Returns wether or not the current gamepad can be created for this type of controller.
  70417. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70418. * @returns true if it can be created, otherwise false
  70419. */
  70420. canCreate(gamepadInfo: any): boolean;
  70421. /**
  70422. * Creates a new instance of the Gamepad.
  70423. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70424. * @returns the new gamepad instance
  70425. */
  70426. create(gamepadInfo: any): Gamepad;
  70427. }
  70428. /**
  70429. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70430. */
  70431. export class PoseEnabledControllerHelper {
  70432. /** @hidden */
  70433. static _ControllerFactories: _GamePadFactory[];
  70434. /** @hidden */
  70435. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  70436. /**
  70437. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70438. * @param vrGamepad the gamepad to initialized
  70439. * @returns a vr controller of the type the gamepad identified as
  70440. */
  70441. static InitiateController(vrGamepad: any): Gamepad;
  70442. }
  70443. /**
  70444. * Defines the PoseEnabledController object that contains state of a vr capable controller
  70445. */
  70446. export class PoseEnabledController extends Gamepad implements PoseControlled {
  70447. private _deviceRoomPosition;
  70448. private _deviceRoomRotationQuaternion;
  70449. /**
  70450. * The device position in babylon space
  70451. */
  70452. devicePosition: Vector3;
  70453. /**
  70454. * The device rotation in babylon space
  70455. */
  70456. deviceRotationQuaternion: Quaternion;
  70457. /**
  70458. * The scale factor of the device in babylon space
  70459. */
  70460. deviceScaleFactor: number;
  70461. /**
  70462. * (Likely devicePosition should be used instead) The device position in its room space
  70463. */
  70464. position: Vector3;
  70465. /**
  70466. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  70467. */
  70468. rotationQuaternion: Quaternion;
  70469. /**
  70470. * The type of controller (Eg. Windows mixed reality)
  70471. */
  70472. controllerType: PoseEnabledControllerType;
  70473. protected _calculatedPosition: Vector3;
  70474. private _calculatedRotation;
  70475. /**
  70476. * The raw pose from the device
  70477. */
  70478. rawPose: DevicePose;
  70479. private _trackPosition;
  70480. private _maxRotationDistFromHeadset;
  70481. private _draggedRoomRotation;
  70482. /**
  70483. * @hidden
  70484. */
  70485. _disableTrackPosition(fixedPosition: Vector3): void;
  70486. /**
  70487. * Internal, the mesh attached to the controller
  70488. * @hidden
  70489. */
  70490. _mesh: Nullable<AbstractMesh>;
  70491. private _poseControlledCamera;
  70492. private _leftHandSystemQuaternion;
  70493. /**
  70494. * Internal, matrix used to convert room space to babylon space
  70495. * @hidden
  70496. */
  70497. _deviceToWorld: Matrix;
  70498. /**
  70499. * Node to be used when casting a ray from the controller
  70500. * @hidden
  70501. */
  70502. _pointingPoseNode: Nullable<TransformNode>;
  70503. /**
  70504. * Name of the child mesh that can be used to cast a ray from the controller
  70505. */
  70506. static readonly POINTING_POSE: string;
  70507. /**
  70508. * Creates a new PoseEnabledController from a gamepad
  70509. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  70510. */
  70511. constructor(browserGamepad: any);
  70512. private _workingMatrix;
  70513. /**
  70514. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  70515. */
  70516. update(): void;
  70517. /**
  70518. * Updates only the pose device and mesh without doing any button event checking
  70519. */
  70520. protected _updatePoseAndMesh(): void;
  70521. /**
  70522. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  70523. * @param poseData raw pose fromthe device
  70524. */
  70525. updateFromDevice(poseData: DevicePose): void;
  70526. /**
  70527. * @hidden
  70528. */
  70529. _meshAttachedObservable: Observable<AbstractMesh>;
  70530. /**
  70531. * Attaches a mesh to the controller
  70532. * @param mesh the mesh to be attached
  70533. */
  70534. attachToMesh(mesh: AbstractMesh): void;
  70535. /**
  70536. * Attaches the controllers mesh to a camera
  70537. * @param camera the camera the mesh should be attached to
  70538. */
  70539. attachToPoseControlledCamera(camera: TargetCamera): void;
  70540. /**
  70541. * Disposes of the controller
  70542. */
  70543. dispose(): void;
  70544. /**
  70545. * The mesh that is attached to the controller
  70546. */
  70547. readonly mesh: Nullable<AbstractMesh>;
  70548. /**
  70549. * Gets the ray of the controller in the direction the controller is pointing
  70550. * @param length the length the resulting ray should be
  70551. * @returns a ray in the direction the controller is pointing
  70552. */
  70553. getForwardRay(length?: number): Ray;
  70554. }
  70555. }
  70556. declare module BABYLON {
  70557. /**
  70558. * Defines the WebVRController object that represents controllers tracked in 3D space
  70559. */
  70560. export abstract class WebVRController extends PoseEnabledController {
  70561. /**
  70562. * Internal, the default controller model for the controller
  70563. */
  70564. protected _defaultModel: AbstractMesh;
  70565. /**
  70566. * Fired when the trigger state has changed
  70567. */
  70568. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70569. /**
  70570. * Fired when the main button state has changed
  70571. */
  70572. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70573. /**
  70574. * Fired when the secondary button state has changed
  70575. */
  70576. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70577. /**
  70578. * Fired when the pad state has changed
  70579. */
  70580. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70581. /**
  70582. * Fired when controllers stick values have changed
  70583. */
  70584. onPadValuesChangedObservable: Observable<StickValues>;
  70585. /**
  70586. * Array of button availible on the controller
  70587. */
  70588. protected _buttons: Array<MutableGamepadButton>;
  70589. private _onButtonStateChange;
  70590. /**
  70591. * Fired when a controller button's state has changed
  70592. * @param callback the callback containing the button that was modified
  70593. */
  70594. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70595. /**
  70596. * X and Y axis corrisponding to the controllers joystick
  70597. */
  70598. pad: StickValues;
  70599. /**
  70600. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70601. */
  70602. hand: string;
  70603. /**
  70604. * The default controller model for the controller
  70605. */
  70606. readonly defaultModel: AbstractMesh;
  70607. /**
  70608. * Creates a new WebVRController from a gamepad
  70609. * @param vrGamepad the gamepad that the WebVRController should be created from
  70610. */
  70611. constructor(vrGamepad: any);
  70612. /**
  70613. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70614. */
  70615. update(): void;
  70616. /**
  70617. * Function to be called when a button is modified
  70618. */
  70619. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70620. /**
  70621. * Loads a mesh and attaches it to the controller
  70622. * @param scene the scene the mesh should be added to
  70623. * @param meshLoaded callback for when the mesh has been loaded
  70624. */
  70625. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70626. private _setButtonValue;
  70627. private _changes;
  70628. private _checkChanges;
  70629. /**
  70630. * Disposes of th webVRCOntroller
  70631. */
  70632. dispose(): void;
  70633. }
  70634. }
  70635. declare module BABYLON {
  70636. /**
  70637. * The HemisphericLight simulates the ambient environment light,
  70638. * so the passed direction is the light reflection direction, not the incoming direction.
  70639. */
  70640. export class HemisphericLight extends Light {
  70641. /**
  70642. * The groundColor is the light in the opposite direction to the one specified during creation.
  70643. * 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.
  70644. */
  70645. groundColor: Color3;
  70646. /**
  70647. * The light reflection direction, not the incoming direction.
  70648. */
  70649. direction: Vector3;
  70650. /**
  70651. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70652. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70653. * The HemisphericLight can't cast shadows.
  70654. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70655. * @param name The friendly name of the light
  70656. * @param direction The direction of the light reflection
  70657. * @param scene The scene the light belongs to
  70658. */
  70659. constructor(name: string, direction: Vector3, scene: Scene);
  70660. protected _buildUniformLayout(): void;
  70661. /**
  70662. * Returns the string "HemisphericLight".
  70663. * @return The class name
  70664. */
  70665. getClassName(): string;
  70666. /**
  70667. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70668. * Returns the updated direction.
  70669. * @param target The target the direction should point to
  70670. * @return The computed direction
  70671. */
  70672. setDirectionToTarget(target: Vector3): Vector3;
  70673. /**
  70674. * Returns the shadow generator associated to the light.
  70675. * @returns Always null for hemispheric lights because it does not support shadows.
  70676. */
  70677. getShadowGenerator(): Nullable<IShadowGenerator>;
  70678. /**
  70679. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70680. * @param effect The effect to update
  70681. * @param lightIndex The index of the light in the effect to update
  70682. * @returns The hemispheric light
  70683. */
  70684. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70685. /**
  70686. * Computes the world matrix of the node
  70687. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70688. * @param useWasUpdatedFlag defines a reserved property
  70689. * @returns the world matrix
  70690. */
  70691. computeWorldMatrix(): Matrix;
  70692. /**
  70693. * Returns the integer 3.
  70694. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70695. */
  70696. getTypeID(): number;
  70697. /**
  70698. * Prepares the list of defines specific to the light type.
  70699. * @param defines the list of defines
  70700. * @param lightIndex defines the index of the light for the effect
  70701. */
  70702. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70703. }
  70704. }
  70705. declare module BABYLON {
  70706. /**
  70707. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70708. * IMPORTANT!! The data is right-hand data.
  70709. * @export
  70710. * @interface DevicePose
  70711. */
  70712. export interface DevicePose {
  70713. /**
  70714. * The position of the device, values in array are [x,y,z].
  70715. */
  70716. readonly position: Nullable<Float32Array>;
  70717. /**
  70718. * The linearVelocity of the device, values in array are [x,y,z].
  70719. */
  70720. readonly linearVelocity: Nullable<Float32Array>;
  70721. /**
  70722. * The linearAcceleration of the device, values in array are [x,y,z].
  70723. */
  70724. readonly linearAcceleration: Nullable<Float32Array>;
  70725. /**
  70726. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70727. */
  70728. readonly orientation: Nullable<Float32Array>;
  70729. /**
  70730. * The angularVelocity of the device, values in array are [x,y,z].
  70731. */
  70732. readonly angularVelocity: Nullable<Float32Array>;
  70733. /**
  70734. * The angularAcceleration of the device, values in array are [x,y,z].
  70735. */
  70736. readonly angularAcceleration: Nullable<Float32Array>;
  70737. }
  70738. /**
  70739. * Interface representing a pose controlled object in Babylon.
  70740. * A pose controlled object has both regular pose values as well as pose values
  70741. * from an external device such as a VR head mounted display
  70742. */
  70743. export interface PoseControlled {
  70744. /**
  70745. * The position of the object in babylon space.
  70746. */
  70747. position: Vector3;
  70748. /**
  70749. * The rotation quaternion of the object in babylon space.
  70750. */
  70751. rotationQuaternion: Quaternion;
  70752. /**
  70753. * The position of the device in babylon space.
  70754. */
  70755. devicePosition?: Vector3;
  70756. /**
  70757. * The rotation quaternion of the device in babylon space.
  70758. */
  70759. deviceRotationQuaternion: Quaternion;
  70760. /**
  70761. * The raw pose coming from the device.
  70762. */
  70763. rawPose: Nullable<DevicePose>;
  70764. /**
  70765. * The scale of the device to be used when translating from device space to babylon space.
  70766. */
  70767. deviceScaleFactor: number;
  70768. /**
  70769. * Updates the poseControlled values based on the input device pose.
  70770. * @param poseData the pose data to update the object with
  70771. */
  70772. updateFromDevice(poseData: DevicePose): void;
  70773. }
  70774. /**
  70775. * Set of options to customize the webVRCamera
  70776. */
  70777. export interface WebVROptions {
  70778. /**
  70779. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70780. */
  70781. trackPosition?: boolean;
  70782. /**
  70783. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70784. */
  70785. positionScale?: number;
  70786. /**
  70787. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70788. */
  70789. displayName?: string;
  70790. /**
  70791. * Should the native controller meshes be initialized. (default: true)
  70792. */
  70793. controllerMeshes?: boolean;
  70794. /**
  70795. * Creating a default HemiLight only on controllers. (default: true)
  70796. */
  70797. defaultLightingOnControllers?: boolean;
  70798. /**
  70799. * If you don't want to use the default VR button of the helper. (default: false)
  70800. */
  70801. useCustomVRButton?: boolean;
  70802. /**
  70803. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70804. */
  70805. customVRButton?: HTMLButtonElement;
  70806. /**
  70807. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70808. */
  70809. rayLength?: number;
  70810. /**
  70811. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70812. */
  70813. defaultHeight?: number;
  70814. }
  70815. /**
  70816. * This represents a WebVR camera.
  70817. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70818. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70819. */
  70820. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70821. private webVROptions;
  70822. /**
  70823. * @hidden
  70824. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70825. */
  70826. _vrDevice: any;
  70827. /**
  70828. * The rawPose of the vrDevice.
  70829. */
  70830. rawPose: Nullable<DevicePose>;
  70831. private _onVREnabled;
  70832. private _specsVersion;
  70833. private _attached;
  70834. private _frameData;
  70835. protected _descendants: Array<Node>;
  70836. private _deviceRoomPosition;
  70837. /** @hidden */
  70838. _deviceRoomRotationQuaternion: Quaternion;
  70839. private _standingMatrix;
  70840. /**
  70841. * Represents device position in babylon space.
  70842. */
  70843. devicePosition: Vector3;
  70844. /**
  70845. * Represents device rotation in babylon space.
  70846. */
  70847. deviceRotationQuaternion: Quaternion;
  70848. /**
  70849. * The scale of the device to be used when translating from device space to babylon space.
  70850. */
  70851. deviceScaleFactor: number;
  70852. private _deviceToWorld;
  70853. private _worldToDevice;
  70854. /**
  70855. * References to the webVR controllers for the vrDevice.
  70856. */
  70857. controllers: Array<WebVRController>;
  70858. /**
  70859. * Emits an event when a controller is attached.
  70860. */
  70861. onControllersAttachedObservable: Observable<WebVRController[]>;
  70862. /**
  70863. * Emits an event when a controller's mesh has been loaded;
  70864. */
  70865. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70866. /**
  70867. * Emits an event when the HMD's pose has been updated.
  70868. */
  70869. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70870. private _poseSet;
  70871. /**
  70872. * If the rig cameras be used as parent instead of this camera.
  70873. */
  70874. rigParenting: boolean;
  70875. private _lightOnControllers;
  70876. private _defaultHeight?;
  70877. /**
  70878. * Instantiates a WebVRFreeCamera.
  70879. * @param name The name of the WebVRFreeCamera
  70880. * @param position The starting anchor position for the camera
  70881. * @param scene The scene the camera belongs to
  70882. * @param webVROptions a set of customizable options for the webVRCamera
  70883. */
  70884. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70885. /**
  70886. * Gets the device distance from the ground in meters.
  70887. * @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.
  70888. */
  70889. deviceDistanceToRoomGround(): number;
  70890. /**
  70891. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70892. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70893. */
  70894. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70895. /**
  70896. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70897. * @returns A promise with a boolean set to if the standing matrix is supported.
  70898. */
  70899. useStandingMatrixAsync(): Promise<boolean>;
  70900. /**
  70901. * Disposes the camera
  70902. */
  70903. dispose(): void;
  70904. /**
  70905. * Gets a vrController by name.
  70906. * @param name The name of the controller to retreive
  70907. * @returns the controller matching the name specified or null if not found
  70908. */
  70909. getControllerByName(name: string): Nullable<WebVRController>;
  70910. private _leftController;
  70911. /**
  70912. * The controller corrisponding to the users left hand.
  70913. */
  70914. readonly leftController: Nullable<WebVRController>;
  70915. private _rightController;
  70916. /**
  70917. * The controller corrisponding to the users right hand.
  70918. */
  70919. readonly rightController: Nullable<WebVRController>;
  70920. /**
  70921. * Casts a ray forward from the vrCamera's gaze.
  70922. * @param length Length of the ray (default: 100)
  70923. * @returns the ray corrisponding to the gaze
  70924. */
  70925. getForwardRay(length?: number): Ray;
  70926. /**
  70927. * @hidden
  70928. * Updates the camera based on device's frame data
  70929. */
  70930. _checkInputs(): void;
  70931. /**
  70932. * Updates the poseControlled values based on the input device pose.
  70933. * @param poseData Pose coming from the device
  70934. */
  70935. updateFromDevice(poseData: DevicePose): void;
  70936. private _htmlElementAttached;
  70937. private _detachIfAttached;
  70938. /**
  70939. * WebVR's attach control will start broadcasting frames to the device.
  70940. * Note that in certain browsers (chrome for example) this function must be called
  70941. * within a user-interaction callback. Example:
  70942. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70943. *
  70944. * @param element html element to attach the vrDevice to
  70945. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70946. */
  70947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70948. /**
  70949. * Detaches the camera from the html element and disables VR
  70950. *
  70951. * @param element html element to detach from
  70952. */
  70953. detachControl(element: HTMLElement): void;
  70954. /**
  70955. * @returns the name of this class
  70956. */
  70957. getClassName(): string;
  70958. /**
  70959. * Calls resetPose on the vrDisplay
  70960. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70961. */
  70962. resetToCurrentRotation(): void;
  70963. /**
  70964. * @hidden
  70965. * Updates the rig cameras (left and right eye)
  70966. */
  70967. _updateRigCameras(): void;
  70968. private _workingVector;
  70969. private _oneVector;
  70970. private _workingMatrix;
  70971. private updateCacheCalled;
  70972. private _correctPositionIfNotTrackPosition;
  70973. /**
  70974. * @hidden
  70975. * Updates the cached values of the camera
  70976. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70977. */
  70978. _updateCache(ignoreParentClass?: boolean): void;
  70979. /**
  70980. * @hidden
  70981. * Get current device position in babylon world
  70982. */
  70983. _computeDevicePosition(): void;
  70984. /**
  70985. * Updates the current device position and rotation in the babylon world
  70986. */
  70987. update(): void;
  70988. /**
  70989. * @hidden
  70990. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70991. * @returns an identity matrix
  70992. */
  70993. _getViewMatrix(): Matrix;
  70994. private _tmpMatrix;
  70995. /**
  70996. * This function is called by the two RIG cameras.
  70997. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70998. * @hidden
  70999. */
  71000. _getWebVRViewMatrix(): Matrix;
  71001. /** @hidden */
  71002. _getWebVRProjectionMatrix(): Matrix;
  71003. private _onGamepadConnectedObserver;
  71004. private _onGamepadDisconnectedObserver;
  71005. private _updateCacheWhenTrackingDisabledObserver;
  71006. /**
  71007. * Initializes the controllers and their meshes
  71008. */
  71009. initControllers(): void;
  71010. }
  71011. }
  71012. declare module BABYLON {
  71013. /**
  71014. * Size options for a post process
  71015. */
  71016. export type PostProcessOptions = {
  71017. width: number;
  71018. height: number;
  71019. };
  71020. /**
  71021. * PostProcess can be used to apply a shader to a texture after it has been rendered
  71022. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71023. */
  71024. export class PostProcess {
  71025. /** Name of the PostProcess. */
  71026. name: string;
  71027. /**
  71028. * Gets or sets the unique id of the post process
  71029. */
  71030. uniqueId: number;
  71031. /**
  71032. * Width of the texture to apply the post process on
  71033. */
  71034. width: number;
  71035. /**
  71036. * Height of the texture to apply the post process on
  71037. */
  71038. height: number;
  71039. /**
  71040. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  71041. * @hidden
  71042. */
  71043. _outputTexture: Nullable<InternalTexture>;
  71044. /**
  71045. * Sampling mode used by the shader
  71046. * See https://doc.babylonjs.com/classes/3.1/texture
  71047. */
  71048. renderTargetSamplingMode: number;
  71049. /**
  71050. * Clear color to use when screen clearing
  71051. */
  71052. clearColor: Color4;
  71053. /**
  71054. * If the buffer needs to be cleared before applying the post process. (default: true)
  71055. * Should be set to false if shader will overwrite all previous pixels.
  71056. */
  71057. autoClear: boolean;
  71058. /**
  71059. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  71060. */
  71061. alphaMode: number;
  71062. /**
  71063. * Sets the setAlphaBlendConstants of the babylon engine
  71064. */
  71065. alphaConstants: Color4;
  71066. /**
  71067. * Animations to be used for the post processing
  71068. */
  71069. animations: Animation[];
  71070. /**
  71071. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  71072. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  71073. */
  71074. enablePixelPerfectMode: boolean;
  71075. /**
  71076. * Force the postprocess to be applied without taking in account viewport
  71077. */
  71078. forceFullscreenViewport: boolean;
  71079. /**
  71080. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  71081. *
  71082. * | Value | Type | Description |
  71083. * | ----- | ----------------------------------- | ----------- |
  71084. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  71085. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  71086. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  71087. *
  71088. */
  71089. scaleMode: number;
  71090. /**
  71091. * Force textures to be a power of two (default: false)
  71092. */
  71093. alwaysForcePOT: boolean;
  71094. private _samples;
  71095. /**
  71096. * Number of sample textures (default: 1)
  71097. */
  71098. samples: number;
  71099. /**
  71100. * Modify the scale of the post process to be the same as the viewport (default: false)
  71101. */
  71102. adaptScaleToCurrentViewport: boolean;
  71103. private _camera;
  71104. private _scene;
  71105. private _engine;
  71106. private _options;
  71107. private _reusable;
  71108. private _textureType;
  71109. /**
  71110. * Smart array of input and output textures for the post process.
  71111. * @hidden
  71112. */
  71113. _textures: SmartArray<InternalTexture>;
  71114. /**
  71115. * The index in _textures that corresponds to the output texture.
  71116. * @hidden
  71117. */
  71118. _currentRenderTextureInd: number;
  71119. private _effect;
  71120. private _samplers;
  71121. private _fragmentUrl;
  71122. private _vertexUrl;
  71123. private _parameters;
  71124. private _scaleRatio;
  71125. protected _indexParameters: any;
  71126. private _shareOutputWithPostProcess;
  71127. private _texelSize;
  71128. private _forcedOutputTexture;
  71129. /**
  71130. * Returns the fragment url or shader name used in the post process.
  71131. * @returns the fragment url or name in the shader store.
  71132. */
  71133. getEffectName(): string;
  71134. /**
  71135. * An event triggered when the postprocess is activated.
  71136. */
  71137. onActivateObservable: Observable<Camera>;
  71138. private _onActivateObserver;
  71139. /**
  71140. * A function that is added to the onActivateObservable
  71141. */
  71142. onActivate: Nullable<(camera: Camera) => void>;
  71143. /**
  71144. * An event triggered when the postprocess changes its size.
  71145. */
  71146. onSizeChangedObservable: Observable<PostProcess>;
  71147. private _onSizeChangedObserver;
  71148. /**
  71149. * A function that is added to the onSizeChangedObservable
  71150. */
  71151. onSizeChanged: (postProcess: PostProcess) => void;
  71152. /**
  71153. * An event triggered when the postprocess applies its effect.
  71154. */
  71155. onApplyObservable: Observable<Effect>;
  71156. private _onApplyObserver;
  71157. /**
  71158. * A function that is added to the onApplyObservable
  71159. */
  71160. onApply: (effect: Effect) => void;
  71161. /**
  71162. * An event triggered before rendering the postprocess
  71163. */
  71164. onBeforeRenderObservable: Observable<Effect>;
  71165. private _onBeforeRenderObserver;
  71166. /**
  71167. * A function that is added to the onBeforeRenderObservable
  71168. */
  71169. onBeforeRender: (effect: Effect) => void;
  71170. /**
  71171. * An event triggered after rendering the postprocess
  71172. */
  71173. onAfterRenderObservable: Observable<Effect>;
  71174. private _onAfterRenderObserver;
  71175. /**
  71176. * A function that is added to the onAfterRenderObservable
  71177. */
  71178. onAfterRender: (efect: Effect) => void;
  71179. /**
  71180. * 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
  71181. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  71182. */
  71183. inputTexture: InternalTexture;
  71184. /**
  71185. * Gets the camera which post process is applied to.
  71186. * @returns The camera the post process is applied to.
  71187. */
  71188. getCamera(): Camera;
  71189. /**
  71190. * Gets the texel size of the postprocess.
  71191. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  71192. */
  71193. readonly texelSize: Vector2;
  71194. /**
  71195. * Creates a new instance PostProcess
  71196. * @param name The name of the PostProcess.
  71197. * @param fragmentUrl The url of the fragment shader to be used.
  71198. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  71199. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  71200. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71201. * @param camera The camera to apply the render pass to.
  71202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71203. * @param engine The engine which the post process will be applied. (default: current engine)
  71204. * @param reusable If the post process can be reused on the same frame. (default: false)
  71205. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  71206. * @param textureType Type of textures used when performing the post process. (default: 0)
  71207. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  71208. * @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
  71209. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  71210. */
  71211. constructor(
  71212. /** Name of the PostProcess. */
  71213. 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);
  71214. /**
  71215. * Gets a string idenfifying the name of the class
  71216. * @returns "PostProcess" string
  71217. */
  71218. getClassName(): string;
  71219. /**
  71220. * Gets the engine which this post process belongs to.
  71221. * @returns The engine the post process was enabled with.
  71222. */
  71223. getEngine(): Engine;
  71224. /**
  71225. * The effect that is created when initializing the post process.
  71226. * @returns The created effect corrisponding the the postprocess.
  71227. */
  71228. getEffect(): Effect;
  71229. /**
  71230. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  71231. * @param postProcess The post process to share the output with.
  71232. * @returns This post process.
  71233. */
  71234. shareOutputWith(postProcess: PostProcess): PostProcess;
  71235. /**
  71236. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  71237. * This should be called if the post process that shares output with this post process is disabled/disposed.
  71238. */
  71239. useOwnOutput(): void;
  71240. /**
  71241. * Updates the effect with the current post process compile time values and recompiles the shader.
  71242. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71243. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71244. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71245. * @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
  71246. * @param onCompiled Called when the shader has been compiled.
  71247. * @param onError Called if there is an error when compiling a shader.
  71248. */
  71249. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71250. /**
  71251. * The post process is reusable if it can be used multiple times within one frame.
  71252. * @returns If the post process is reusable
  71253. */
  71254. isReusable(): boolean;
  71255. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  71256. markTextureDirty(): void;
  71257. /**
  71258. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  71259. * 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.
  71260. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  71261. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  71262. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  71263. * @returns The target texture that was bound to be written to.
  71264. */
  71265. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  71266. /**
  71267. * If the post process is supported.
  71268. */
  71269. readonly isSupported: boolean;
  71270. /**
  71271. * The aspect ratio of the output texture.
  71272. */
  71273. readonly aspectRatio: number;
  71274. /**
  71275. * Get a value indicating if the post-process is ready to be used
  71276. * @returns true if the post-process is ready (shader is compiled)
  71277. */
  71278. isReady(): boolean;
  71279. /**
  71280. * Binds all textures and uniforms to the shader, this will be run on every pass.
  71281. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  71282. */
  71283. apply(): Nullable<Effect>;
  71284. private _disposeTextures;
  71285. /**
  71286. * Disposes the post process.
  71287. * @param camera The camera to dispose the post process on.
  71288. */
  71289. dispose(camera?: Camera): void;
  71290. }
  71291. }
  71292. declare module BABYLON {
  71293. /**
  71294. * PostProcessManager is used to manage one or more post processes or post process pipelines
  71295. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71296. */
  71297. export class PostProcessManager {
  71298. private _scene;
  71299. private _indexBuffer;
  71300. private _vertexBuffers;
  71301. /**
  71302. * Creates a new instance PostProcess
  71303. * @param scene The scene that the post process is associated with.
  71304. */
  71305. constructor(scene: Scene);
  71306. private _prepareBuffers;
  71307. private _buildIndexBuffer;
  71308. /**
  71309. * Rebuilds the vertex buffers of the manager.
  71310. * @hidden
  71311. */
  71312. _rebuild(): void;
  71313. /**
  71314. * Prepares a frame to be run through a post process.
  71315. * @param sourceTexture The input texture to the post procesess. (default: null)
  71316. * @param postProcesses An array of post processes to be run. (default: null)
  71317. * @returns True if the post processes were able to be run.
  71318. * @hidden
  71319. */
  71320. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  71321. /**
  71322. * Manually render a set of post processes to a texture.
  71323. * @param postProcesses An array of post processes to be run.
  71324. * @param targetTexture The target texture to render to.
  71325. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  71326. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  71327. * @param lodLevel defines which lod of the texture to render to
  71328. */
  71329. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  71330. /**
  71331. * Finalize the result of the output of the postprocesses.
  71332. * @param doNotPresent If true the result will not be displayed to the screen.
  71333. * @param targetTexture The target texture to render to.
  71334. * @param faceIndex The index of the face to bind the target texture to.
  71335. * @param postProcesses The array of post processes to render.
  71336. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  71337. * @hidden
  71338. */
  71339. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71340. /**
  71341. * Disposes of the post process manager.
  71342. */
  71343. dispose(): void;
  71344. }
  71345. }
  71346. declare module BABYLON {
  71347. interface AbstractScene {
  71348. /**
  71349. * The list of layers (background and foreground) of the scene
  71350. */
  71351. layers: Array<Layer>;
  71352. }
  71353. /**
  71354. * Defines the layer scene component responsible to manage any layers
  71355. * in a given scene.
  71356. */
  71357. export class LayerSceneComponent implements ISceneComponent {
  71358. /**
  71359. * The component name helpfull to identify the component in the list of scene components.
  71360. */
  71361. readonly name: string;
  71362. /**
  71363. * The scene the component belongs to.
  71364. */
  71365. scene: Scene;
  71366. private _engine;
  71367. /**
  71368. * Creates a new instance of the component for the given scene
  71369. * @param scene Defines the scene to register the component in
  71370. */
  71371. constructor(scene: Scene);
  71372. /**
  71373. * Registers the component in a given scene
  71374. */
  71375. register(): void;
  71376. /**
  71377. * Rebuilds the elements related to this component in case of
  71378. * context lost for instance.
  71379. */
  71380. rebuild(): void;
  71381. /**
  71382. * Disposes the component and the associated ressources.
  71383. */
  71384. dispose(): void;
  71385. private _draw;
  71386. private _drawCameraPredicate;
  71387. private _drawCameraBackground;
  71388. private _drawCameraForeground;
  71389. private _drawRenderTargetPredicate;
  71390. private _drawRenderTargetBackground;
  71391. private _drawRenderTargetForeground;
  71392. }
  71393. }
  71394. declare module BABYLON {
  71395. /** @hidden */
  71396. export var layerPixelShader: {
  71397. name: string;
  71398. shader: string;
  71399. };
  71400. }
  71401. declare module BABYLON {
  71402. /** @hidden */
  71403. export var layerVertexShader: {
  71404. name: string;
  71405. shader: string;
  71406. };
  71407. }
  71408. declare module BABYLON {
  71409. /**
  71410. * This represents a full screen 2d layer.
  71411. * This can be useful to display a picture in the background of your scene for instance.
  71412. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71413. */
  71414. export class Layer {
  71415. /**
  71416. * Define the name of the layer.
  71417. */
  71418. name: string;
  71419. /**
  71420. * Define the texture the layer should display.
  71421. */
  71422. texture: Nullable<Texture>;
  71423. /**
  71424. * Is the layer in background or foreground.
  71425. */
  71426. isBackground: boolean;
  71427. /**
  71428. * Define the color of the layer (instead of texture).
  71429. */
  71430. color: Color4;
  71431. /**
  71432. * Define the scale of the layer in order to zoom in out of the texture.
  71433. */
  71434. scale: Vector2;
  71435. /**
  71436. * Define an offset for the layer in order to shift the texture.
  71437. */
  71438. offset: Vector2;
  71439. /**
  71440. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  71441. */
  71442. alphaBlendingMode: number;
  71443. /**
  71444. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  71445. * Alpha test will not mix with the background color in case of transparency.
  71446. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  71447. */
  71448. alphaTest: boolean;
  71449. /**
  71450. * Define a mask to restrict the layer to only some of the scene cameras.
  71451. */
  71452. layerMask: number;
  71453. /**
  71454. * Define the list of render target the layer is visible into.
  71455. */
  71456. renderTargetTextures: RenderTargetTexture[];
  71457. /**
  71458. * Define if the layer is only used in renderTarget or if it also
  71459. * renders in the main frame buffer of the canvas.
  71460. */
  71461. renderOnlyInRenderTargetTextures: boolean;
  71462. private _scene;
  71463. private _vertexBuffers;
  71464. private _indexBuffer;
  71465. private _effect;
  71466. private _alphaTestEffect;
  71467. /**
  71468. * An event triggered when the layer is disposed.
  71469. */
  71470. onDisposeObservable: Observable<Layer>;
  71471. private _onDisposeObserver;
  71472. /**
  71473. * Back compatibility with callback before the onDisposeObservable existed.
  71474. * The set callback will be triggered when the layer has been disposed.
  71475. */
  71476. onDispose: () => void;
  71477. /**
  71478. * An event triggered before rendering the scene
  71479. */
  71480. onBeforeRenderObservable: Observable<Layer>;
  71481. private _onBeforeRenderObserver;
  71482. /**
  71483. * Back compatibility with callback before the onBeforeRenderObservable existed.
  71484. * The set callback will be triggered just before rendering the layer.
  71485. */
  71486. onBeforeRender: () => void;
  71487. /**
  71488. * An event triggered after rendering the scene
  71489. */
  71490. onAfterRenderObservable: Observable<Layer>;
  71491. private _onAfterRenderObserver;
  71492. /**
  71493. * Back compatibility with callback before the onAfterRenderObservable existed.
  71494. * The set callback will be triggered just after rendering the layer.
  71495. */
  71496. onAfterRender: () => void;
  71497. /**
  71498. * Instantiates a new layer.
  71499. * This represents a full screen 2d layer.
  71500. * This can be useful to display a picture in the background of your scene for instance.
  71501. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71502. * @param name Define the name of the layer in the scene
  71503. * @param imgUrl Define the url of the texture to display in the layer
  71504. * @param scene Define the scene the layer belongs to
  71505. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  71506. * @param color Defines a color for the layer
  71507. */
  71508. constructor(
  71509. /**
  71510. * Define the name of the layer.
  71511. */
  71512. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  71513. private _createIndexBuffer;
  71514. /** @hidden */
  71515. _rebuild(): void;
  71516. /**
  71517. * Renders the layer in the scene.
  71518. */
  71519. render(): void;
  71520. /**
  71521. * Disposes and releases the associated ressources.
  71522. */
  71523. dispose(): void;
  71524. }
  71525. }
  71526. declare module BABYLON {
  71527. interface AbstractScene {
  71528. /**
  71529. * The list of procedural textures added to the scene
  71530. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71531. */
  71532. proceduralTextures: Array<ProceduralTexture>;
  71533. }
  71534. /**
  71535. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  71536. * in a given scene.
  71537. */
  71538. export class ProceduralTextureSceneComponent implements ISceneComponent {
  71539. /**
  71540. * The component name helpfull to identify the component in the list of scene components.
  71541. */
  71542. readonly name: string;
  71543. /**
  71544. * The scene the component belongs to.
  71545. */
  71546. scene: Scene;
  71547. /**
  71548. * Creates a new instance of the component for the given scene
  71549. * @param scene Defines the scene to register the component in
  71550. */
  71551. constructor(scene: Scene);
  71552. /**
  71553. * Registers the component in a given scene
  71554. */
  71555. register(): void;
  71556. /**
  71557. * Rebuilds the elements related to this component in case of
  71558. * context lost for instance.
  71559. */
  71560. rebuild(): void;
  71561. /**
  71562. * Disposes the component and the associated ressources.
  71563. */
  71564. dispose(): void;
  71565. private _beforeClear;
  71566. }
  71567. }
  71568. declare module BABYLON {
  71569. /** @hidden */
  71570. export var proceduralVertexShader: {
  71571. name: string;
  71572. shader: string;
  71573. };
  71574. }
  71575. declare module BABYLON {
  71576. /**
  71577. * 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.
  71578. * This is the base class of any Procedural texture and contains most of the shareable code.
  71579. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71580. */
  71581. export class ProceduralTexture extends Texture {
  71582. isCube: boolean;
  71583. /**
  71584. * Define if the texture is enabled or not (disabled texture will not render)
  71585. */
  71586. isEnabled: boolean;
  71587. /**
  71588. * Define if the texture must be cleared before rendering (default is true)
  71589. */
  71590. autoClear: boolean;
  71591. /**
  71592. * Callback called when the texture is generated
  71593. */
  71594. onGenerated: () => void;
  71595. /**
  71596. * Event raised when the texture is generated
  71597. */
  71598. onGeneratedObservable: Observable<ProceduralTexture>;
  71599. /** @hidden */
  71600. _generateMipMaps: boolean;
  71601. /** @hidden **/
  71602. _effect: Effect;
  71603. /** @hidden */
  71604. _textures: {
  71605. [key: string]: Texture;
  71606. };
  71607. private _size;
  71608. private _currentRefreshId;
  71609. private _refreshRate;
  71610. private _vertexBuffers;
  71611. private _indexBuffer;
  71612. private _uniforms;
  71613. private _samplers;
  71614. private _fragment;
  71615. private _floats;
  71616. private _ints;
  71617. private _floatsArrays;
  71618. private _colors3;
  71619. private _colors4;
  71620. private _vectors2;
  71621. private _vectors3;
  71622. private _matrices;
  71623. private _fallbackTexture;
  71624. private _fallbackTextureUsed;
  71625. private _engine;
  71626. private _cachedDefines;
  71627. private _contentUpdateId;
  71628. private _contentData;
  71629. /**
  71630. * Instantiates a new procedural texture.
  71631. * 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.
  71632. * This is the base class of any Procedural texture and contains most of the shareable code.
  71633. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71634. * @param name Define the name of the texture
  71635. * @param size Define the size of the texture to create
  71636. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71637. * @param scene Define the scene the texture belongs to
  71638. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71639. * @param generateMipMaps Define if the texture should creates mip maps or not
  71640. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71641. */
  71642. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71643. /**
  71644. * The effect that is created when initializing the post process.
  71645. * @returns The created effect corrisponding the the postprocess.
  71646. */
  71647. getEffect(): Effect;
  71648. /**
  71649. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71650. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71651. */
  71652. getContent(): Nullable<ArrayBufferView>;
  71653. private _createIndexBuffer;
  71654. /** @hidden */
  71655. _rebuild(): void;
  71656. /**
  71657. * Resets the texture in order to recreate its associated resources.
  71658. * This can be called in case of context loss
  71659. */
  71660. reset(): void;
  71661. protected _getDefines(): string;
  71662. /**
  71663. * Is the texture ready to be used ? (rendered at least once)
  71664. * @returns true if ready, otherwise, false.
  71665. */
  71666. isReady(): boolean;
  71667. /**
  71668. * Resets the refresh counter of the texture and start bak from scratch.
  71669. * Could be useful to regenerate the texture if it is setup to render only once.
  71670. */
  71671. resetRefreshCounter(): void;
  71672. /**
  71673. * Set the fragment shader to use in order to render the texture.
  71674. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71675. */
  71676. setFragment(fragment: any): void;
  71677. /**
  71678. * Define the refresh rate of the texture or the rendering frequency.
  71679. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71680. */
  71681. refreshRate: number;
  71682. /** @hidden */
  71683. _shouldRender(): boolean;
  71684. /**
  71685. * Get the size the texture is rendering at.
  71686. * @returns the size (texture is always squared)
  71687. */
  71688. getRenderSize(): number;
  71689. /**
  71690. * Resize the texture to new value.
  71691. * @param size Define the new size the texture should have
  71692. * @param generateMipMaps Define whether the new texture should create mip maps
  71693. */
  71694. resize(size: number, generateMipMaps: boolean): void;
  71695. private _checkUniform;
  71696. /**
  71697. * Set a texture in the shader program used to render.
  71698. * @param name Define the name of the uniform samplers as defined in the shader
  71699. * @param texture Define the texture to bind to this sampler
  71700. * @return the texture itself allowing "fluent" like uniform updates
  71701. */
  71702. setTexture(name: string, texture: Texture): ProceduralTexture;
  71703. /**
  71704. * Set a float in the shader.
  71705. * @param name Define the name of the uniform as defined in the shader
  71706. * @param value Define the value to give to the uniform
  71707. * @return the texture itself allowing "fluent" like uniform updates
  71708. */
  71709. setFloat(name: string, value: number): ProceduralTexture;
  71710. /**
  71711. * Set a int in the shader.
  71712. * @param name Define the name of the uniform as defined in the shader
  71713. * @param value Define the value to give to the uniform
  71714. * @return the texture itself allowing "fluent" like uniform updates
  71715. */
  71716. setInt(name: string, value: number): ProceduralTexture;
  71717. /**
  71718. * Set an array of floats in the shader.
  71719. * @param name Define the name of the uniform as defined in the shader
  71720. * @param value Define the value to give to the uniform
  71721. * @return the texture itself allowing "fluent" like uniform updates
  71722. */
  71723. setFloats(name: string, value: number[]): ProceduralTexture;
  71724. /**
  71725. * Set a vec3 in the shader from a Color3.
  71726. * @param name Define the name of the uniform as defined in the shader
  71727. * @param value Define the value to give to the uniform
  71728. * @return the texture itself allowing "fluent" like uniform updates
  71729. */
  71730. setColor3(name: string, value: Color3): ProceduralTexture;
  71731. /**
  71732. * Set a vec4 in the shader from a Color4.
  71733. * @param name Define the name of the uniform as defined in the shader
  71734. * @param value Define the value to give to the uniform
  71735. * @return the texture itself allowing "fluent" like uniform updates
  71736. */
  71737. setColor4(name: string, value: Color4): ProceduralTexture;
  71738. /**
  71739. * Set a vec2 in the shader from a Vector2.
  71740. * @param name Define the name of the uniform as defined in the shader
  71741. * @param value Define the value to give to the uniform
  71742. * @return the texture itself allowing "fluent" like uniform updates
  71743. */
  71744. setVector2(name: string, value: Vector2): ProceduralTexture;
  71745. /**
  71746. * Set a vec3 in the shader from a Vector3.
  71747. * @param name Define the name of the uniform as defined in the shader
  71748. * @param value Define the value to give to the uniform
  71749. * @return the texture itself allowing "fluent" like uniform updates
  71750. */
  71751. setVector3(name: string, value: Vector3): ProceduralTexture;
  71752. /**
  71753. * Set a mat4 in the shader from a MAtrix.
  71754. * @param name Define the name of the uniform as defined in the shader
  71755. * @param value Define the value to give to the uniform
  71756. * @return the texture itself allowing "fluent" like uniform updates
  71757. */
  71758. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71759. /**
  71760. * Render the texture to its associated render target.
  71761. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71762. */
  71763. render(useCameraPostProcess?: boolean): void;
  71764. /**
  71765. * Clone the texture.
  71766. * @returns the cloned texture
  71767. */
  71768. clone(): ProceduralTexture;
  71769. /**
  71770. * Dispose the texture and release its asoociated resources.
  71771. */
  71772. dispose(): void;
  71773. }
  71774. }
  71775. declare module BABYLON {
  71776. /**
  71777. * This represents the base class for particle system in Babylon.
  71778. * 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.
  71779. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71780. * @example https://doc.babylonjs.com/babylon101/particles
  71781. */
  71782. export class BaseParticleSystem {
  71783. /**
  71784. * Source color is added to the destination color without alpha affecting the result
  71785. */
  71786. static BLENDMODE_ONEONE: number;
  71787. /**
  71788. * Blend current color and particle color using particle’s alpha
  71789. */
  71790. static BLENDMODE_STANDARD: number;
  71791. /**
  71792. * Add current color and particle color multiplied by particle’s alpha
  71793. */
  71794. static BLENDMODE_ADD: number;
  71795. /**
  71796. * Multiply current color with particle color
  71797. */
  71798. static BLENDMODE_MULTIPLY: number;
  71799. /**
  71800. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71801. */
  71802. static BLENDMODE_MULTIPLYADD: number;
  71803. /**
  71804. * List of animations used by the particle system.
  71805. */
  71806. animations: Animation[];
  71807. /**
  71808. * The id of the Particle system.
  71809. */
  71810. id: string;
  71811. /**
  71812. * The friendly name of the Particle system.
  71813. */
  71814. name: string;
  71815. /**
  71816. * The rendering group used by the Particle system to chose when to render.
  71817. */
  71818. renderingGroupId: number;
  71819. /**
  71820. * The emitter represents the Mesh or position we are attaching the particle system to.
  71821. */
  71822. emitter: Nullable<AbstractMesh | Vector3>;
  71823. /**
  71824. * The maximum number of particles to emit per frame
  71825. */
  71826. emitRate: number;
  71827. /**
  71828. * If you want to launch only a few particles at once, that can be done, as well.
  71829. */
  71830. manualEmitCount: number;
  71831. /**
  71832. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71833. */
  71834. updateSpeed: number;
  71835. /**
  71836. * The amount of time the particle system is running (depends of the overall update speed).
  71837. */
  71838. targetStopDuration: number;
  71839. /**
  71840. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71841. */
  71842. disposeOnStop: boolean;
  71843. /**
  71844. * Minimum power of emitting particles.
  71845. */
  71846. minEmitPower: number;
  71847. /**
  71848. * Maximum power of emitting particles.
  71849. */
  71850. maxEmitPower: number;
  71851. /**
  71852. * Minimum life time of emitting particles.
  71853. */
  71854. minLifeTime: number;
  71855. /**
  71856. * Maximum life time of emitting particles.
  71857. */
  71858. maxLifeTime: number;
  71859. /**
  71860. * Minimum Size of emitting particles.
  71861. */
  71862. minSize: number;
  71863. /**
  71864. * Maximum Size of emitting particles.
  71865. */
  71866. maxSize: number;
  71867. /**
  71868. * Minimum scale of emitting particles on X axis.
  71869. */
  71870. minScaleX: number;
  71871. /**
  71872. * Maximum scale of emitting particles on X axis.
  71873. */
  71874. maxScaleX: number;
  71875. /**
  71876. * Minimum scale of emitting particles on Y axis.
  71877. */
  71878. minScaleY: number;
  71879. /**
  71880. * Maximum scale of emitting particles on Y axis.
  71881. */
  71882. maxScaleY: number;
  71883. /**
  71884. * Gets or sets the minimal initial rotation in radians.
  71885. */
  71886. minInitialRotation: number;
  71887. /**
  71888. * Gets or sets the maximal initial rotation in radians.
  71889. */
  71890. maxInitialRotation: number;
  71891. /**
  71892. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71893. */
  71894. minAngularSpeed: number;
  71895. /**
  71896. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71897. */
  71898. maxAngularSpeed: number;
  71899. /**
  71900. * The texture used to render each particle. (this can be a spritesheet)
  71901. */
  71902. particleTexture: Nullable<Texture>;
  71903. /**
  71904. * The layer mask we are rendering the particles through.
  71905. */
  71906. layerMask: number;
  71907. /**
  71908. * This can help using your own shader to render the particle system.
  71909. * The according effect will be created
  71910. */
  71911. customShader: any;
  71912. /**
  71913. * By default particle system starts as soon as they are created. This prevents the
  71914. * automatic start to happen and let you decide when to start emitting particles.
  71915. */
  71916. preventAutoStart: boolean;
  71917. private _noiseTexture;
  71918. /**
  71919. * Gets or sets a texture used to add random noise to particle positions
  71920. */
  71921. noiseTexture: Nullable<ProceduralTexture>;
  71922. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71923. noiseStrength: Vector3;
  71924. /**
  71925. * Callback triggered when the particle animation is ending.
  71926. */
  71927. onAnimationEnd: Nullable<() => void>;
  71928. /**
  71929. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71930. */
  71931. blendMode: number;
  71932. /**
  71933. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71934. * to override the particles.
  71935. */
  71936. forceDepthWrite: boolean;
  71937. /** 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 */
  71938. preWarmCycles: number;
  71939. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71940. preWarmStepOffset: number;
  71941. /**
  71942. * 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)
  71943. */
  71944. spriteCellChangeSpeed: number;
  71945. /**
  71946. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71947. */
  71948. startSpriteCellID: number;
  71949. /**
  71950. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71951. */
  71952. endSpriteCellID: number;
  71953. /**
  71954. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71955. */
  71956. spriteCellWidth: number;
  71957. /**
  71958. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71959. */
  71960. spriteCellHeight: number;
  71961. /**
  71962. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71963. */
  71964. spriteRandomStartCell: boolean;
  71965. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71966. translationPivot: Vector2;
  71967. /** @hidden */
  71968. protected _isAnimationSheetEnabled: boolean;
  71969. /**
  71970. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71971. */
  71972. beginAnimationOnStart: boolean;
  71973. /**
  71974. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71975. */
  71976. beginAnimationFrom: number;
  71977. /**
  71978. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71979. */
  71980. beginAnimationTo: number;
  71981. /**
  71982. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71983. */
  71984. beginAnimationLoop: boolean;
  71985. /**
  71986. * Gets or sets a world offset applied to all particles
  71987. */
  71988. worldOffset: Vector3;
  71989. /**
  71990. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71991. */
  71992. isAnimationSheetEnabled: boolean;
  71993. /**
  71994. * Get hosting scene
  71995. * @returns the scene
  71996. */
  71997. getScene(): Scene;
  71998. /**
  71999. * You can use gravity if you want to give an orientation to your particles.
  72000. */
  72001. gravity: Vector3;
  72002. protected _colorGradients: Nullable<Array<ColorGradient>>;
  72003. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  72004. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  72005. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  72006. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  72007. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  72008. protected _dragGradients: Nullable<Array<FactorGradient>>;
  72009. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  72010. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  72011. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  72012. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  72013. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  72014. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  72015. /**
  72016. * Defines the delay in milliseconds before starting the system (0 by default)
  72017. */
  72018. startDelay: number;
  72019. /**
  72020. * Gets the current list of drag gradients.
  72021. * You must use addDragGradient and removeDragGradient to udpate this list
  72022. * @returns the list of drag gradients
  72023. */
  72024. getDragGradients(): Nullable<Array<FactorGradient>>;
  72025. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72026. limitVelocityDamping: number;
  72027. /**
  72028. * Gets the current list of limit velocity gradients.
  72029. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72030. * @returns the list of limit velocity gradients
  72031. */
  72032. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72033. /**
  72034. * Gets the current list of color gradients.
  72035. * You must use addColorGradient and removeColorGradient to udpate this list
  72036. * @returns the list of color gradients
  72037. */
  72038. getColorGradients(): Nullable<Array<ColorGradient>>;
  72039. /**
  72040. * Gets the current list of size gradients.
  72041. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72042. * @returns the list of size gradients
  72043. */
  72044. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72045. /**
  72046. * Gets the current list of color remap gradients.
  72047. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72048. * @returns the list of color remap gradients
  72049. */
  72050. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72051. /**
  72052. * Gets the current list of alpha remap gradients.
  72053. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72054. * @returns the list of alpha remap gradients
  72055. */
  72056. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72057. /**
  72058. * Gets the current list of life time gradients.
  72059. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72060. * @returns the list of life time gradients
  72061. */
  72062. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72063. /**
  72064. * Gets the current list of angular speed gradients.
  72065. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72066. * @returns the list of angular speed gradients
  72067. */
  72068. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72069. /**
  72070. * Gets the current list of velocity gradients.
  72071. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72072. * @returns the list of velocity gradients
  72073. */
  72074. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72075. /**
  72076. * Gets the current list of start size gradients.
  72077. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72078. * @returns the list of start size gradients
  72079. */
  72080. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72081. /**
  72082. * Gets the current list of emit rate gradients.
  72083. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72084. * @returns the list of emit rate gradients
  72085. */
  72086. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72087. /**
  72088. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72089. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72090. */
  72091. direction1: Vector3;
  72092. /**
  72093. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72094. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72095. */
  72096. direction2: Vector3;
  72097. /**
  72098. * 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.
  72099. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72100. */
  72101. minEmitBox: Vector3;
  72102. /**
  72103. * 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.
  72104. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72105. */
  72106. maxEmitBox: Vector3;
  72107. /**
  72108. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72109. */
  72110. color1: Color4;
  72111. /**
  72112. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72113. */
  72114. color2: Color4;
  72115. /**
  72116. * Color the particle will have at the end of its lifetime
  72117. */
  72118. colorDead: Color4;
  72119. /**
  72120. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  72121. */
  72122. textureMask: Color4;
  72123. /**
  72124. * The particle emitter type defines the emitter used by the particle system.
  72125. * It can be for example box, sphere, or cone...
  72126. */
  72127. particleEmitterType: IParticleEmitterType;
  72128. /** @hidden */
  72129. _isSubEmitter: boolean;
  72130. /**
  72131. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72132. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72133. */
  72134. billboardMode: number;
  72135. protected _isBillboardBased: boolean;
  72136. /**
  72137. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72138. */
  72139. isBillboardBased: boolean;
  72140. /**
  72141. * The scene the particle system belongs to.
  72142. */
  72143. protected _scene: Scene;
  72144. /**
  72145. * Local cache of defines for image processing.
  72146. */
  72147. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  72148. /**
  72149. * Default configuration related to image processing available in the standard Material.
  72150. */
  72151. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  72152. /**
  72153. * Gets the image processing configuration used either in this material.
  72154. */
  72155. /**
  72156. * Sets the Default image processing configuration used either in the this material.
  72157. *
  72158. * If sets to null, the scene one is in use.
  72159. */
  72160. imageProcessingConfiguration: ImageProcessingConfiguration;
  72161. /**
  72162. * Attaches a new image processing configuration to the Standard Material.
  72163. * @param configuration
  72164. */
  72165. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  72166. /** @hidden */
  72167. protected _reset(): void;
  72168. /** @hidden */
  72169. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  72170. /**
  72171. * Instantiates a particle system.
  72172. * 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.
  72173. * @param name The name of the particle system
  72174. */
  72175. constructor(name: string);
  72176. /**
  72177. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72178. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72179. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72180. * @returns the emitter
  72181. */
  72182. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72183. /**
  72184. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72185. * @param radius The radius of the hemisphere to emit from
  72186. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72187. * @returns the emitter
  72188. */
  72189. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  72190. /**
  72191. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72192. * @param radius The radius of the sphere to emit from
  72193. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72194. * @returns the emitter
  72195. */
  72196. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  72197. /**
  72198. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72199. * @param radius The radius of the sphere to emit from
  72200. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72201. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72202. * @returns the emitter
  72203. */
  72204. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  72205. /**
  72206. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72207. * @param radius The radius of the emission cylinder
  72208. * @param height The height of the emission cylinder
  72209. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72210. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72211. * @returns the emitter
  72212. */
  72213. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  72214. /**
  72215. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72216. * @param radius The radius of the cylinder to emit from
  72217. * @param height The height of the emission cylinder
  72218. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72219. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72220. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72221. * @returns the emitter
  72222. */
  72223. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  72224. /**
  72225. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72226. * @param radius The radius of the cone to emit from
  72227. * @param angle The base angle of the cone
  72228. * @returns the emitter
  72229. */
  72230. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  72231. /**
  72232. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72233. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72234. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72235. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72236. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72237. * @returns the emitter
  72238. */
  72239. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72240. }
  72241. }
  72242. declare module BABYLON {
  72243. /**
  72244. * Type of sub emitter
  72245. */
  72246. export enum SubEmitterType {
  72247. /**
  72248. * Attached to the particle over it's lifetime
  72249. */
  72250. ATTACHED = 0,
  72251. /**
  72252. * Created when the particle dies
  72253. */
  72254. END = 1
  72255. }
  72256. /**
  72257. * Sub emitter class used to emit particles from an existing particle
  72258. */
  72259. export class SubEmitter {
  72260. /**
  72261. * the particle system to be used by the sub emitter
  72262. */
  72263. particleSystem: ParticleSystem;
  72264. /**
  72265. * Type of the submitter (Default: END)
  72266. */
  72267. type: SubEmitterType;
  72268. /**
  72269. * 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)
  72270. * Note: This only is supported when using an emitter of type Mesh
  72271. */
  72272. inheritDirection: boolean;
  72273. /**
  72274. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  72275. */
  72276. inheritedVelocityAmount: number;
  72277. /**
  72278. * Creates a sub emitter
  72279. * @param particleSystem the particle system to be used by the sub emitter
  72280. */
  72281. constructor(
  72282. /**
  72283. * the particle system to be used by the sub emitter
  72284. */
  72285. particleSystem: ParticleSystem);
  72286. /**
  72287. * Clones the sub emitter
  72288. * @returns the cloned sub emitter
  72289. */
  72290. clone(): SubEmitter;
  72291. /**
  72292. * Serialize current object to a JSON object
  72293. * @returns the serialized object
  72294. */
  72295. serialize(): any;
  72296. /** @hidden */
  72297. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  72298. /**
  72299. * Creates a new SubEmitter from a serialized JSON version
  72300. * @param serializationObject defines the JSON object to read from
  72301. * @param scene defines the hosting scene
  72302. * @param rootUrl defines the rootUrl for data loading
  72303. * @returns a new SubEmitter
  72304. */
  72305. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  72306. /** Release associated resources */
  72307. dispose(): void;
  72308. }
  72309. }
  72310. declare module BABYLON {
  72311. /** @hidden */
  72312. export var clipPlaneFragmentDeclaration: {
  72313. name: string;
  72314. shader: string;
  72315. };
  72316. }
  72317. declare module BABYLON {
  72318. /** @hidden */
  72319. export var imageProcessingDeclaration: {
  72320. name: string;
  72321. shader: string;
  72322. };
  72323. }
  72324. declare module BABYLON {
  72325. /** @hidden */
  72326. export var imageProcessingFunctions: {
  72327. name: string;
  72328. shader: string;
  72329. };
  72330. }
  72331. declare module BABYLON {
  72332. /** @hidden */
  72333. export var clipPlaneFragment: {
  72334. name: string;
  72335. shader: string;
  72336. };
  72337. }
  72338. declare module BABYLON {
  72339. /** @hidden */
  72340. export var particlesPixelShader: {
  72341. name: string;
  72342. shader: string;
  72343. };
  72344. }
  72345. declare module BABYLON {
  72346. /** @hidden */
  72347. export var clipPlaneVertexDeclaration: {
  72348. name: string;
  72349. shader: string;
  72350. };
  72351. }
  72352. declare module BABYLON {
  72353. /** @hidden */
  72354. export var clipPlaneVertex: {
  72355. name: string;
  72356. shader: string;
  72357. };
  72358. }
  72359. declare module BABYLON {
  72360. /** @hidden */
  72361. export var particlesVertexShader: {
  72362. name: string;
  72363. shader: string;
  72364. };
  72365. }
  72366. declare module BABYLON {
  72367. /**
  72368. * This represents a particle system in Babylon.
  72369. * 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.
  72370. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72371. * @example https://doc.babylonjs.com/babylon101/particles
  72372. */
  72373. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72374. /**
  72375. * Billboard mode will only apply to Y axis
  72376. */
  72377. static readonly BILLBOARDMODE_Y: number;
  72378. /**
  72379. * Billboard mode will apply to all axes
  72380. */
  72381. static readonly BILLBOARDMODE_ALL: number;
  72382. /**
  72383. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72384. */
  72385. static readonly BILLBOARDMODE_STRETCHED: number;
  72386. /**
  72387. * This function can be defined to provide custom update for active particles.
  72388. * This function will be called instead of regular update (age, position, color, etc.).
  72389. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72390. */
  72391. updateFunction: (particles: Particle[]) => void;
  72392. private _emitterWorldMatrix;
  72393. /**
  72394. * This function can be defined to specify initial direction for every new particle.
  72395. * It by default use the emitterType defined function
  72396. */
  72397. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72398. /**
  72399. * This function can be defined to specify initial position for every new particle.
  72400. * It by default use the emitterType defined function
  72401. */
  72402. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72403. /**
  72404. * @hidden
  72405. */
  72406. _inheritedVelocityOffset: Vector3;
  72407. /**
  72408. * An event triggered when the system is disposed
  72409. */
  72410. onDisposeObservable: Observable<ParticleSystem>;
  72411. private _onDisposeObserver;
  72412. /**
  72413. * Sets a callback that will be triggered when the system is disposed
  72414. */
  72415. onDispose: () => void;
  72416. private _particles;
  72417. private _epsilon;
  72418. private _capacity;
  72419. private _stockParticles;
  72420. private _newPartsExcess;
  72421. private _vertexData;
  72422. private _vertexBuffer;
  72423. private _vertexBuffers;
  72424. private _spriteBuffer;
  72425. private _indexBuffer;
  72426. private _effect;
  72427. private _customEffect;
  72428. private _cachedDefines;
  72429. private _scaledColorStep;
  72430. private _colorDiff;
  72431. private _scaledDirection;
  72432. private _scaledGravity;
  72433. private _currentRenderId;
  72434. private _alive;
  72435. private _useInstancing;
  72436. private _started;
  72437. private _stopped;
  72438. private _actualFrame;
  72439. private _scaledUpdateSpeed;
  72440. private _vertexBufferSize;
  72441. /** @hidden */
  72442. _currentEmitRateGradient: Nullable<FactorGradient>;
  72443. /** @hidden */
  72444. _currentEmitRate1: number;
  72445. /** @hidden */
  72446. _currentEmitRate2: number;
  72447. /** @hidden */
  72448. _currentStartSizeGradient: Nullable<FactorGradient>;
  72449. /** @hidden */
  72450. _currentStartSize1: number;
  72451. /** @hidden */
  72452. _currentStartSize2: number;
  72453. private readonly _rawTextureWidth;
  72454. private _rampGradientsTexture;
  72455. private _useRampGradients;
  72456. /** Gets or sets a boolean indicating that ramp gradients must be used
  72457. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72458. */
  72459. useRampGradients: boolean;
  72460. /**
  72461. * 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.
  72462. * 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: [])
  72463. */
  72464. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  72465. private _subEmitters;
  72466. /**
  72467. * @hidden
  72468. * If the particle systems emitter should be disposed when the particle system is disposed
  72469. */
  72470. _disposeEmitterOnDispose: boolean;
  72471. /**
  72472. * The current active Sub-systems, this property is used by the root particle system only.
  72473. */
  72474. activeSubSystems: Array<ParticleSystem>;
  72475. private _rootParticleSystem;
  72476. /**
  72477. * Gets the current list of active particles
  72478. */
  72479. readonly particles: Particle[];
  72480. /**
  72481. * Returns the string "ParticleSystem"
  72482. * @returns a string containing the class name
  72483. */
  72484. getClassName(): string;
  72485. /**
  72486. * Instantiates a particle system.
  72487. * 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.
  72488. * @param name The name of the particle system
  72489. * @param capacity The max number of particles alive at the same time
  72490. * @param scene The scene the particle system belongs to
  72491. * @param customEffect a custom effect used to change the way particles are rendered by default
  72492. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72493. * @param epsilon Offset used to render the particles
  72494. */
  72495. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  72496. private _addFactorGradient;
  72497. private _removeFactorGradient;
  72498. /**
  72499. * Adds a new life time gradient
  72500. * @param gradient defines the gradient to use (between 0 and 1)
  72501. * @param factor defines the life time factor to affect to the specified gradient
  72502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72503. * @returns the current particle system
  72504. */
  72505. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72506. /**
  72507. * Remove a specific life time gradient
  72508. * @param gradient defines the gradient to remove
  72509. * @returns the current particle system
  72510. */
  72511. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72512. /**
  72513. * Adds a new size gradient
  72514. * @param gradient defines the gradient to use (between 0 and 1)
  72515. * @param factor defines the size factor to affect to the specified gradient
  72516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72517. * @returns the current particle system
  72518. */
  72519. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72520. /**
  72521. * Remove a specific size gradient
  72522. * @param gradient defines the gradient to remove
  72523. * @returns the current particle system
  72524. */
  72525. removeSizeGradient(gradient: number): IParticleSystem;
  72526. /**
  72527. * Adds a new color remap gradient
  72528. * @param gradient defines the gradient to use (between 0 and 1)
  72529. * @param min defines the color remap minimal range
  72530. * @param max defines the color remap maximal range
  72531. * @returns the current particle system
  72532. */
  72533. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72534. /**
  72535. * Remove a specific color remap gradient
  72536. * @param gradient defines the gradient to remove
  72537. * @returns the current particle system
  72538. */
  72539. removeColorRemapGradient(gradient: number): IParticleSystem;
  72540. /**
  72541. * Adds a new alpha remap gradient
  72542. * @param gradient defines the gradient to use (between 0 and 1)
  72543. * @param min defines the alpha remap minimal range
  72544. * @param max defines the alpha remap maximal range
  72545. * @returns the current particle system
  72546. */
  72547. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72548. /**
  72549. * Remove a specific alpha remap gradient
  72550. * @param gradient defines the gradient to remove
  72551. * @returns the current particle system
  72552. */
  72553. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  72554. /**
  72555. * Adds a new angular speed gradient
  72556. * @param gradient defines the gradient to use (between 0 and 1)
  72557. * @param factor defines the angular speed to affect to the specified gradient
  72558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72559. * @returns the current particle system
  72560. */
  72561. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72562. /**
  72563. * Remove a specific angular speed gradient
  72564. * @param gradient defines the gradient to remove
  72565. * @returns the current particle system
  72566. */
  72567. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72568. /**
  72569. * Adds a new velocity gradient
  72570. * @param gradient defines the gradient to use (between 0 and 1)
  72571. * @param factor defines the velocity to affect to the specified gradient
  72572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72573. * @returns the current particle system
  72574. */
  72575. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72576. /**
  72577. * Remove a specific velocity gradient
  72578. * @param gradient defines the gradient to remove
  72579. * @returns the current particle system
  72580. */
  72581. removeVelocityGradient(gradient: number): IParticleSystem;
  72582. /**
  72583. * Adds a new limit velocity gradient
  72584. * @param gradient defines the gradient to use (between 0 and 1)
  72585. * @param factor defines the limit velocity value to affect to the specified gradient
  72586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72587. * @returns the current particle system
  72588. */
  72589. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72590. /**
  72591. * Remove a specific limit velocity gradient
  72592. * @param gradient defines the gradient to remove
  72593. * @returns the current particle system
  72594. */
  72595. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72596. /**
  72597. * Adds a new drag gradient
  72598. * @param gradient defines the gradient to use (between 0 and 1)
  72599. * @param factor defines the drag value to affect to the specified gradient
  72600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72601. * @returns the current particle system
  72602. */
  72603. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72604. /**
  72605. * Remove a specific drag gradient
  72606. * @param gradient defines the gradient to remove
  72607. * @returns the current particle system
  72608. */
  72609. removeDragGradient(gradient: number): IParticleSystem;
  72610. /**
  72611. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72612. * @param gradient defines the gradient to use (between 0 and 1)
  72613. * @param factor defines the emit rate value to affect to the specified gradient
  72614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72615. * @returns the current particle system
  72616. */
  72617. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72618. /**
  72619. * Remove a specific emit rate gradient
  72620. * @param gradient defines the gradient to remove
  72621. * @returns the current particle system
  72622. */
  72623. removeEmitRateGradient(gradient: number): IParticleSystem;
  72624. /**
  72625. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72626. * @param gradient defines the gradient to use (between 0 and 1)
  72627. * @param factor defines the start size value to affect to the specified gradient
  72628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72629. * @returns the current particle system
  72630. */
  72631. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72632. /**
  72633. * Remove a specific start size gradient
  72634. * @param gradient defines the gradient to remove
  72635. * @returns the current particle system
  72636. */
  72637. removeStartSizeGradient(gradient: number): IParticleSystem;
  72638. private _createRampGradientTexture;
  72639. /**
  72640. * Gets the current list of ramp gradients.
  72641. * You must use addRampGradient and removeRampGradient to udpate this list
  72642. * @returns the list of ramp gradients
  72643. */
  72644. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72645. /**
  72646. * Adds a new ramp gradient used to remap particle colors
  72647. * @param gradient defines the gradient to use (between 0 and 1)
  72648. * @param color defines the color to affect to the specified gradient
  72649. * @returns the current particle system
  72650. */
  72651. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72652. /**
  72653. * Remove a specific ramp gradient
  72654. * @param gradient defines the gradient to remove
  72655. * @returns the current particle system
  72656. */
  72657. removeRampGradient(gradient: number): ParticleSystem;
  72658. /**
  72659. * Adds a new color gradient
  72660. * @param gradient defines the gradient to use (between 0 and 1)
  72661. * @param color1 defines the color to affect to the specified gradient
  72662. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72663. * @returns this particle system
  72664. */
  72665. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72666. /**
  72667. * Remove a specific color gradient
  72668. * @param gradient defines the gradient to remove
  72669. * @returns this particle system
  72670. */
  72671. removeColorGradient(gradient: number): IParticleSystem;
  72672. private _fetchR;
  72673. protected _reset(): void;
  72674. private _resetEffect;
  72675. private _createVertexBuffers;
  72676. private _createIndexBuffer;
  72677. /**
  72678. * Gets the maximum number of particles active at the same time.
  72679. * @returns The max number of active particles.
  72680. */
  72681. getCapacity(): number;
  72682. /**
  72683. * Gets whether there are still active particles in the system.
  72684. * @returns True if it is alive, otherwise false.
  72685. */
  72686. isAlive(): boolean;
  72687. /**
  72688. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72689. * @returns True if it has been started, otherwise false.
  72690. */
  72691. isStarted(): boolean;
  72692. private _prepareSubEmitterInternalArray;
  72693. /**
  72694. * Starts the particle system and begins to emit
  72695. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72696. */
  72697. start(delay?: number): void;
  72698. /**
  72699. * Stops the particle system.
  72700. * @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.
  72701. */
  72702. stop(stopSubEmitters?: boolean): void;
  72703. /**
  72704. * Remove all active particles
  72705. */
  72706. reset(): void;
  72707. /**
  72708. * @hidden (for internal use only)
  72709. */
  72710. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72711. /**
  72712. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72713. * Its lifetime will start back at 0.
  72714. */
  72715. recycleParticle: (particle: Particle) => void;
  72716. private _stopSubEmitters;
  72717. private _createParticle;
  72718. private _removeFromRoot;
  72719. private _emitFromParticle;
  72720. private _update;
  72721. /** @hidden */
  72722. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72723. /** @hidden */
  72724. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72725. /** @hidden */
  72726. private _getEffect;
  72727. /**
  72728. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72729. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72730. */
  72731. animate(preWarmOnly?: boolean): void;
  72732. private _appendParticleVertices;
  72733. /**
  72734. * Rebuilds the particle system.
  72735. */
  72736. rebuild(): void;
  72737. /**
  72738. * Is this system ready to be used/rendered
  72739. * @return true if the system is ready
  72740. */
  72741. isReady(): boolean;
  72742. private _render;
  72743. /**
  72744. * Renders the particle system in its current state.
  72745. * @returns the current number of particles
  72746. */
  72747. render(): number;
  72748. /**
  72749. * Disposes the particle system and free the associated resources
  72750. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72751. */
  72752. dispose(disposeTexture?: boolean): void;
  72753. /**
  72754. * Clones the particle system.
  72755. * @param name The name of the cloned object
  72756. * @param newEmitter The new emitter to use
  72757. * @returns the cloned particle system
  72758. */
  72759. clone(name: string, newEmitter: any): ParticleSystem;
  72760. /**
  72761. * Serializes the particle system to a JSON object.
  72762. * @returns the JSON object
  72763. */
  72764. serialize(): any;
  72765. /** @hidden */
  72766. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72767. /** @hidden */
  72768. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72769. /**
  72770. * Parses a JSON object to create a particle system.
  72771. * @param parsedParticleSystem The JSON object to parse
  72772. * @param scene The scene to create the particle system in
  72773. * @param rootUrl The root url to use to load external dependencies like texture
  72774. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72775. * @returns the Parsed particle system
  72776. */
  72777. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72778. }
  72779. }
  72780. declare module BABYLON {
  72781. /**
  72782. * A particle represents one of the element emitted by a particle system.
  72783. * This is mainly define by its coordinates, direction, velocity and age.
  72784. */
  72785. export class Particle {
  72786. /**
  72787. * The particle system the particle belongs to.
  72788. */
  72789. particleSystem: ParticleSystem;
  72790. private static _Count;
  72791. /**
  72792. * Unique ID of the particle
  72793. */
  72794. id: number;
  72795. /**
  72796. * The world position of the particle in the scene.
  72797. */
  72798. position: Vector3;
  72799. /**
  72800. * The world direction of the particle in the scene.
  72801. */
  72802. direction: Vector3;
  72803. /**
  72804. * The color of the particle.
  72805. */
  72806. color: Color4;
  72807. /**
  72808. * The color change of the particle per step.
  72809. */
  72810. colorStep: Color4;
  72811. /**
  72812. * Defines how long will the life of the particle be.
  72813. */
  72814. lifeTime: number;
  72815. /**
  72816. * The current age of the particle.
  72817. */
  72818. age: number;
  72819. /**
  72820. * The current size of the particle.
  72821. */
  72822. size: number;
  72823. /**
  72824. * The current scale of the particle.
  72825. */
  72826. scale: Vector2;
  72827. /**
  72828. * The current angle of the particle.
  72829. */
  72830. angle: number;
  72831. /**
  72832. * Defines how fast is the angle changing.
  72833. */
  72834. angularSpeed: number;
  72835. /**
  72836. * Defines the cell index used by the particle to be rendered from a sprite.
  72837. */
  72838. cellIndex: number;
  72839. /**
  72840. * The information required to support color remapping
  72841. */
  72842. remapData: Vector4;
  72843. /** @hidden */
  72844. _randomCellOffset?: number;
  72845. /** @hidden */
  72846. _initialDirection: Nullable<Vector3>;
  72847. /** @hidden */
  72848. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72849. /** @hidden */
  72850. _initialStartSpriteCellID: number;
  72851. /** @hidden */
  72852. _initialEndSpriteCellID: number;
  72853. /** @hidden */
  72854. _currentColorGradient: Nullable<ColorGradient>;
  72855. /** @hidden */
  72856. _currentColor1: Color4;
  72857. /** @hidden */
  72858. _currentColor2: Color4;
  72859. /** @hidden */
  72860. _currentSizeGradient: Nullable<FactorGradient>;
  72861. /** @hidden */
  72862. _currentSize1: number;
  72863. /** @hidden */
  72864. _currentSize2: number;
  72865. /** @hidden */
  72866. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72867. /** @hidden */
  72868. _currentAngularSpeed1: number;
  72869. /** @hidden */
  72870. _currentAngularSpeed2: number;
  72871. /** @hidden */
  72872. _currentVelocityGradient: Nullable<FactorGradient>;
  72873. /** @hidden */
  72874. _currentVelocity1: number;
  72875. /** @hidden */
  72876. _currentVelocity2: number;
  72877. /** @hidden */
  72878. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72879. /** @hidden */
  72880. _currentLimitVelocity1: number;
  72881. /** @hidden */
  72882. _currentLimitVelocity2: number;
  72883. /** @hidden */
  72884. _currentDragGradient: Nullable<FactorGradient>;
  72885. /** @hidden */
  72886. _currentDrag1: number;
  72887. /** @hidden */
  72888. _currentDrag2: number;
  72889. /** @hidden */
  72890. _randomNoiseCoordinates1: Vector3;
  72891. /** @hidden */
  72892. _randomNoiseCoordinates2: Vector3;
  72893. /**
  72894. * Creates a new instance Particle
  72895. * @param particleSystem the particle system the particle belongs to
  72896. */
  72897. constructor(
  72898. /**
  72899. * The particle system the particle belongs to.
  72900. */
  72901. particleSystem: ParticleSystem);
  72902. private updateCellInfoFromSystem;
  72903. /**
  72904. * Defines how the sprite cell index is updated for the particle
  72905. */
  72906. updateCellIndex(): void;
  72907. /** @hidden */
  72908. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72909. /** @hidden */
  72910. _inheritParticleInfoToSubEmitters(): void;
  72911. /** @hidden */
  72912. _reset(): void;
  72913. /**
  72914. * Copy the properties of particle to another one.
  72915. * @param other the particle to copy the information to.
  72916. */
  72917. copyTo(other: Particle): void;
  72918. }
  72919. }
  72920. declare module BABYLON {
  72921. /**
  72922. * Particle emitter represents a volume emitting particles.
  72923. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72924. */
  72925. export interface IParticleEmitterType {
  72926. /**
  72927. * Called by the particle System when the direction is computed for the created particle.
  72928. * @param worldMatrix is the world matrix of the particle system
  72929. * @param directionToUpdate is the direction vector to update with the result
  72930. * @param particle is the particle we are computed the direction for
  72931. */
  72932. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72933. /**
  72934. * Called by the particle System when the position is computed for the created particle.
  72935. * @param worldMatrix is the world matrix of the particle system
  72936. * @param positionToUpdate is the position vector to update with the result
  72937. * @param particle is the particle we are computed the position for
  72938. */
  72939. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72940. /**
  72941. * Clones the current emitter and returns a copy of it
  72942. * @returns the new emitter
  72943. */
  72944. clone(): IParticleEmitterType;
  72945. /**
  72946. * Called by the GPUParticleSystem to setup the update shader
  72947. * @param effect defines the update shader
  72948. */
  72949. applyToShader(effect: Effect): void;
  72950. /**
  72951. * Returns a string to use to update the GPU particles update shader
  72952. * @returns the effect defines string
  72953. */
  72954. getEffectDefines(): string;
  72955. /**
  72956. * Returns a string representing the class name
  72957. * @returns a string containing the class name
  72958. */
  72959. getClassName(): string;
  72960. /**
  72961. * Serializes the particle system to a JSON object.
  72962. * @returns the JSON object
  72963. */
  72964. serialize(): any;
  72965. /**
  72966. * Parse properties from a JSON object
  72967. * @param serializationObject defines the JSON object
  72968. */
  72969. parse(serializationObject: any): void;
  72970. }
  72971. }
  72972. declare module BABYLON {
  72973. /**
  72974. * Particle emitter emitting particles from the inside of a box.
  72975. * It emits the particles randomly between 2 given directions.
  72976. */
  72977. export class BoxParticleEmitter implements IParticleEmitterType {
  72978. /**
  72979. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72980. */
  72981. direction1: Vector3;
  72982. /**
  72983. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72984. */
  72985. direction2: Vector3;
  72986. /**
  72987. * 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.
  72988. */
  72989. minEmitBox: Vector3;
  72990. /**
  72991. * 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.
  72992. */
  72993. maxEmitBox: Vector3;
  72994. /**
  72995. * Creates a new instance BoxParticleEmitter
  72996. */
  72997. constructor();
  72998. /**
  72999. * Called by the particle System when the direction is computed for the created particle.
  73000. * @param worldMatrix is the world matrix of the particle system
  73001. * @param directionToUpdate is the direction vector to update with the result
  73002. * @param particle is the particle we are computed the direction for
  73003. */
  73004. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73005. /**
  73006. * Called by the particle System when the position is computed for the created particle.
  73007. * @param worldMatrix is the world matrix of the particle system
  73008. * @param positionToUpdate is the position vector to update with the result
  73009. * @param particle is the particle we are computed the position for
  73010. */
  73011. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73012. /**
  73013. * Clones the current emitter and returns a copy of it
  73014. * @returns the new emitter
  73015. */
  73016. clone(): BoxParticleEmitter;
  73017. /**
  73018. * Called by the GPUParticleSystem to setup the update shader
  73019. * @param effect defines the update shader
  73020. */
  73021. applyToShader(effect: Effect): void;
  73022. /**
  73023. * Returns a string to use to update the GPU particles update shader
  73024. * @returns a string containng the defines string
  73025. */
  73026. getEffectDefines(): string;
  73027. /**
  73028. * Returns the string "BoxParticleEmitter"
  73029. * @returns a string containing the class name
  73030. */
  73031. getClassName(): string;
  73032. /**
  73033. * Serializes the particle system to a JSON object.
  73034. * @returns the JSON object
  73035. */
  73036. serialize(): any;
  73037. /**
  73038. * Parse properties from a JSON object
  73039. * @param serializationObject defines the JSON object
  73040. */
  73041. parse(serializationObject: any): void;
  73042. }
  73043. }
  73044. declare module BABYLON {
  73045. /**
  73046. * Particle emitter emitting particles from the inside of a cone.
  73047. * It emits the particles alongside the cone volume from the base to the particle.
  73048. * The emission direction might be randomized.
  73049. */
  73050. export class ConeParticleEmitter implements IParticleEmitterType {
  73051. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73052. directionRandomizer: number;
  73053. private _radius;
  73054. private _angle;
  73055. private _height;
  73056. /**
  73057. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  73058. */
  73059. radiusRange: number;
  73060. /**
  73061. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  73062. */
  73063. heightRange: number;
  73064. /**
  73065. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  73066. */
  73067. emitFromSpawnPointOnly: boolean;
  73068. /**
  73069. * Gets or sets the radius of the emission cone
  73070. */
  73071. radius: number;
  73072. /**
  73073. * Gets or sets the angle of the emission cone
  73074. */
  73075. angle: number;
  73076. private _buildHeight;
  73077. /**
  73078. * Creates a new instance ConeParticleEmitter
  73079. * @param radius the radius of the emission cone (1 by default)
  73080. * @param angle the cone base angle (PI by default)
  73081. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  73082. */
  73083. constructor(radius?: number, angle?: number,
  73084. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73085. directionRandomizer?: number);
  73086. /**
  73087. * Called by the particle System when the direction is computed for the created particle.
  73088. * @param worldMatrix is the world matrix of the particle system
  73089. * @param directionToUpdate is the direction vector to update with the result
  73090. * @param particle is the particle we are computed the direction for
  73091. */
  73092. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73093. /**
  73094. * Called by the particle System when the position is computed for the created particle.
  73095. * @param worldMatrix is the world matrix of the particle system
  73096. * @param positionToUpdate is the position vector to update with the result
  73097. * @param particle is the particle we are computed the position for
  73098. */
  73099. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73100. /**
  73101. * Clones the current emitter and returns a copy of it
  73102. * @returns the new emitter
  73103. */
  73104. clone(): ConeParticleEmitter;
  73105. /**
  73106. * Called by the GPUParticleSystem to setup the update shader
  73107. * @param effect defines the update shader
  73108. */
  73109. applyToShader(effect: Effect): void;
  73110. /**
  73111. * Returns a string to use to update the GPU particles update shader
  73112. * @returns a string containng the defines string
  73113. */
  73114. getEffectDefines(): string;
  73115. /**
  73116. * Returns the string "ConeParticleEmitter"
  73117. * @returns a string containing the class name
  73118. */
  73119. getClassName(): string;
  73120. /**
  73121. * Serializes the particle system to a JSON object.
  73122. * @returns the JSON object
  73123. */
  73124. serialize(): any;
  73125. /**
  73126. * Parse properties from a JSON object
  73127. * @param serializationObject defines the JSON object
  73128. */
  73129. parse(serializationObject: any): void;
  73130. }
  73131. }
  73132. declare module BABYLON {
  73133. /**
  73134. * Particle emitter emitting particles from the inside of a cylinder.
  73135. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  73136. */
  73137. export class CylinderParticleEmitter implements IParticleEmitterType {
  73138. /**
  73139. * The radius of the emission cylinder.
  73140. */
  73141. radius: number;
  73142. /**
  73143. * The height of the emission cylinder.
  73144. */
  73145. height: number;
  73146. /**
  73147. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73148. */
  73149. radiusRange: number;
  73150. /**
  73151. * How much to randomize the particle direction [0-1].
  73152. */
  73153. directionRandomizer: number;
  73154. /**
  73155. * Creates a new instance CylinderParticleEmitter
  73156. * @param radius the radius of the emission cylinder (1 by default)
  73157. * @param height the height of the emission cylinder (1 by default)
  73158. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73159. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73160. */
  73161. constructor(
  73162. /**
  73163. * The radius of the emission cylinder.
  73164. */
  73165. radius?: number,
  73166. /**
  73167. * The height of the emission cylinder.
  73168. */
  73169. height?: number,
  73170. /**
  73171. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73172. */
  73173. radiusRange?: number,
  73174. /**
  73175. * How much to randomize the particle direction [0-1].
  73176. */
  73177. directionRandomizer?: number);
  73178. /**
  73179. * Called by the particle System when the direction is computed for the created particle.
  73180. * @param worldMatrix is the world matrix of the particle system
  73181. * @param directionToUpdate is the direction vector to update with the result
  73182. * @param particle is the particle we are computed the direction for
  73183. */
  73184. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73185. /**
  73186. * Called by the particle System when the position is computed for the created particle.
  73187. * @param worldMatrix is the world matrix of the particle system
  73188. * @param positionToUpdate is the position vector to update with the result
  73189. * @param particle is the particle we are computed the position for
  73190. */
  73191. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73192. /**
  73193. * Clones the current emitter and returns a copy of it
  73194. * @returns the new emitter
  73195. */
  73196. clone(): CylinderParticleEmitter;
  73197. /**
  73198. * Called by the GPUParticleSystem to setup the update shader
  73199. * @param effect defines the update shader
  73200. */
  73201. applyToShader(effect: Effect): void;
  73202. /**
  73203. * Returns a string to use to update the GPU particles update shader
  73204. * @returns a string containng the defines string
  73205. */
  73206. getEffectDefines(): string;
  73207. /**
  73208. * Returns the string "CylinderParticleEmitter"
  73209. * @returns a string containing the class name
  73210. */
  73211. getClassName(): string;
  73212. /**
  73213. * Serializes the particle system to a JSON object.
  73214. * @returns the JSON object
  73215. */
  73216. serialize(): any;
  73217. /**
  73218. * Parse properties from a JSON object
  73219. * @param serializationObject defines the JSON object
  73220. */
  73221. parse(serializationObject: any): void;
  73222. }
  73223. /**
  73224. * Particle emitter emitting particles from the inside of a cylinder.
  73225. * It emits the particles randomly between two vectors.
  73226. */
  73227. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  73228. /**
  73229. * The min limit of the emission direction.
  73230. */
  73231. direction1: Vector3;
  73232. /**
  73233. * The max limit of the emission direction.
  73234. */
  73235. direction2: Vector3;
  73236. /**
  73237. * Creates a new instance CylinderDirectedParticleEmitter
  73238. * @param radius the radius of the emission cylinder (1 by default)
  73239. * @param height the height of the emission cylinder (1 by default)
  73240. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73241. * @param direction1 the min limit of the emission direction (up vector by default)
  73242. * @param direction2 the max limit of the emission direction (up vector by default)
  73243. */
  73244. constructor(radius?: number, height?: number, radiusRange?: number,
  73245. /**
  73246. * The min limit of the emission direction.
  73247. */
  73248. direction1?: Vector3,
  73249. /**
  73250. * The max limit of the emission direction.
  73251. */
  73252. direction2?: Vector3);
  73253. /**
  73254. * Called by the particle System when the direction is computed for the created particle.
  73255. * @param worldMatrix is the world matrix of the particle system
  73256. * @param directionToUpdate is the direction vector to update with the result
  73257. * @param particle is the particle we are computed the direction for
  73258. */
  73259. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73260. /**
  73261. * Clones the current emitter and returns a copy of it
  73262. * @returns the new emitter
  73263. */
  73264. clone(): CylinderDirectedParticleEmitter;
  73265. /**
  73266. * Called by the GPUParticleSystem to setup the update shader
  73267. * @param effect defines the update shader
  73268. */
  73269. applyToShader(effect: Effect): void;
  73270. /**
  73271. * Returns a string to use to update the GPU particles update shader
  73272. * @returns a string containng the defines string
  73273. */
  73274. getEffectDefines(): string;
  73275. /**
  73276. * Returns the string "CylinderDirectedParticleEmitter"
  73277. * @returns a string containing the class name
  73278. */
  73279. getClassName(): string;
  73280. /**
  73281. * Serializes the particle system to a JSON object.
  73282. * @returns the JSON object
  73283. */
  73284. serialize(): any;
  73285. /**
  73286. * Parse properties from a JSON object
  73287. * @param serializationObject defines the JSON object
  73288. */
  73289. parse(serializationObject: any): void;
  73290. }
  73291. }
  73292. declare module BABYLON {
  73293. /**
  73294. * Particle emitter emitting particles from the inside of a hemisphere.
  73295. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  73296. */
  73297. export class HemisphericParticleEmitter implements IParticleEmitterType {
  73298. /**
  73299. * The radius of the emission hemisphere.
  73300. */
  73301. radius: number;
  73302. /**
  73303. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73304. */
  73305. radiusRange: number;
  73306. /**
  73307. * How much to randomize the particle direction [0-1].
  73308. */
  73309. directionRandomizer: number;
  73310. /**
  73311. * Creates a new instance HemisphericParticleEmitter
  73312. * @param radius the radius of the emission hemisphere (1 by default)
  73313. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73314. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73315. */
  73316. constructor(
  73317. /**
  73318. * The radius of the emission hemisphere.
  73319. */
  73320. radius?: number,
  73321. /**
  73322. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73323. */
  73324. radiusRange?: number,
  73325. /**
  73326. * How much to randomize the particle direction [0-1].
  73327. */
  73328. directionRandomizer?: number);
  73329. /**
  73330. * Called by the particle System when the direction is computed for the created particle.
  73331. * @param worldMatrix is the world matrix of the particle system
  73332. * @param directionToUpdate is the direction vector to update with the result
  73333. * @param particle is the particle we are computed the direction for
  73334. */
  73335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73336. /**
  73337. * Called by the particle System when the position is computed for the created particle.
  73338. * @param worldMatrix is the world matrix of the particle system
  73339. * @param positionToUpdate is the position vector to update with the result
  73340. * @param particle is the particle we are computed the position for
  73341. */
  73342. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73343. /**
  73344. * Clones the current emitter and returns a copy of it
  73345. * @returns the new emitter
  73346. */
  73347. clone(): HemisphericParticleEmitter;
  73348. /**
  73349. * Called by the GPUParticleSystem to setup the update shader
  73350. * @param effect defines the update shader
  73351. */
  73352. applyToShader(effect: Effect): void;
  73353. /**
  73354. * Returns a string to use to update the GPU particles update shader
  73355. * @returns a string containng the defines string
  73356. */
  73357. getEffectDefines(): string;
  73358. /**
  73359. * Returns the string "HemisphericParticleEmitter"
  73360. * @returns a string containing the class name
  73361. */
  73362. getClassName(): string;
  73363. /**
  73364. * Serializes the particle system to a JSON object.
  73365. * @returns the JSON object
  73366. */
  73367. serialize(): any;
  73368. /**
  73369. * Parse properties from a JSON object
  73370. * @param serializationObject defines the JSON object
  73371. */
  73372. parse(serializationObject: any): void;
  73373. }
  73374. }
  73375. declare module BABYLON {
  73376. /**
  73377. * Particle emitter emitting particles from a point.
  73378. * It emits the particles randomly between 2 given directions.
  73379. */
  73380. export class PointParticleEmitter implements IParticleEmitterType {
  73381. /**
  73382. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73383. */
  73384. direction1: Vector3;
  73385. /**
  73386. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73387. */
  73388. direction2: Vector3;
  73389. /**
  73390. * Creates a new instance PointParticleEmitter
  73391. */
  73392. constructor();
  73393. /**
  73394. * Called by the particle System when the direction is computed for the created particle.
  73395. * @param worldMatrix is the world matrix of the particle system
  73396. * @param directionToUpdate is the direction vector to update with the result
  73397. * @param particle is the particle we are computed the direction for
  73398. */
  73399. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73400. /**
  73401. * Called by the particle System when the position is computed for the created particle.
  73402. * @param worldMatrix is the world matrix of the particle system
  73403. * @param positionToUpdate is the position vector to update with the result
  73404. * @param particle is the particle we are computed the position for
  73405. */
  73406. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73407. /**
  73408. * Clones the current emitter and returns a copy of it
  73409. * @returns the new emitter
  73410. */
  73411. clone(): PointParticleEmitter;
  73412. /**
  73413. * Called by the GPUParticleSystem to setup the update shader
  73414. * @param effect defines the update shader
  73415. */
  73416. applyToShader(effect: Effect): void;
  73417. /**
  73418. * Returns a string to use to update the GPU particles update shader
  73419. * @returns a string containng the defines string
  73420. */
  73421. getEffectDefines(): string;
  73422. /**
  73423. * Returns the string "PointParticleEmitter"
  73424. * @returns a string containing the class name
  73425. */
  73426. getClassName(): string;
  73427. /**
  73428. * Serializes the particle system to a JSON object.
  73429. * @returns the JSON object
  73430. */
  73431. serialize(): any;
  73432. /**
  73433. * Parse properties from a JSON object
  73434. * @param serializationObject defines the JSON object
  73435. */
  73436. parse(serializationObject: any): void;
  73437. }
  73438. }
  73439. declare module BABYLON {
  73440. /**
  73441. * Particle emitter emitting particles from the inside of a sphere.
  73442. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  73443. */
  73444. export class SphereParticleEmitter implements IParticleEmitterType {
  73445. /**
  73446. * The radius of the emission sphere.
  73447. */
  73448. radius: number;
  73449. /**
  73450. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73451. */
  73452. radiusRange: number;
  73453. /**
  73454. * How much to randomize the particle direction [0-1].
  73455. */
  73456. directionRandomizer: number;
  73457. /**
  73458. * Creates a new instance SphereParticleEmitter
  73459. * @param radius the radius of the emission sphere (1 by default)
  73460. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73461. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73462. */
  73463. constructor(
  73464. /**
  73465. * The radius of the emission sphere.
  73466. */
  73467. radius?: number,
  73468. /**
  73469. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73470. */
  73471. radiusRange?: number,
  73472. /**
  73473. * How much to randomize the particle direction [0-1].
  73474. */
  73475. directionRandomizer?: number);
  73476. /**
  73477. * Called by the particle System when the direction is computed for the created particle.
  73478. * @param worldMatrix is the world matrix of the particle system
  73479. * @param directionToUpdate is the direction vector to update with the result
  73480. * @param particle is the particle we are computed the direction for
  73481. */
  73482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73483. /**
  73484. * Called by the particle System when the position is computed for the created particle.
  73485. * @param worldMatrix is the world matrix of the particle system
  73486. * @param positionToUpdate is the position vector to update with the result
  73487. * @param particle is the particle we are computed the position for
  73488. */
  73489. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73490. /**
  73491. * Clones the current emitter and returns a copy of it
  73492. * @returns the new emitter
  73493. */
  73494. clone(): SphereParticleEmitter;
  73495. /**
  73496. * Called by the GPUParticleSystem to setup the update shader
  73497. * @param effect defines the update shader
  73498. */
  73499. applyToShader(effect: Effect): void;
  73500. /**
  73501. * Returns a string to use to update the GPU particles update shader
  73502. * @returns a string containng the defines string
  73503. */
  73504. getEffectDefines(): string;
  73505. /**
  73506. * Returns the string "SphereParticleEmitter"
  73507. * @returns a string containing the class name
  73508. */
  73509. getClassName(): string;
  73510. /**
  73511. * Serializes the particle system to a JSON object.
  73512. * @returns the JSON object
  73513. */
  73514. serialize(): any;
  73515. /**
  73516. * Parse properties from a JSON object
  73517. * @param serializationObject defines the JSON object
  73518. */
  73519. parse(serializationObject: any): void;
  73520. }
  73521. /**
  73522. * Particle emitter emitting particles from the inside of a sphere.
  73523. * It emits the particles randomly between two vectors.
  73524. */
  73525. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  73526. /**
  73527. * The min limit of the emission direction.
  73528. */
  73529. direction1: Vector3;
  73530. /**
  73531. * The max limit of the emission direction.
  73532. */
  73533. direction2: Vector3;
  73534. /**
  73535. * Creates a new instance SphereDirectedParticleEmitter
  73536. * @param radius the radius of the emission sphere (1 by default)
  73537. * @param direction1 the min limit of the emission direction (up vector by default)
  73538. * @param direction2 the max limit of the emission direction (up vector by default)
  73539. */
  73540. constructor(radius?: number,
  73541. /**
  73542. * The min limit of the emission direction.
  73543. */
  73544. direction1?: Vector3,
  73545. /**
  73546. * The max limit of the emission direction.
  73547. */
  73548. direction2?: Vector3);
  73549. /**
  73550. * Called by the particle System when the direction is computed for the created particle.
  73551. * @param worldMatrix is the world matrix of the particle system
  73552. * @param directionToUpdate is the direction vector to update with the result
  73553. * @param particle is the particle we are computed the direction for
  73554. */
  73555. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73556. /**
  73557. * Clones the current emitter and returns a copy of it
  73558. * @returns the new emitter
  73559. */
  73560. clone(): SphereDirectedParticleEmitter;
  73561. /**
  73562. * Called by the GPUParticleSystem to setup the update shader
  73563. * @param effect defines the update shader
  73564. */
  73565. applyToShader(effect: Effect): void;
  73566. /**
  73567. * Returns a string to use to update the GPU particles update shader
  73568. * @returns a string containng the defines string
  73569. */
  73570. getEffectDefines(): string;
  73571. /**
  73572. * Returns the string "SphereDirectedParticleEmitter"
  73573. * @returns a string containing the class name
  73574. */
  73575. getClassName(): string;
  73576. /**
  73577. * Serializes the particle system to a JSON object.
  73578. * @returns the JSON object
  73579. */
  73580. serialize(): any;
  73581. /**
  73582. * Parse properties from a JSON object
  73583. * @param serializationObject defines the JSON object
  73584. */
  73585. parse(serializationObject: any): void;
  73586. }
  73587. }
  73588. declare module BABYLON {
  73589. /**
  73590. * Interface representing a particle system in Babylon.js.
  73591. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73592. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73593. */
  73594. export interface IParticleSystem {
  73595. /**
  73596. * List of animations used by the particle system.
  73597. */
  73598. animations: Animation[];
  73599. /**
  73600. * The id of the Particle system.
  73601. */
  73602. id: string;
  73603. /**
  73604. * The name of the Particle system.
  73605. */
  73606. name: string;
  73607. /**
  73608. * The emitter represents the Mesh or position we are attaching the particle system to.
  73609. */
  73610. emitter: Nullable<AbstractMesh | Vector3>;
  73611. /**
  73612. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73613. */
  73614. isBillboardBased: boolean;
  73615. /**
  73616. * The rendering group used by the Particle system to chose when to render.
  73617. */
  73618. renderingGroupId: number;
  73619. /**
  73620. * The layer mask we are rendering the particles through.
  73621. */
  73622. layerMask: number;
  73623. /**
  73624. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73625. */
  73626. updateSpeed: number;
  73627. /**
  73628. * The amount of time the particle system is running (depends of the overall update speed).
  73629. */
  73630. targetStopDuration: number;
  73631. /**
  73632. * The texture used to render each particle. (this can be a spritesheet)
  73633. */
  73634. particleTexture: Nullable<Texture>;
  73635. /**
  73636. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73637. */
  73638. blendMode: number;
  73639. /**
  73640. * Minimum life time of emitting particles.
  73641. */
  73642. minLifeTime: number;
  73643. /**
  73644. * Maximum life time of emitting particles.
  73645. */
  73646. maxLifeTime: number;
  73647. /**
  73648. * Minimum Size of emitting particles.
  73649. */
  73650. minSize: number;
  73651. /**
  73652. * Maximum Size of emitting particles.
  73653. */
  73654. maxSize: number;
  73655. /**
  73656. * Minimum scale of emitting particles on X axis.
  73657. */
  73658. minScaleX: number;
  73659. /**
  73660. * Maximum scale of emitting particles on X axis.
  73661. */
  73662. maxScaleX: number;
  73663. /**
  73664. * Minimum scale of emitting particles on Y axis.
  73665. */
  73666. minScaleY: number;
  73667. /**
  73668. * Maximum scale of emitting particles on Y axis.
  73669. */
  73670. maxScaleY: number;
  73671. /**
  73672. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73673. */
  73674. color1: Color4;
  73675. /**
  73676. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73677. */
  73678. color2: Color4;
  73679. /**
  73680. * Color the particle will have at the end of its lifetime.
  73681. */
  73682. colorDead: Color4;
  73683. /**
  73684. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73685. */
  73686. emitRate: number;
  73687. /**
  73688. * You can use gravity if you want to give an orientation to your particles.
  73689. */
  73690. gravity: Vector3;
  73691. /**
  73692. * Minimum power of emitting particles.
  73693. */
  73694. minEmitPower: number;
  73695. /**
  73696. * Maximum power of emitting particles.
  73697. */
  73698. maxEmitPower: number;
  73699. /**
  73700. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73701. */
  73702. minAngularSpeed: number;
  73703. /**
  73704. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73705. */
  73706. maxAngularSpeed: number;
  73707. /**
  73708. * Gets or sets the minimal initial rotation in radians.
  73709. */
  73710. minInitialRotation: number;
  73711. /**
  73712. * Gets or sets the maximal initial rotation in radians.
  73713. */
  73714. maxInitialRotation: number;
  73715. /**
  73716. * The particle emitter type defines the emitter used by the particle system.
  73717. * It can be for example box, sphere, or cone...
  73718. */
  73719. particleEmitterType: Nullable<IParticleEmitterType>;
  73720. /**
  73721. * Defines the delay in milliseconds before starting the system (0 by default)
  73722. */
  73723. startDelay: number;
  73724. /**
  73725. * 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
  73726. */
  73727. preWarmCycles: number;
  73728. /**
  73729. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73730. */
  73731. preWarmStepOffset: number;
  73732. /**
  73733. * 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)
  73734. */
  73735. spriteCellChangeSpeed: number;
  73736. /**
  73737. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73738. */
  73739. startSpriteCellID: number;
  73740. /**
  73741. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73742. */
  73743. endSpriteCellID: number;
  73744. /**
  73745. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73746. */
  73747. spriteCellWidth: number;
  73748. /**
  73749. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73750. */
  73751. spriteCellHeight: number;
  73752. /**
  73753. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73754. */
  73755. spriteRandomStartCell: boolean;
  73756. /**
  73757. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73758. */
  73759. isAnimationSheetEnabled: boolean;
  73760. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73761. translationPivot: Vector2;
  73762. /**
  73763. * Gets or sets a texture used to add random noise to particle positions
  73764. */
  73765. noiseTexture: Nullable<BaseTexture>;
  73766. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73767. noiseStrength: Vector3;
  73768. /**
  73769. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73770. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73771. */
  73772. billboardMode: number;
  73773. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73774. limitVelocityDamping: number;
  73775. /**
  73776. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73777. */
  73778. beginAnimationOnStart: boolean;
  73779. /**
  73780. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73781. */
  73782. beginAnimationFrom: number;
  73783. /**
  73784. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73785. */
  73786. beginAnimationTo: number;
  73787. /**
  73788. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73789. */
  73790. beginAnimationLoop: boolean;
  73791. /**
  73792. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73793. */
  73794. disposeOnStop: boolean;
  73795. /**
  73796. * Gets the maximum number of particles active at the same time.
  73797. * @returns The max number of active particles.
  73798. */
  73799. getCapacity(): number;
  73800. /**
  73801. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73802. * @returns True if it has been started, otherwise false.
  73803. */
  73804. isStarted(): boolean;
  73805. /**
  73806. * Animates the particle system for this frame.
  73807. */
  73808. animate(): void;
  73809. /**
  73810. * Renders the particle system in its current state.
  73811. * @returns the current number of particles
  73812. */
  73813. render(): number;
  73814. /**
  73815. * Dispose the particle system and frees its associated resources.
  73816. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73817. */
  73818. dispose(disposeTexture?: boolean): void;
  73819. /**
  73820. * Clones the particle system.
  73821. * @param name The name of the cloned object
  73822. * @param newEmitter The new emitter to use
  73823. * @returns the cloned particle system
  73824. */
  73825. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73826. /**
  73827. * Serializes the particle system to a JSON object.
  73828. * @returns the JSON object
  73829. */
  73830. serialize(): any;
  73831. /**
  73832. * Rebuild the particle system
  73833. */
  73834. rebuild(): void;
  73835. /**
  73836. * Starts the particle system and begins to emit
  73837. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73838. */
  73839. start(delay?: number): void;
  73840. /**
  73841. * Stops the particle system.
  73842. */
  73843. stop(): void;
  73844. /**
  73845. * Remove all active particles
  73846. */
  73847. reset(): void;
  73848. /**
  73849. * Is this system ready to be used/rendered
  73850. * @return true if the system is ready
  73851. */
  73852. isReady(): boolean;
  73853. /**
  73854. * Adds a new color gradient
  73855. * @param gradient defines the gradient to use (between 0 and 1)
  73856. * @param color1 defines the color to affect to the specified gradient
  73857. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73858. * @returns the current particle system
  73859. */
  73860. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73861. /**
  73862. * Remove a specific color gradient
  73863. * @param gradient defines the gradient to remove
  73864. * @returns the current particle system
  73865. */
  73866. removeColorGradient(gradient: number): IParticleSystem;
  73867. /**
  73868. * Adds a new size gradient
  73869. * @param gradient defines the gradient to use (between 0 and 1)
  73870. * @param factor defines the size factor to affect to the specified gradient
  73871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73872. * @returns the current particle system
  73873. */
  73874. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73875. /**
  73876. * Remove a specific size gradient
  73877. * @param gradient defines the gradient to remove
  73878. * @returns the current particle system
  73879. */
  73880. removeSizeGradient(gradient: number): IParticleSystem;
  73881. /**
  73882. * Gets the current list of color gradients.
  73883. * You must use addColorGradient and removeColorGradient to udpate this list
  73884. * @returns the list of color gradients
  73885. */
  73886. getColorGradients(): Nullable<Array<ColorGradient>>;
  73887. /**
  73888. * Gets the current list of size gradients.
  73889. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73890. * @returns the list of size gradients
  73891. */
  73892. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73893. /**
  73894. * Gets the current list of angular speed gradients.
  73895. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73896. * @returns the list of angular speed gradients
  73897. */
  73898. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73899. /**
  73900. * Adds a new angular speed gradient
  73901. * @param gradient defines the gradient to use (between 0 and 1)
  73902. * @param factor defines the angular speed to affect to the specified gradient
  73903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73904. * @returns the current particle system
  73905. */
  73906. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73907. /**
  73908. * Remove a specific angular speed gradient
  73909. * @param gradient defines the gradient to remove
  73910. * @returns the current particle system
  73911. */
  73912. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73913. /**
  73914. * Gets the current list of velocity gradients.
  73915. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73916. * @returns the list of velocity gradients
  73917. */
  73918. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73919. /**
  73920. * Adds a new velocity gradient
  73921. * @param gradient defines the gradient to use (between 0 and 1)
  73922. * @param factor defines the velocity to affect to the specified gradient
  73923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73924. * @returns the current particle system
  73925. */
  73926. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73927. /**
  73928. * Remove a specific velocity gradient
  73929. * @param gradient defines the gradient to remove
  73930. * @returns the current particle system
  73931. */
  73932. removeVelocityGradient(gradient: number): IParticleSystem;
  73933. /**
  73934. * Gets the current list of limit velocity gradients.
  73935. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73936. * @returns the list of limit velocity gradients
  73937. */
  73938. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73939. /**
  73940. * Adds a new limit velocity gradient
  73941. * @param gradient defines the gradient to use (between 0 and 1)
  73942. * @param factor defines the limit velocity to affect to the specified gradient
  73943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73944. * @returns the current particle system
  73945. */
  73946. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73947. /**
  73948. * Remove a specific limit velocity gradient
  73949. * @param gradient defines the gradient to remove
  73950. * @returns the current particle system
  73951. */
  73952. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73953. /**
  73954. * Adds a new drag gradient
  73955. * @param gradient defines the gradient to use (between 0 and 1)
  73956. * @param factor defines the drag to affect to the specified gradient
  73957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73958. * @returns the current particle system
  73959. */
  73960. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73961. /**
  73962. * Remove a specific drag gradient
  73963. * @param gradient defines the gradient to remove
  73964. * @returns the current particle system
  73965. */
  73966. removeDragGradient(gradient: number): IParticleSystem;
  73967. /**
  73968. * Gets the current list of drag gradients.
  73969. * You must use addDragGradient and removeDragGradient to udpate this list
  73970. * @returns the list of drag gradients
  73971. */
  73972. getDragGradients(): Nullable<Array<FactorGradient>>;
  73973. /**
  73974. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73975. * @param gradient defines the gradient to use (between 0 and 1)
  73976. * @param factor defines the emit rate to affect to the specified gradient
  73977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73978. * @returns the current particle system
  73979. */
  73980. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73981. /**
  73982. * Remove a specific emit rate gradient
  73983. * @param gradient defines the gradient to remove
  73984. * @returns the current particle system
  73985. */
  73986. removeEmitRateGradient(gradient: number): IParticleSystem;
  73987. /**
  73988. * Gets the current list of emit rate gradients.
  73989. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73990. * @returns the list of emit rate gradients
  73991. */
  73992. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73993. /**
  73994. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73995. * @param gradient defines the gradient to use (between 0 and 1)
  73996. * @param factor defines the start size to affect to the specified gradient
  73997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73998. * @returns the current particle system
  73999. */
  74000. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74001. /**
  74002. * Remove a specific start size gradient
  74003. * @param gradient defines the gradient to remove
  74004. * @returns the current particle system
  74005. */
  74006. removeStartSizeGradient(gradient: number): IParticleSystem;
  74007. /**
  74008. * Gets the current list of start size gradients.
  74009. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74010. * @returns the list of start size gradients
  74011. */
  74012. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74013. /**
  74014. * Adds a new life time gradient
  74015. * @param gradient defines the gradient to use (between 0 and 1)
  74016. * @param factor defines the life time factor to affect to the specified gradient
  74017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74018. * @returns the current particle system
  74019. */
  74020. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74021. /**
  74022. * Remove a specific life time gradient
  74023. * @param gradient defines the gradient to remove
  74024. * @returns the current particle system
  74025. */
  74026. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74027. /**
  74028. * Gets the current list of life time gradients.
  74029. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74030. * @returns the list of life time gradients
  74031. */
  74032. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74033. /**
  74034. * Gets the current list of color gradients.
  74035. * You must use addColorGradient and removeColorGradient to udpate this list
  74036. * @returns the list of color gradients
  74037. */
  74038. getColorGradients(): Nullable<Array<ColorGradient>>;
  74039. /**
  74040. * Adds a new ramp gradient used to remap particle colors
  74041. * @param gradient defines the gradient to use (between 0 and 1)
  74042. * @param color defines the color to affect to the specified gradient
  74043. * @returns the current particle system
  74044. */
  74045. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  74046. /**
  74047. * Gets the current list of ramp gradients.
  74048. * You must use addRampGradient and removeRampGradient to udpate this list
  74049. * @returns the list of ramp gradients
  74050. */
  74051. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74052. /** Gets or sets a boolean indicating that ramp gradients must be used
  74053. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74054. */
  74055. useRampGradients: boolean;
  74056. /**
  74057. * Adds a new color remap gradient
  74058. * @param gradient defines the gradient to use (between 0 and 1)
  74059. * @param min defines the color remap minimal range
  74060. * @param max defines the color remap maximal range
  74061. * @returns the current particle system
  74062. */
  74063. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74064. /**
  74065. * Gets the current list of color remap gradients.
  74066. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74067. * @returns the list of color remap gradients
  74068. */
  74069. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74070. /**
  74071. * Adds a new alpha remap gradient
  74072. * @param gradient defines the gradient to use (between 0 and 1)
  74073. * @param min defines the alpha remap minimal range
  74074. * @param max defines the alpha remap maximal range
  74075. * @returns the current particle system
  74076. */
  74077. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74078. /**
  74079. * Gets the current list of alpha remap gradients.
  74080. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74081. * @returns the list of alpha remap gradients
  74082. */
  74083. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74084. /**
  74085. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74086. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74087. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74088. * @returns the emitter
  74089. */
  74090. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74091. /**
  74092. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74093. * @param radius The radius of the hemisphere to emit from
  74094. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74095. * @returns the emitter
  74096. */
  74097. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  74098. /**
  74099. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74100. * @param radius The radius of the sphere to emit from
  74101. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74102. * @returns the emitter
  74103. */
  74104. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  74105. /**
  74106. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74107. * @param radius The radius of the sphere to emit from
  74108. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74109. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74110. * @returns the emitter
  74111. */
  74112. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74113. /**
  74114. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74115. * @param radius The radius of the emission cylinder
  74116. * @param height The height of the emission cylinder
  74117. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74118. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74119. * @returns the emitter
  74120. */
  74121. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  74122. /**
  74123. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74124. * @param radius The radius of the cylinder to emit from
  74125. * @param height The height of the emission cylinder
  74126. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74127. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74128. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74129. * @returns the emitter
  74130. */
  74131. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74132. /**
  74133. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74134. * @param radius The radius of the cone to emit from
  74135. * @param angle The base angle of the cone
  74136. * @returns the emitter
  74137. */
  74138. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  74139. /**
  74140. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74143. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74144. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74145. * @returns the emitter
  74146. */
  74147. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74148. /**
  74149. * Get hosting scene
  74150. * @returns the scene
  74151. */
  74152. getScene(): Scene;
  74153. }
  74154. }
  74155. declare module BABYLON {
  74156. /**
  74157. * Creates an instance based on a source mesh.
  74158. */
  74159. export class InstancedMesh extends AbstractMesh {
  74160. private _sourceMesh;
  74161. private _currentLOD;
  74162. /** @hidden */
  74163. _indexInSourceMeshInstanceArray: number;
  74164. constructor(name: string, source: Mesh);
  74165. /**
  74166. * Returns the string "InstancedMesh".
  74167. */
  74168. getClassName(): string;
  74169. /**
  74170. * If the source mesh receives shadows
  74171. */
  74172. readonly receiveShadows: boolean;
  74173. /**
  74174. * The material of the source mesh
  74175. */
  74176. readonly material: Nullable<Material>;
  74177. /**
  74178. * Visibility of the source mesh
  74179. */
  74180. readonly visibility: number;
  74181. /**
  74182. * Skeleton of the source mesh
  74183. */
  74184. readonly skeleton: Nullable<Skeleton>;
  74185. /**
  74186. * Rendering ground id of the source mesh
  74187. */
  74188. renderingGroupId: number;
  74189. /**
  74190. * Returns the total number of vertices (integer).
  74191. */
  74192. getTotalVertices(): number;
  74193. /**
  74194. * Returns a positive integer : the total number of indices in this mesh geometry.
  74195. * @returns the numner of indices or zero if the mesh has no geometry.
  74196. */
  74197. getTotalIndices(): number;
  74198. /**
  74199. * The source mesh of the instance
  74200. */
  74201. readonly sourceMesh: Mesh;
  74202. /**
  74203. * Is this node ready to be used/rendered
  74204. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74205. * @return {boolean} is it ready
  74206. */
  74207. isReady(completeCheck?: boolean): boolean;
  74208. /**
  74209. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74210. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74211. * @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.
  74212. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74213. */
  74214. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74215. /**
  74216. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74217. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74218. * The `data` are either a numeric array either a Float32Array.
  74219. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74220. * 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).
  74221. * Note that a new underlying VertexBuffer object is created each call.
  74222. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74223. *
  74224. * Possible `kind` values :
  74225. * - VertexBuffer.PositionKind
  74226. * - VertexBuffer.UVKind
  74227. * - VertexBuffer.UV2Kind
  74228. * - VertexBuffer.UV3Kind
  74229. * - VertexBuffer.UV4Kind
  74230. * - VertexBuffer.UV5Kind
  74231. * - VertexBuffer.UV6Kind
  74232. * - VertexBuffer.ColorKind
  74233. * - VertexBuffer.MatricesIndicesKind
  74234. * - VertexBuffer.MatricesIndicesExtraKind
  74235. * - VertexBuffer.MatricesWeightsKind
  74236. * - VertexBuffer.MatricesWeightsExtraKind
  74237. *
  74238. * Returns the Mesh.
  74239. */
  74240. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74241. /**
  74242. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74243. * If the mesh has no geometry, it is simply returned as it is.
  74244. * The `data` are either a numeric array either a Float32Array.
  74245. * No new underlying VertexBuffer object is created.
  74246. * 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.
  74247. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74248. *
  74249. * Possible `kind` values :
  74250. * - VertexBuffer.PositionKind
  74251. * - VertexBuffer.UVKind
  74252. * - VertexBuffer.UV2Kind
  74253. * - VertexBuffer.UV3Kind
  74254. * - VertexBuffer.UV4Kind
  74255. * - VertexBuffer.UV5Kind
  74256. * - VertexBuffer.UV6Kind
  74257. * - VertexBuffer.ColorKind
  74258. * - VertexBuffer.MatricesIndicesKind
  74259. * - VertexBuffer.MatricesIndicesExtraKind
  74260. * - VertexBuffer.MatricesWeightsKind
  74261. * - VertexBuffer.MatricesWeightsExtraKind
  74262. *
  74263. * Returns the Mesh.
  74264. */
  74265. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74266. /**
  74267. * Sets the mesh indices.
  74268. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74269. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74270. * This method creates a new index buffer each call.
  74271. * Returns the Mesh.
  74272. */
  74273. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74274. /**
  74275. * Boolean : True if the mesh owns the requested kind of data.
  74276. */
  74277. isVerticesDataPresent(kind: string): boolean;
  74278. /**
  74279. * Returns an array of indices (IndicesArray).
  74280. */
  74281. getIndices(): Nullable<IndicesArray>;
  74282. readonly _positions: Nullable<Vector3[]>;
  74283. /**
  74284. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74285. * This means the mesh underlying bounding box and sphere are recomputed.
  74286. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74287. * @returns the current mesh
  74288. */
  74289. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74290. /** @hidden */
  74291. _preActivate(): InstancedMesh;
  74292. /** @hidden */
  74293. _activate(renderId: number): InstancedMesh;
  74294. /**
  74295. * Returns the current associated LOD AbstractMesh.
  74296. */
  74297. getLOD(camera: Camera): AbstractMesh;
  74298. /** @hidden */
  74299. _syncSubMeshes(): InstancedMesh;
  74300. /** @hidden */
  74301. _generatePointsArray(): boolean;
  74302. /**
  74303. * Creates a new InstancedMesh from the current mesh.
  74304. * - name (string) : the cloned mesh name
  74305. * - newParent (optional Node) : the optional Node to parent the clone to.
  74306. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74307. *
  74308. * Returns the clone.
  74309. */
  74310. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74311. /**
  74312. * Disposes the InstancedMesh.
  74313. * Returns nothing.
  74314. */
  74315. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74316. }
  74317. }
  74318. declare module BABYLON {
  74319. /**
  74320. * Defines the options associated with the creation of a shader material.
  74321. */
  74322. export interface IShaderMaterialOptions {
  74323. /**
  74324. * Does the material work in alpha blend mode
  74325. */
  74326. needAlphaBlending: boolean;
  74327. /**
  74328. * Does the material work in alpha test mode
  74329. */
  74330. needAlphaTesting: boolean;
  74331. /**
  74332. * The list of attribute names used in the shader
  74333. */
  74334. attributes: string[];
  74335. /**
  74336. * The list of unifrom names used in the shader
  74337. */
  74338. uniforms: string[];
  74339. /**
  74340. * The list of UBO names used in the shader
  74341. */
  74342. uniformBuffers: string[];
  74343. /**
  74344. * The list of sampler names used in the shader
  74345. */
  74346. samplers: string[];
  74347. /**
  74348. * The list of defines used in the shader
  74349. */
  74350. defines: string[];
  74351. }
  74352. /**
  74353. * 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.
  74354. *
  74355. * This returned material effects how the mesh will look based on the code in the shaders.
  74356. *
  74357. * @see http://doc.babylonjs.com/how_to/shader_material
  74358. */
  74359. export class ShaderMaterial extends Material {
  74360. private _shaderPath;
  74361. private _options;
  74362. private _textures;
  74363. private _textureArrays;
  74364. private _floats;
  74365. private _ints;
  74366. private _floatsArrays;
  74367. private _colors3;
  74368. private _colors3Arrays;
  74369. private _colors4;
  74370. private _vectors2;
  74371. private _vectors3;
  74372. private _vectors4;
  74373. private _matrices;
  74374. private _matrices3x3;
  74375. private _matrices2x2;
  74376. private _vectors2Arrays;
  74377. private _vectors3Arrays;
  74378. private _cachedWorldViewMatrix;
  74379. private _renderId;
  74380. /**
  74381. * Instantiate a new shader material.
  74382. * 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.
  74383. * This returned material effects how the mesh will look based on the code in the shaders.
  74384. * @see http://doc.babylonjs.com/how_to/shader_material
  74385. * @param name Define the name of the material in the scene
  74386. * @param scene Define the scene the material belongs to
  74387. * @param shaderPath Defines the route to the shader code in one of three ways:
  74388. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74389. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74390. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74391. * @param options Define the options used to create the shader
  74392. */
  74393. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74394. /**
  74395. * Gets the options used to compile the shader.
  74396. * They can be modified to trigger a new compilation
  74397. */
  74398. readonly options: IShaderMaterialOptions;
  74399. /**
  74400. * Gets the current class name of the material e.g. "ShaderMaterial"
  74401. * Mainly use in serialization.
  74402. * @returns the class name
  74403. */
  74404. getClassName(): string;
  74405. /**
  74406. * Specifies if the material will require alpha blending
  74407. * @returns a boolean specifying if alpha blending is needed
  74408. */
  74409. needAlphaBlending(): boolean;
  74410. /**
  74411. * Specifies if this material should be rendered in alpha test mode
  74412. * @returns a boolean specifying if an alpha test is needed.
  74413. */
  74414. needAlphaTesting(): boolean;
  74415. private _checkUniform;
  74416. /**
  74417. * Set a texture in the shader.
  74418. * @param name Define the name of the uniform samplers as defined in the shader
  74419. * @param texture Define the texture to bind to this sampler
  74420. * @return the material itself allowing "fluent" like uniform updates
  74421. */
  74422. setTexture(name: string, texture: Texture): ShaderMaterial;
  74423. /**
  74424. * Set a texture array in the shader.
  74425. * @param name Define the name of the uniform sampler array as defined in the shader
  74426. * @param textures Define the list of textures to bind to this sampler
  74427. * @return the material itself allowing "fluent" like uniform updates
  74428. */
  74429. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74430. /**
  74431. * Set a float in the shader.
  74432. * @param name Define the name of the uniform as defined in the shader
  74433. * @param value Define the value to give to the uniform
  74434. * @return the material itself allowing "fluent" like uniform updates
  74435. */
  74436. setFloat(name: string, value: number): ShaderMaterial;
  74437. /**
  74438. * Set a int in the shader.
  74439. * @param name Define the name of the uniform as defined in the shader
  74440. * @param value Define the value to give to the uniform
  74441. * @return the material itself allowing "fluent" like uniform updates
  74442. */
  74443. setInt(name: string, value: number): ShaderMaterial;
  74444. /**
  74445. * Set an array of floats in the shader.
  74446. * @param name Define the name of the uniform as defined in the shader
  74447. * @param value Define the value to give to the uniform
  74448. * @return the material itself allowing "fluent" like uniform updates
  74449. */
  74450. setFloats(name: string, value: number[]): ShaderMaterial;
  74451. /**
  74452. * Set a vec3 in the shader from a Color3.
  74453. * @param name Define the name of the uniform as defined in the shader
  74454. * @param value Define the value to give to the uniform
  74455. * @return the material itself allowing "fluent" like uniform updates
  74456. */
  74457. setColor3(name: string, value: Color3): ShaderMaterial;
  74458. /**
  74459. * Set a vec3 array in the shader from a Color3 array.
  74460. * @param name Define the name of the uniform as defined in the shader
  74461. * @param value Define the value to give to the uniform
  74462. * @return the material itself allowing "fluent" like uniform updates
  74463. */
  74464. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74465. /**
  74466. * Set a vec4 in the shader from a Color4.
  74467. * @param name Define the name of the uniform as defined in the shader
  74468. * @param value Define the value to give to the uniform
  74469. * @return the material itself allowing "fluent" like uniform updates
  74470. */
  74471. setColor4(name: string, value: Color4): ShaderMaterial;
  74472. /**
  74473. * Set a vec2 in the shader from a Vector2.
  74474. * @param name Define the name of the uniform as defined in the shader
  74475. * @param value Define the value to give to the uniform
  74476. * @return the material itself allowing "fluent" like uniform updates
  74477. */
  74478. setVector2(name: string, value: Vector2): ShaderMaterial;
  74479. /**
  74480. * Set a vec3 in the shader from a Vector3.
  74481. * @param name Define the name of the uniform as defined in the shader
  74482. * @param value Define the value to give to the uniform
  74483. * @return the material itself allowing "fluent" like uniform updates
  74484. */
  74485. setVector3(name: string, value: Vector3): ShaderMaterial;
  74486. /**
  74487. * Set a vec4 in the shader from a Vector4.
  74488. * @param name Define the name of the uniform as defined in the shader
  74489. * @param value Define the value to give to the uniform
  74490. * @return the material itself allowing "fluent" like uniform updates
  74491. */
  74492. setVector4(name: string, value: Vector4): ShaderMaterial;
  74493. /**
  74494. * Set a mat4 in the shader from a Matrix.
  74495. * @param name Define the name of the uniform as defined in the shader
  74496. * @param value Define the value to give to the uniform
  74497. * @return the material itself allowing "fluent" like uniform updates
  74498. */
  74499. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74500. /**
  74501. * Set a mat3 in the shader from a Float32Array.
  74502. * @param name Define the name of the uniform as defined in the shader
  74503. * @param value Define the value to give to the uniform
  74504. * @return the material itself allowing "fluent" like uniform updates
  74505. */
  74506. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74507. /**
  74508. * Set a mat2 in the shader from a Float32Array.
  74509. * @param name Define the name of the uniform as defined in the shader
  74510. * @param value Define the value to give to the uniform
  74511. * @return the material itself allowing "fluent" like uniform updates
  74512. */
  74513. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74514. /**
  74515. * Set a vec2 array in the shader from a number array.
  74516. * @param name Define the name of the uniform as defined in the shader
  74517. * @param value Define the value to give to the uniform
  74518. * @return the material itself allowing "fluent" like uniform updates
  74519. */
  74520. setArray2(name: string, value: number[]): ShaderMaterial;
  74521. /**
  74522. * Set a vec3 array in the shader from a number array.
  74523. * @param name Define the name of the uniform as defined in the shader
  74524. * @param value Define the value to give to the uniform
  74525. * @return the material itself allowing "fluent" like uniform updates
  74526. */
  74527. setArray3(name: string, value: number[]): ShaderMaterial;
  74528. private _checkCache;
  74529. /**
  74530. * Checks if the material is ready to render the requested mesh
  74531. * @param mesh Define the mesh to render
  74532. * @param useInstances Define whether or not the material is used with instances
  74533. * @returns true if ready, otherwise false
  74534. */
  74535. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74536. /**
  74537. * Binds the world matrix to the material
  74538. * @param world defines the world transformation matrix
  74539. */
  74540. bindOnlyWorldMatrix(world: Matrix): void;
  74541. /**
  74542. * Binds the material to the mesh
  74543. * @param world defines the world transformation matrix
  74544. * @param mesh defines the mesh to bind the material to
  74545. */
  74546. bind(world: Matrix, mesh?: Mesh): void;
  74547. /**
  74548. * Gets the active textures from the material
  74549. * @returns an array of textures
  74550. */
  74551. getActiveTextures(): BaseTexture[];
  74552. /**
  74553. * Specifies if the material uses a texture
  74554. * @param texture defines the texture to check against the material
  74555. * @returns a boolean specifying if the material uses the texture
  74556. */
  74557. hasTexture(texture: BaseTexture): boolean;
  74558. /**
  74559. * Makes a duplicate of the material, and gives it a new name
  74560. * @param name defines the new name for the duplicated material
  74561. * @returns the cloned material
  74562. */
  74563. clone(name: string): ShaderMaterial;
  74564. /**
  74565. * Disposes the material
  74566. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74567. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74568. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74569. */
  74570. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74571. /**
  74572. * Serializes this material in a JSON representation
  74573. * @returns the serialized material object
  74574. */
  74575. serialize(): any;
  74576. /**
  74577. * Creates a shader material from parsed shader material data
  74578. * @param source defines the JSON represnetation of the material
  74579. * @param scene defines the hosting scene
  74580. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74581. * @returns a new material
  74582. */
  74583. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74584. }
  74585. }
  74586. declare module BABYLON {
  74587. /** @hidden */
  74588. export var colorPixelShader: {
  74589. name: string;
  74590. shader: string;
  74591. };
  74592. }
  74593. declare module BABYLON {
  74594. /** @hidden */
  74595. export var colorVertexShader: {
  74596. name: string;
  74597. shader: string;
  74598. };
  74599. }
  74600. declare module BABYLON {
  74601. /**
  74602. * Line mesh
  74603. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74604. */
  74605. export class LinesMesh extends Mesh {
  74606. /**
  74607. * If vertex color should be applied to the mesh
  74608. */
  74609. useVertexColor?: boolean | undefined;
  74610. /**
  74611. * If vertex alpha should be applied to the mesh
  74612. */
  74613. useVertexAlpha?: boolean | undefined;
  74614. /**
  74615. * Color of the line (Default: White)
  74616. */
  74617. color: Color3;
  74618. /**
  74619. * Alpha of the line (Default: 1)
  74620. */
  74621. alpha: number;
  74622. /**
  74623. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74624. * This margin is expressed in world space coordinates, so its value may vary.
  74625. * Default value is 0.1
  74626. */
  74627. intersectionThreshold: number;
  74628. private _colorShader;
  74629. /**
  74630. * Creates a new LinesMesh
  74631. * @param name defines the name
  74632. * @param scene defines the hosting scene
  74633. * @param parent defines the parent mesh if any
  74634. * @param source defines the optional source LinesMesh used to clone data from
  74635. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74636. * When false, achieved by calling a clone(), also passing False.
  74637. * This will make creation of children, recursive.
  74638. * @param useVertexColor defines if this LinesMesh supports vertex color
  74639. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74640. */
  74641. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74642. /**
  74643. * If vertex color should be applied to the mesh
  74644. */
  74645. useVertexColor?: boolean | undefined,
  74646. /**
  74647. * If vertex alpha should be applied to the mesh
  74648. */
  74649. useVertexAlpha?: boolean | undefined);
  74650. private _addClipPlaneDefine;
  74651. private _removeClipPlaneDefine;
  74652. isReady(): boolean;
  74653. /**
  74654. * Returns the string "LineMesh"
  74655. */
  74656. getClassName(): string;
  74657. /**
  74658. * @hidden
  74659. */
  74660. /**
  74661. * @hidden
  74662. */
  74663. material: Material;
  74664. /**
  74665. * @hidden
  74666. */
  74667. readonly checkCollisions: boolean;
  74668. /** @hidden */
  74669. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74670. /** @hidden */
  74671. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74672. /**
  74673. * Disposes of the line mesh
  74674. * @param doNotRecurse If children should be disposed
  74675. */
  74676. dispose(doNotRecurse?: boolean): void;
  74677. /**
  74678. * Returns a new LineMesh object cloned from the current one.
  74679. */
  74680. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74681. /**
  74682. * Creates a new InstancedLinesMesh object from the mesh model.
  74683. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74684. * @param name defines the name of the new instance
  74685. * @returns a new InstancedLinesMesh
  74686. */
  74687. createInstance(name: string): InstancedLinesMesh;
  74688. }
  74689. /**
  74690. * Creates an instance based on a source LinesMesh
  74691. */
  74692. export class InstancedLinesMesh extends InstancedMesh {
  74693. /**
  74694. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74695. * This margin is expressed in world space coordinates, so its value may vary.
  74696. * Initilized with the intersectionThreshold value of the source LinesMesh
  74697. */
  74698. intersectionThreshold: number;
  74699. constructor(name: string, source: LinesMesh);
  74700. /**
  74701. * Returns the string "InstancedLinesMesh".
  74702. */
  74703. getClassName(): string;
  74704. }
  74705. }
  74706. declare module BABYLON {
  74707. /** @hidden */
  74708. export var linePixelShader: {
  74709. name: string;
  74710. shader: string;
  74711. };
  74712. }
  74713. declare module BABYLON {
  74714. /** @hidden */
  74715. export var lineVertexShader: {
  74716. name: string;
  74717. shader: string;
  74718. };
  74719. }
  74720. declare module BABYLON {
  74721. interface AbstractMesh {
  74722. /**
  74723. * Disables the mesh edge rendering mode
  74724. * @returns the currentAbstractMesh
  74725. */
  74726. disableEdgesRendering(): AbstractMesh;
  74727. /**
  74728. * Enables the edge rendering mode on the mesh.
  74729. * This mode makes the mesh edges visible
  74730. * @param epsilon defines the maximal distance between two angles to detect a face
  74731. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74732. * @returns the currentAbstractMesh
  74733. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74734. */
  74735. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74736. /**
  74737. * Gets the edgesRenderer associated with the mesh
  74738. */
  74739. edgesRenderer: Nullable<EdgesRenderer>;
  74740. }
  74741. interface LinesMesh {
  74742. /**
  74743. * Enables the edge rendering mode on the mesh.
  74744. * This mode makes the mesh edges visible
  74745. * @param epsilon defines the maximal distance between two angles to detect a face
  74746. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74747. * @returns the currentAbstractMesh
  74748. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74749. */
  74750. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74751. }
  74752. interface InstancedLinesMesh {
  74753. /**
  74754. * Enables the edge rendering mode on the mesh.
  74755. * This mode makes the mesh edges visible
  74756. * @param epsilon defines the maximal distance between two angles to detect a face
  74757. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74758. * @returns the current InstancedLinesMesh
  74759. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74760. */
  74761. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74762. }
  74763. /**
  74764. * Defines the minimum contract an Edges renderer should follow.
  74765. */
  74766. export interface IEdgesRenderer extends IDisposable {
  74767. /**
  74768. * Gets or sets a boolean indicating if the edgesRenderer is active
  74769. */
  74770. isEnabled: boolean;
  74771. /**
  74772. * Renders the edges of the attached mesh,
  74773. */
  74774. render(): void;
  74775. /**
  74776. * Checks wether or not the edges renderer is ready to render.
  74777. * @return true if ready, otherwise false.
  74778. */
  74779. isReady(): boolean;
  74780. }
  74781. /**
  74782. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74783. */
  74784. export class EdgesRenderer implements IEdgesRenderer {
  74785. /**
  74786. * Define the size of the edges with an orthographic camera
  74787. */
  74788. edgesWidthScalerForOrthographic: number;
  74789. /**
  74790. * Define the size of the edges with a perspective camera
  74791. */
  74792. edgesWidthScalerForPerspective: number;
  74793. protected _source: AbstractMesh;
  74794. protected _linesPositions: number[];
  74795. protected _linesNormals: number[];
  74796. protected _linesIndices: number[];
  74797. protected _epsilon: number;
  74798. protected _indicesCount: number;
  74799. protected _lineShader: ShaderMaterial;
  74800. protected _ib: WebGLBuffer;
  74801. protected _buffers: {
  74802. [key: string]: Nullable<VertexBuffer>;
  74803. };
  74804. protected _checkVerticesInsteadOfIndices: boolean;
  74805. private _meshRebuildObserver;
  74806. private _meshDisposeObserver;
  74807. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74808. isEnabled: boolean;
  74809. /**
  74810. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74811. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74812. * @param source Mesh used to create edges
  74813. * @param epsilon sum of angles in adjacency to check for edge
  74814. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74815. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74816. */
  74817. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74818. protected _prepareRessources(): void;
  74819. /** @hidden */
  74820. _rebuild(): void;
  74821. /**
  74822. * Releases the required resources for the edges renderer
  74823. */
  74824. dispose(): void;
  74825. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74826. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74827. /**
  74828. * Checks if the pair of p0 and p1 is en edge
  74829. * @param faceIndex
  74830. * @param edge
  74831. * @param faceNormals
  74832. * @param p0
  74833. * @param p1
  74834. * @private
  74835. */
  74836. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74837. /**
  74838. * push line into the position, normal and index buffer
  74839. * @protected
  74840. */
  74841. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74842. /**
  74843. * Generates lines edges from adjacencjes
  74844. * @private
  74845. */
  74846. _generateEdgesLines(): void;
  74847. /**
  74848. * Checks wether or not the edges renderer is ready to render.
  74849. * @return true if ready, otherwise false.
  74850. */
  74851. isReady(): boolean;
  74852. /**
  74853. * Renders the edges of the attached mesh,
  74854. */
  74855. render(): void;
  74856. }
  74857. /**
  74858. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74859. */
  74860. export class LineEdgesRenderer extends EdgesRenderer {
  74861. /**
  74862. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74863. * @param source LineMesh used to generate edges
  74864. * @param epsilon not important (specified angle for edge detection)
  74865. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74866. */
  74867. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74868. /**
  74869. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74870. */
  74871. _generateEdgesLines(): void;
  74872. }
  74873. }
  74874. declare module BABYLON {
  74875. /**
  74876. * This represents the object necessary to create a rendering group.
  74877. * This is exclusively used and created by the rendering manager.
  74878. * To modify the behavior, you use the available helpers in your scene or meshes.
  74879. * @hidden
  74880. */
  74881. export class RenderingGroup {
  74882. index: number;
  74883. private _scene;
  74884. private _opaqueSubMeshes;
  74885. private _transparentSubMeshes;
  74886. private _alphaTestSubMeshes;
  74887. private _depthOnlySubMeshes;
  74888. private _particleSystems;
  74889. private _spriteManagers;
  74890. private _opaqueSortCompareFn;
  74891. private _alphaTestSortCompareFn;
  74892. private _transparentSortCompareFn;
  74893. private _renderOpaque;
  74894. private _renderAlphaTest;
  74895. private _renderTransparent;
  74896. private _edgesRenderers;
  74897. onBeforeTransparentRendering: () => void;
  74898. /**
  74899. * Set the opaque sort comparison function.
  74900. * If null the sub meshes will be render in the order they were created
  74901. */
  74902. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74903. /**
  74904. * Set the alpha test sort comparison function.
  74905. * If null the sub meshes will be render in the order they were created
  74906. */
  74907. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74908. /**
  74909. * Set the transparent sort comparison function.
  74910. * If null the sub meshes will be render in the order they were created
  74911. */
  74912. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74913. /**
  74914. * Creates a new rendering group.
  74915. * @param index The rendering group index
  74916. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74917. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74918. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74919. */
  74920. 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>);
  74921. /**
  74922. * Render all the sub meshes contained in the group.
  74923. * @param customRenderFunction Used to override the default render behaviour of the group.
  74924. * @returns true if rendered some submeshes.
  74925. */
  74926. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74927. /**
  74928. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74929. * @param subMeshes The submeshes to render
  74930. */
  74931. private renderOpaqueSorted;
  74932. /**
  74933. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74934. * @param subMeshes The submeshes to render
  74935. */
  74936. private renderAlphaTestSorted;
  74937. /**
  74938. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74939. * @param subMeshes The submeshes to render
  74940. */
  74941. private renderTransparentSorted;
  74942. /**
  74943. * Renders the submeshes in a specified order.
  74944. * @param subMeshes The submeshes to sort before render
  74945. * @param sortCompareFn The comparison function use to sort
  74946. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74947. * @param transparent Specifies to activate blending if true
  74948. */
  74949. private static renderSorted;
  74950. /**
  74951. * Renders the submeshes in the order they were dispatched (no sort applied).
  74952. * @param subMeshes The submeshes to render
  74953. */
  74954. private static renderUnsorted;
  74955. /**
  74956. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74957. * are rendered back to front if in the same alpha index.
  74958. *
  74959. * @param a The first submesh
  74960. * @param b The second submesh
  74961. * @returns The result of the comparison
  74962. */
  74963. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74964. /**
  74965. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74966. * are rendered back to front.
  74967. *
  74968. * @param a The first submesh
  74969. * @param b The second submesh
  74970. * @returns The result of the comparison
  74971. */
  74972. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74973. /**
  74974. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74975. * are rendered front to back (prevent overdraw).
  74976. *
  74977. * @param a The first submesh
  74978. * @param b The second submesh
  74979. * @returns The result of the comparison
  74980. */
  74981. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74982. /**
  74983. * Resets the different lists of submeshes to prepare a new frame.
  74984. */
  74985. prepare(): void;
  74986. dispose(): void;
  74987. /**
  74988. * Inserts the submesh in its correct queue depending on its material.
  74989. * @param subMesh The submesh to dispatch
  74990. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74991. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74992. */
  74993. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74994. dispatchSprites(spriteManager: ISpriteManager): void;
  74995. dispatchParticles(particleSystem: IParticleSystem): void;
  74996. private _renderParticles;
  74997. private _renderSprites;
  74998. }
  74999. }
  75000. declare module BABYLON {
  75001. /**
  75002. * Interface describing the different options available in the rendering manager
  75003. * regarding Auto Clear between groups.
  75004. */
  75005. export interface IRenderingManagerAutoClearSetup {
  75006. /**
  75007. * Defines whether or not autoclear is enable.
  75008. */
  75009. autoClear: boolean;
  75010. /**
  75011. * Defines whether or not to autoclear the depth buffer.
  75012. */
  75013. depth: boolean;
  75014. /**
  75015. * Defines whether or not to autoclear the stencil buffer.
  75016. */
  75017. stencil: boolean;
  75018. }
  75019. /**
  75020. * This class is used by the onRenderingGroupObservable
  75021. */
  75022. export class RenderingGroupInfo {
  75023. /**
  75024. * The Scene that being rendered
  75025. */
  75026. scene: Scene;
  75027. /**
  75028. * The camera currently used for the rendering pass
  75029. */
  75030. camera: Nullable<Camera>;
  75031. /**
  75032. * The ID of the renderingGroup being processed
  75033. */
  75034. renderingGroupId: number;
  75035. }
  75036. /**
  75037. * This is the manager responsible of all the rendering for meshes sprites and particles.
  75038. * It is enable to manage the different groups as well as the different necessary sort functions.
  75039. * This should not be used directly aside of the few static configurations
  75040. */
  75041. export class RenderingManager {
  75042. /**
  75043. * The max id used for rendering groups (not included)
  75044. */
  75045. static MAX_RENDERINGGROUPS: number;
  75046. /**
  75047. * The min id used for rendering groups (included)
  75048. */
  75049. static MIN_RENDERINGGROUPS: number;
  75050. /**
  75051. * Used to globally prevent autoclearing scenes.
  75052. */
  75053. static AUTOCLEAR: boolean;
  75054. /**
  75055. * @hidden
  75056. */
  75057. _useSceneAutoClearSetup: boolean;
  75058. private _scene;
  75059. private _renderingGroups;
  75060. private _depthStencilBufferAlreadyCleaned;
  75061. private _autoClearDepthStencil;
  75062. private _customOpaqueSortCompareFn;
  75063. private _customAlphaTestSortCompareFn;
  75064. private _customTransparentSortCompareFn;
  75065. private _renderingGroupInfo;
  75066. /**
  75067. * Instantiates a new rendering group for a particular scene
  75068. * @param scene Defines the scene the groups belongs to
  75069. */
  75070. constructor(scene: Scene);
  75071. private _clearDepthStencilBuffer;
  75072. /**
  75073. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  75074. * @hidden
  75075. */
  75076. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  75077. /**
  75078. * Resets the different information of the group to prepare a new frame
  75079. * @hidden
  75080. */
  75081. reset(): void;
  75082. /**
  75083. * Dispose and release the group and its associated resources.
  75084. * @hidden
  75085. */
  75086. dispose(): void;
  75087. /**
  75088. * Clear the info related to rendering groups preventing retention points during dispose.
  75089. */
  75090. freeRenderingGroups(): void;
  75091. private _prepareRenderingGroup;
  75092. /**
  75093. * Add a sprite manager to the rendering manager in order to render it this frame.
  75094. * @param spriteManager Define the sprite manager to render
  75095. */
  75096. dispatchSprites(spriteManager: ISpriteManager): void;
  75097. /**
  75098. * Add a particle system to the rendering manager in order to render it this frame.
  75099. * @param particleSystem Define the particle system to render
  75100. */
  75101. dispatchParticles(particleSystem: IParticleSystem): void;
  75102. /**
  75103. * Add a submesh to the manager in order to render it this frame
  75104. * @param subMesh The submesh to dispatch
  75105. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75106. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75107. */
  75108. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75109. /**
  75110. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75111. * This allowed control for front to back rendering or reversly depending of the special needs.
  75112. *
  75113. * @param renderingGroupId The rendering group id corresponding to its index
  75114. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75115. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75116. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75117. */
  75118. 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;
  75119. /**
  75120. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75121. *
  75122. * @param renderingGroupId The rendering group id corresponding to its index
  75123. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75124. * @param depth Automatically clears depth between groups if true and autoClear is true.
  75125. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  75126. */
  75127. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  75128. /**
  75129. * Gets the current auto clear configuration for one rendering group of the rendering
  75130. * manager.
  75131. * @param index the rendering group index to get the information for
  75132. * @returns The auto clear setup for the requested rendering group
  75133. */
  75134. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  75135. }
  75136. }
  75137. declare module BABYLON {
  75138. /**
  75139. * This Helps creating a texture that will be created from a camera in your scene.
  75140. * It is basically a dynamic texture that could be used to create special effects for instance.
  75141. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  75142. */
  75143. export class RenderTargetTexture extends Texture {
  75144. isCube: boolean;
  75145. /**
  75146. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  75147. */
  75148. static readonly REFRESHRATE_RENDER_ONCE: number;
  75149. /**
  75150. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  75151. */
  75152. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  75153. /**
  75154. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  75155. * the central point of your effect and can save a lot of performances.
  75156. */
  75157. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  75158. /**
  75159. * Use this predicate to dynamically define the list of mesh you want to render.
  75160. * If set, the renderList property will be overwritten.
  75161. */
  75162. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  75163. private _renderList;
  75164. /**
  75165. * Use this list to define the list of mesh you want to render.
  75166. */
  75167. renderList: Nullable<Array<AbstractMesh>>;
  75168. private _hookArray;
  75169. /**
  75170. * Define if particles should be rendered in your texture.
  75171. */
  75172. renderParticles: boolean;
  75173. /**
  75174. * Define if sprites should be rendered in your texture.
  75175. */
  75176. renderSprites: boolean;
  75177. /**
  75178. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  75179. */
  75180. coordinatesMode: number;
  75181. /**
  75182. * Define the camera used to render the texture.
  75183. */
  75184. activeCamera: Nullable<Camera>;
  75185. /**
  75186. * Override the render function of the texture with your own one.
  75187. */
  75188. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  75189. /**
  75190. * Define if camera post processes should be use while rendering the texture.
  75191. */
  75192. useCameraPostProcesses: boolean;
  75193. /**
  75194. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  75195. */
  75196. ignoreCameraViewport: boolean;
  75197. private _postProcessManager;
  75198. private _postProcesses;
  75199. private _resizeObserver;
  75200. /**
  75201. * An event triggered when the texture is unbind.
  75202. */
  75203. onBeforeBindObservable: Observable<RenderTargetTexture>;
  75204. /**
  75205. * An event triggered when the texture is unbind.
  75206. */
  75207. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  75208. private _onAfterUnbindObserver;
  75209. /**
  75210. * Set a after unbind callback in the texture.
  75211. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  75212. */
  75213. onAfterUnbind: () => void;
  75214. /**
  75215. * An event triggered before rendering the texture
  75216. */
  75217. onBeforeRenderObservable: Observable<number>;
  75218. private _onBeforeRenderObserver;
  75219. /**
  75220. * Set a before render callback in the texture.
  75221. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  75222. */
  75223. onBeforeRender: (faceIndex: number) => void;
  75224. /**
  75225. * An event triggered after rendering the texture
  75226. */
  75227. onAfterRenderObservable: Observable<number>;
  75228. private _onAfterRenderObserver;
  75229. /**
  75230. * Set a after render callback in the texture.
  75231. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  75232. */
  75233. onAfterRender: (faceIndex: number) => void;
  75234. /**
  75235. * An event triggered after the texture clear
  75236. */
  75237. onClearObservable: Observable<Engine>;
  75238. private _onClearObserver;
  75239. /**
  75240. * Set a clear callback in the texture.
  75241. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  75242. */
  75243. onClear: (Engine: Engine) => void;
  75244. /**
  75245. * Define the clear color of the Render Target if it should be different from the scene.
  75246. */
  75247. clearColor: Color4;
  75248. protected _size: number | {
  75249. width: number;
  75250. height: number;
  75251. };
  75252. protected _initialSizeParameter: number | {
  75253. width: number;
  75254. height: number;
  75255. } | {
  75256. ratio: number;
  75257. };
  75258. protected _sizeRatio: Nullable<number>;
  75259. /** @hidden */
  75260. _generateMipMaps: boolean;
  75261. protected _renderingManager: RenderingManager;
  75262. /** @hidden */
  75263. _waitingRenderList: string[];
  75264. protected _doNotChangeAspectRatio: boolean;
  75265. protected _currentRefreshId: number;
  75266. protected _refreshRate: number;
  75267. protected _textureMatrix: Matrix;
  75268. protected _samples: number;
  75269. protected _renderTargetOptions: RenderTargetCreationOptions;
  75270. /**
  75271. * Gets render target creation options that were used.
  75272. */
  75273. readonly renderTargetOptions: RenderTargetCreationOptions;
  75274. protected _engine: Engine;
  75275. protected _onRatioRescale(): void;
  75276. /**
  75277. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  75278. * It must define where the camera used to render the texture is set
  75279. */
  75280. boundingBoxPosition: Vector3;
  75281. private _boundingBoxSize;
  75282. /**
  75283. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  75284. * When defined, the cubemap will switch to local mode
  75285. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75286. * @example https://www.babylonjs-playground.com/#RNASML
  75287. */
  75288. boundingBoxSize: Vector3;
  75289. /**
  75290. * In case the RTT has been created with a depth texture, get the associated
  75291. * depth texture.
  75292. * Otherwise, return null.
  75293. */
  75294. depthStencilTexture: Nullable<InternalTexture>;
  75295. /**
  75296. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  75297. * or used a shadow, depth texture...
  75298. * @param name The friendly name of the texture
  75299. * @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)
  75300. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  75301. * @param generateMipMaps True if mip maps need to be generated after render.
  75302. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  75303. * @param type The type of the buffer in the RTT (int, half float, float...)
  75304. * @param isCube True if a cube texture needs to be created
  75305. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  75306. * @param generateDepthBuffer True to generate a depth buffer
  75307. * @param generateStencilBuffer True to generate a stencil buffer
  75308. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  75309. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  75310. * @param delayAllocation if the texture allocation should be delayed (default: false)
  75311. */
  75312. constructor(name: string, size: number | {
  75313. width: number;
  75314. height: number;
  75315. } | {
  75316. ratio: number;
  75317. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  75318. /**
  75319. * Creates a depth stencil texture.
  75320. * This is only available in WebGL 2 or with the depth texture extension available.
  75321. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  75322. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  75323. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  75324. */
  75325. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  75326. private _processSizeParameter;
  75327. /**
  75328. * Define the number of samples to use in case of MSAA.
  75329. * It defaults to one meaning no MSAA has been enabled.
  75330. */
  75331. samples: number;
  75332. /**
  75333. * Resets the refresh counter of the texture and start bak from scratch.
  75334. * Could be useful to regenerate the texture if it is setup to render only once.
  75335. */
  75336. resetRefreshCounter(): void;
  75337. /**
  75338. * Define the refresh rate of the texture or the rendering frequency.
  75339. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  75340. */
  75341. refreshRate: number;
  75342. /**
  75343. * Adds a post process to the render target rendering passes.
  75344. * @param postProcess define the post process to add
  75345. */
  75346. addPostProcess(postProcess: PostProcess): void;
  75347. /**
  75348. * Clear all the post processes attached to the render target
  75349. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75350. */
  75351. clearPostProcesses(dispose?: boolean): void;
  75352. /**
  75353. * Remove one of the post process from the list of attached post processes to the texture
  75354. * @param postProcess define the post process to remove from the list
  75355. */
  75356. removePostProcess(postProcess: PostProcess): void;
  75357. /** @hidden */
  75358. _shouldRender(): boolean;
  75359. /**
  75360. * Gets the actual render size of the texture.
  75361. * @returns the width of the render size
  75362. */
  75363. getRenderSize(): number;
  75364. /**
  75365. * Gets the actual render width of the texture.
  75366. * @returns the width of the render size
  75367. */
  75368. getRenderWidth(): number;
  75369. /**
  75370. * Gets the actual render height of the texture.
  75371. * @returns the height of the render size
  75372. */
  75373. getRenderHeight(): number;
  75374. /**
  75375. * Get if the texture can be rescaled or not.
  75376. */
  75377. readonly canRescale: boolean;
  75378. /**
  75379. * Resize the texture using a ratio.
  75380. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75381. */
  75382. scale(ratio: number): void;
  75383. /**
  75384. * Get the texture reflection matrix used to rotate/transform the reflection.
  75385. * @returns the reflection matrix
  75386. */
  75387. getReflectionTextureMatrix(): Matrix;
  75388. /**
  75389. * Resize the texture to a new desired size.
  75390. * Be carrefull as it will recreate all the data in the new texture.
  75391. * @param size Define the new size. It can be:
  75392. * - a number for squared texture,
  75393. * - an object containing { width: number, height: number }
  75394. * - or an object containing a ratio { ratio: number }
  75395. */
  75396. resize(size: number | {
  75397. width: number;
  75398. height: number;
  75399. } | {
  75400. ratio: number;
  75401. }): void;
  75402. /**
  75403. * Renders all the objects from the render list into the texture.
  75404. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75405. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75406. */
  75407. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75408. private _bestReflectionRenderTargetDimension;
  75409. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75410. private renderToTarget;
  75411. /**
  75412. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75413. * This allowed control for front to back rendering or reversly depending of the special needs.
  75414. *
  75415. * @param renderingGroupId The rendering group id corresponding to its index
  75416. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75417. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75418. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75419. */
  75420. 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;
  75421. /**
  75422. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75423. *
  75424. * @param renderingGroupId The rendering group id corresponding to its index
  75425. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75426. */
  75427. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  75428. /**
  75429. * Clones the texture.
  75430. * @returns the cloned texture
  75431. */
  75432. clone(): RenderTargetTexture;
  75433. /**
  75434. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75435. * @returns The JSON representation of the texture
  75436. */
  75437. serialize(): any;
  75438. /**
  75439. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  75440. */
  75441. disposeFramebufferObjects(): void;
  75442. /**
  75443. * Dispose the texture and release its associated resources.
  75444. */
  75445. dispose(): void;
  75446. /** @hidden */
  75447. _rebuild(): void;
  75448. /**
  75449. * Clear the info related to rendering groups preventing retention point in material dispose.
  75450. */
  75451. freeRenderingGroups(): void;
  75452. }
  75453. }
  75454. declare module BABYLON {
  75455. /**
  75456. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75457. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75458. * You can then easily use it as a reflectionTexture on a flat surface.
  75459. * In case the surface is not a plane, please consider relying on reflection probes.
  75460. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75461. */
  75462. export class MirrorTexture extends RenderTargetTexture {
  75463. private scene;
  75464. /**
  75465. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  75466. * 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.
  75467. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75468. */
  75469. mirrorPlane: Plane;
  75470. /**
  75471. * Define the blur ratio used to blur the reflection if needed.
  75472. */
  75473. blurRatio: number;
  75474. /**
  75475. * Define the adaptive blur kernel used to blur the reflection if needed.
  75476. * This will autocompute the closest best match for the `blurKernel`
  75477. */
  75478. adaptiveBlurKernel: number;
  75479. /**
  75480. * Define the blur kernel used to blur the reflection if needed.
  75481. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75482. */
  75483. blurKernel: number;
  75484. /**
  75485. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  75486. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75487. */
  75488. blurKernelX: number;
  75489. /**
  75490. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  75491. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75492. */
  75493. blurKernelY: number;
  75494. private _autoComputeBlurKernel;
  75495. protected _onRatioRescale(): void;
  75496. private _updateGammaSpace;
  75497. private _imageProcessingConfigChangeObserver;
  75498. private _transformMatrix;
  75499. private _mirrorMatrix;
  75500. private _savedViewMatrix;
  75501. private _blurX;
  75502. private _blurY;
  75503. private _adaptiveBlurKernel;
  75504. private _blurKernelX;
  75505. private _blurKernelY;
  75506. private _blurRatio;
  75507. /**
  75508. * Instantiates a Mirror Texture.
  75509. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75510. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75511. * You can then easily use it as a reflectionTexture on a flat surface.
  75512. * In case the surface is not a plane, please consider relying on reflection probes.
  75513. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75514. * @param name
  75515. * @param size
  75516. * @param scene
  75517. * @param generateMipMaps
  75518. * @param type
  75519. * @param samplingMode
  75520. * @param generateDepthBuffer
  75521. */
  75522. constructor(name: string, size: number | {
  75523. width: number;
  75524. height: number;
  75525. } | {
  75526. ratio: number;
  75527. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  75528. private _preparePostProcesses;
  75529. /**
  75530. * Clone the mirror texture.
  75531. * @returns the cloned texture
  75532. */
  75533. clone(): MirrorTexture;
  75534. /**
  75535. * Serialize the texture to a JSON representation you could use in Parse later on
  75536. * @returns the serialized JSON representation
  75537. */
  75538. serialize(): any;
  75539. /**
  75540. * Dispose the texture and release its associated resources.
  75541. */
  75542. dispose(): void;
  75543. }
  75544. }
  75545. declare module BABYLON {
  75546. /**
  75547. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75548. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75549. */
  75550. export class Texture extends BaseTexture {
  75551. /** @hidden */
  75552. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  75553. /** @hidden */
  75554. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  75555. /** @hidden */
  75556. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  75557. /** nearest is mag = nearest and min = nearest and mip = linear */
  75558. static readonly NEAREST_SAMPLINGMODE: number;
  75559. /** nearest is mag = nearest and min = nearest and mip = linear */
  75560. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  75561. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75562. static readonly BILINEAR_SAMPLINGMODE: number;
  75563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75564. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  75565. /** Trilinear is mag = linear and min = linear and mip = linear */
  75566. static readonly TRILINEAR_SAMPLINGMODE: number;
  75567. /** Trilinear is mag = linear and min = linear and mip = linear */
  75568. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  75569. /** mag = nearest and min = nearest and mip = nearest */
  75570. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  75571. /** mag = nearest and min = linear and mip = nearest */
  75572. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75573. /** mag = nearest and min = linear and mip = linear */
  75574. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75575. /** mag = nearest and min = linear and mip = none */
  75576. static readonly NEAREST_LINEAR: number;
  75577. /** mag = nearest and min = nearest and mip = none */
  75578. static readonly NEAREST_NEAREST: number;
  75579. /** mag = linear and min = nearest and mip = nearest */
  75580. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75581. /** mag = linear and min = nearest and mip = linear */
  75582. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75583. /** mag = linear and min = linear and mip = none */
  75584. static readonly LINEAR_LINEAR: number;
  75585. /** mag = linear and min = nearest and mip = none */
  75586. static readonly LINEAR_NEAREST: number;
  75587. /** Explicit coordinates mode */
  75588. static readonly EXPLICIT_MODE: number;
  75589. /** Spherical coordinates mode */
  75590. static readonly SPHERICAL_MODE: number;
  75591. /** Planar coordinates mode */
  75592. static readonly PLANAR_MODE: number;
  75593. /** Cubic coordinates mode */
  75594. static readonly CUBIC_MODE: number;
  75595. /** Projection coordinates mode */
  75596. static readonly PROJECTION_MODE: number;
  75597. /** Inverse Cubic coordinates mode */
  75598. static readonly SKYBOX_MODE: number;
  75599. /** Inverse Cubic coordinates mode */
  75600. static readonly INVCUBIC_MODE: number;
  75601. /** Equirectangular coordinates mode */
  75602. static readonly EQUIRECTANGULAR_MODE: number;
  75603. /** Equirectangular Fixed coordinates mode */
  75604. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75605. /** Equirectangular Fixed Mirrored coordinates mode */
  75606. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75607. /** Texture is not repeating outside of 0..1 UVs */
  75608. static readonly CLAMP_ADDRESSMODE: number;
  75609. /** Texture is repeating outside of 0..1 UVs */
  75610. static readonly WRAP_ADDRESSMODE: number;
  75611. /** Texture is repeating and mirrored */
  75612. static readonly MIRROR_ADDRESSMODE: number;
  75613. /**
  75614. * 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
  75615. */
  75616. static UseSerializedUrlIfAny: boolean;
  75617. /**
  75618. * Define the url of the texture.
  75619. */
  75620. url: Nullable<string>;
  75621. /**
  75622. * Define an offset on the texture to offset the u coordinates of the UVs
  75623. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75624. */
  75625. uOffset: number;
  75626. /**
  75627. * Define an offset on the texture to offset the v coordinates of the UVs
  75628. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75629. */
  75630. vOffset: number;
  75631. /**
  75632. * Define an offset on the texture to scale the u coordinates of the UVs
  75633. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75634. */
  75635. uScale: number;
  75636. /**
  75637. * Define an offset on the texture to scale the v coordinates of the UVs
  75638. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75639. */
  75640. vScale: number;
  75641. /**
  75642. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75643. * @see http://doc.babylonjs.com/how_to/more_materials
  75644. */
  75645. uAng: number;
  75646. /**
  75647. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75648. * @see http://doc.babylonjs.com/how_to/more_materials
  75649. */
  75650. vAng: number;
  75651. /**
  75652. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75653. * @see http://doc.babylonjs.com/how_to/more_materials
  75654. */
  75655. wAng: number;
  75656. /**
  75657. * Defines the center of rotation (U)
  75658. */
  75659. uRotationCenter: number;
  75660. /**
  75661. * Defines the center of rotation (V)
  75662. */
  75663. vRotationCenter: number;
  75664. /**
  75665. * Defines the center of rotation (W)
  75666. */
  75667. wRotationCenter: number;
  75668. /**
  75669. * Are mip maps generated for this texture or not.
  75670. */
  75671. readonly noMipmap: boolean;
  75672. private _noMipmap;
  75673. /** @hidden */
  75674. _invertY: boolean;
  75675. private _rowGenerationMatrix;
  75676. private _cachedTextureMatrix;
  75677. private _projectionModeMatrix;
  75678. private _t0;
  75679. private _t1;
  75680. private _t2;
  75681. private _cachedUOffset;
  75682. private _cachedVOffset;
  75683. private _cachedUScale;
  75684. private _cachedVScale;
  75685. private _cachedUAng;
  75686. private _cachedVAng;
  75687. private _cachedWAng;
  75688. private _cachedProjectionMatrixId;
  75689. private _cachedCoordinatesMode;
  75690. /** @hidden */
  75691. protected _initialSamplingMode: number;
  75692. /** @hidden */
  75693. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75694. private _deleteBuffer;
  75695. protected _format: Nullable<number>;
  75696. private _delayedOnLoad;
  75697. private _delayedOnError;
  75698. /**
  75699. * Observable triggered once the texture has been loaded.
  75700. */
  75701. onLoadObservable: Observable<Texture>;
  75702. protected _isBlocking: boolean;
  75703. /**
  75704. * Is the texture preventing material to render while loading.
  75705. * If false, a default texture will be used instead of the loading one during the preparation step.
  75706. */
  75707. isBlocking: boolean;
  75708. /**
  75709. * Get the current sampling mode associated with the texture.
  75710. */
  75711. readonly samplingMode: number;
  75712. /**
  75713. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75714. */
  75715. readonly invertY: boolean;
  75716. /**
  75717. * Instantiates a new texture.
  75718. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75719. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75720. * @param url define the url of the picture to load as a texture
  75721. * @param scene define the scene the texture will belong to
  75722. * @param noMipmap define if the texture will require mip maps or not
  75723. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75724. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75725. * @param onLoad define a callback triggered when the texture has been loaded
  75726. * @param onError define a callback triggered when an error occurred during the loading session
  75727. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75728. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75729. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75730. */
  75731. 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);
  75732. /**
  75733. * Update the url (and optional buffer) of this texture if url was null during construction.
  75734. * @param url the url of the texture
  75735. * @param buffer the buffer of the texture (defaults to null)
  75736. * @param onLoad callback called when the texture is loaded (defaults to null)
  75737. */
  75738. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75739. /**
  75740. * Finish the loading sequence of a texture flagged as delayed load.
  75741. * @hidden
  75742. */
  75743. delayLoad(): void;
  75744. private _prepareRowForTextureGeneration;
  75745. /**
  75746. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75747. * @returns the transform matrix of the texture.
  75748. */
  75749. getTextureMatrix(): Matrix;
  75750. /**
  75751. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75752. * @returns The reflection texture transform
  75753. */
  75754. getReflectionTextureMatrix(): Matrix;
  75755. /**
  75756. * Clones the texture.
  75757. * @returns the cloned texture
  75758. */
  75759. clone(): Texture;
  75760. /**
  75761. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75762. * @returns The JSON representation of the texture
  75763. */
  75764. serialize(): any;
  75765. /**
  75766. * Get the current class name of the texture useful for serialization or dynamic coding.
  75767. * @returns "Texture"
  75768. */
  75769. getClassName(): string;
  75770. /**
  75771. * Dispose the texture and release its associated resources.
  75772. */
  75773. dispose(): void;
  75774. /**
  75775. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75776. * @param parsedTexture Define the JSON representation of the texture
  75777. * @param scene Define the scene the parsed texture should be instantiated in
  75778. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75779. * @returns The parsed texture if successful
  75780. */
  75781. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75782. /**
  75783. * Creates a texture from its base 64 representation.
  75784. * @param data Define the base64 payload without the data: prefix
  75785. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75786. * @param scene Define the scene the texture should belong to
  75787. * @param noMipmap Forces the texture to not create mip map information if true
  75788. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75789. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75790. * @param onLoad define a callback triggered when the texture has been loaded
  75791. * @param onError define a callback triggered when an error occurred during the loading session
  75792. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75793. * @returns the created texture
  75794. */
  75795. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75796. /**
  75797. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75798. * @param data Define the base64 payload without the data: prefix
  75799. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75800. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75801. * @param scene Define the scene the texture should belong to
  75802. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75803. * @param noMipmap Forces the texture to not create mip map information if true
  75804. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75805. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75806. * @param onLoad define a callback triggered when the texture has been loaded
  75807. * @param onError define a callback triggered when an error occurred during the loading session
  75808. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75809. * @returns the created texture
  75810. */
  75811. 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;
  75812. }
  75813. }
  75814. declare module BABYLON {
  75815. /**
  75816. * Raw texture can help creating a texture directly from an array of data.
  75817. * This can be super useful if you either get the data from an uncompressed source or
  75818. * if you wish to create your texture pixel by pixel.
  75819. */
  75820. export class RawTexture extends Texture {
  75821. /**
  75822. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75823. */
  75824. format: number;
  75825. private _engine;
  75826. /**
  75827. * Instantiates a new RawTexture.
  75828. * Raw texture can help creating a texture directly from an array of data.
  75829. * This can be super useful if you either get the data from an uncompressed source or
  75830. * if you wish to create your texture pixel by pixel.
  75831. * @param data define the array of data to use to create the texture
  75832. * @param width define the width of the texture
  75833. * @param height define the height of the texture
  75834. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75835. * @param scene define the scene the texture belongs to
  75836. * @param generateMipMaps define whether mip maps should be generated or not
  75837. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75838. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75839. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75840. */
  75841. constructor(data: ArrayBufferView, width: number, height: number,
  75842. /**
  75843. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75844. */
  75845. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75846. /**
  75847. * Updates the texture underlying data.
  75848. * @param data Define the new data of the texture
  75849. */
  75850. update(data: ArrayBufferView): void;
  75851. /**
  75852. * Creates a luminance texture from some data.
  75853. * @param data Define the texture data
  75854. * @param width Define the width of the texture
  75855. * @param height Define the height of the texture
  75856. * @param scene Define the scene the texture belongs to
  75857. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75858. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75859. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75860. * @returns the luminance texture
  75861. */
  75862. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75863. /**
  75864. * Creates a luminance alpha texture from some data.
  75865. * @param data Define the texture data
  75866. * @param width Define the width of the texture
  75867. * @param height Define the height of the texture
  75868. * @param scene Define the scene the texture belongs to
  75869. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75870. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75871. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75872. * @returns the luminance alpha texture
  75873. */
  75874. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75875. /**
  75876. * Creates an alpha texture from some data.
  75877. * @param data Define the texture data
  75878. * @param width Define the width of the texture
  75879. * @param height Define the height of the texture
  75880. * @param scene Define the scene the texture belongs to
  75881. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75882. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75883. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75884. * @returns the alpha texture
  75885. */
  75886. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75887. /**
  75888. * Creates a RGB texture from some data.
  75889. * @param data Define the texture data
  75890. * @param width Define the width of the texture
  75891. * @param height Define the height of the texture
  75892. * @param scene Define the scene the texture belongs to
  75893. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75894. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75895. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75896. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75897. * @returns the RGB alpha texture
  75898. */
  75899. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75900. /**
  75901. * Creates a RGBA texture from some data.
  75902. * @param data Define the texture data
  75903. * @param width Define the width of the texture
  75904. * @param height Define the height of the texture
  75905. * @param scene Define the scene the texture belongs to
  75906. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75907. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75908. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75909. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75910. * @returns the RGBA texture
  75911. */
  75912. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75913. /**
  75914. * Creates a R texture from some data.
  75915. * @param data Define the texture data
  75916. * @param width Define the width of the texture
  75917. * @param height Define the height of the texture
  75918. * @param scene Define the scene the texture belongs to
  75919. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75920. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75921. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75922. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75923. * @returns the R texture
  75924. */
  75925. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75926. }
  75927. }
  75928. declare module BABYLON {
  75929. /**
  75930. * Defines a runtime animation
  75931. */
  75932. export class RuntimeAnimation {
  75933. private _events;
  75934. /**
  75935. * The current frame of the runtime animation
  75936. */
  75937. private _currentFrame;
  75938. /**
  75939. * The animation used by the runtime animation
  75940. */
  75941. private _animation;
  75942. /**
  75943. * The target of the runtime animation
  75944. */
  75945. private _target;
  75946. /**
  75947. * The initiating animatable
  75948. */
  75949. private _host;
  75950. /**
  75951. * The original value of the runtime animation
  75952. */
  75953. private _originalValue;
  75954. /**
  75955. * The original blend value of the runtime animation
  75956. */
  75957. private _originalBlendValue;
  75958. /**
  75959. * The offsets cache of the runtime animation
  75960. */
  75961. private _offsetsCache;
  75962. /**
  75963. * The high limits cache of the runtime animation
  75964. */
  75965. private _highLimitsCache;
  75966. /**
  75967. * Specifies if the runtime animation has been stopped
  75968. */
  75969. private _stopped;
  75970. /**
  75971. * The blending factor of the runtime animation
  75972. */
  75973. private _blendingFactor;
  75974. /**
  75975. * The BabylonJS scene
  75976. */
  75977. private _scene;
  75978. /**
  75979. * The current value of the runtime animation
  75980. */
  75981. private _currentValue;
  75982. /** @hidden */
  75983. _workValue: any;
  75984. /**
  75985. * The active target of the runtime animation
  75986. */
  75987. private _activeTarget;
  75988. /**
  75989. * The target path of the runtime animation
  75990. */
  75991. private _targetPath;
  75992. /**
  75993. * The weight of the runtime animation
  75994. */
  75995. private _weight;
  75996. /**
  75997. * The ratio offset of the runtime animation
  75998. */
  75999. private _ratioOffset;
  76000. /**
  76001. * The previous delay of the runtime animation
  76002. */
  76003. private _previousDelay;
  76004. /**
  76005. * The previous ratio of the runtime animation
  76006. */
  76007. private _previousRatio;
  76008. /**
  76009. * Gets the current frame of the runtime animation
  76010. */
  76011. readonly currentFrame: number;
  76012. /**
  76013. * Gets the weight of the runtime animation
  76014. */
  76015. readonly weight: number;
  76016. /**
  76017. * Gets the current value of the runtime animation
  76018. */
  76019. readonly currentValue: any;
  76020. /**
  76021. * Gets the target path of the runtime animation
  76022. */
  76023. readonly targetPath: string;
  76024. /**
  76025. * Gets the actual target of the runtime animation
  76026. */
  76027. readonly target: any;
  76028. /**
  76029. * Create a new RuntimeAnimation object
  76030. * @param target defines the target of the animation
  76031. * @param animation defines the source animation object
  76032. * @param scene defines the hosting scene
  76033. * @param host defines the initiating Animatable
  76034. */
  76035. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76036. /**
  76037. * Gets the animation from the runtime animation
  76038. */
  76039. readonly animation: Animation;
  76040. /**
  76041. * Resets the runtime animation to the beginning
  76042. * @param restoreOriginal defines whether to restore the target property to the original value
  76043. */
  76044. reset(restoreOriginal?: boolean): void;
  76045. /**
  76046. * Specifies if the runtime animation is stopped
  76047. * @returns Boolean specifying if the runtime animation is stopped
  76048. */
  76049. isStopped(): boolean;
  76050. /**
  76051. * Disposes of the runtime animation
  76052. */
  76053. dispose(): void;
  76054. /**
  76055. * Interpolates the animation from the current frame
  76056. * @param currentFrame The frame to interpolate the animation to
  76057. * @param repeatCount The number of times that the animation should loop
  76058. * @param loopMode The type of looping mode to use
  76059. * @param offsetValue Animation offset value
  76060. * @param highLimitValue The high limit value
  76061. * @returns The interpolated value
  76062. */
  76063. private _interpolate;
  76064. /**
  76065. * Apply the interpolated value to the target
  76066. * @param currentValue defines the value computed by the animation
  76067. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76068. */
  76069. setValue(currentValue: any, weight?: number): void;
  76070. private _setValue;
  76071. /**
  76072. * Gets the loop pmode of the runtime animation
  76073. * @returns Loop Mode
  76074. */
  76075. private _getCorrectLoopMode;
  76076. /**
  76077. * Move the current animation to a given frame
  76078. * @param frame defines the frame to move to
  76079. */
  76080. goToFrame(frame: number): void;
  76081. /**
  76082. * @hidden Internal use only
  76083. */
  76084. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76085. /**
  76086. * Execute the current animation
  76087. * @param delay defines the delay to add to the current frame
  76088. * @param from defines the lower bound of the animation range
  76089. * @param to defines the upper bound of the animation range
  76090. * @param loop defines if the current animation must loop
  76091. * @param speedRatio defines the current speed ratio
  76092. * @param weight defines the weight of the animation (default is -1 so no weight)
  76093. * @param onLoop optional callback called when animation loops
  76094. * @returns a boolean indicating if the animation is running
  76095. */
  76096. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  76097. }
  76098. }
  76099. declare module BABYLON {
  76100. /**
  76101. * Class used to store an actual running animation
  76102. */
  76103. export class Animatable {
  76104. /** defines the target object */
  76105. target: any;
  76106. /** defines the starting frame number (default is 0) */
  76107. fromFrame: number;
  76108. /** defines the ending frame number (default is 100) */
  76109. toFrame: number;
  76110. /** defines if the animation must loop (default is false) */
  76111. loopAnimation: boolean;
  76112. /** defines a callback to call when animation ends if it is not looping */
  76113. onAnimationEnd?: (() => void) | null | undefined;
  76114. /** defines a callback to call when animation loops */
  76115. onAnimationLoop?: (() => void) | null | undefined;
  76116. private _localDelayOffset;
  76117. private _pausedDelay;
  76118. private _runtimeAnimations;
  76119. private _paused;
  76120. private _scene;
  76121. private _speedRatio;
  76122. private _weight;
  76123. private _syncRoot;
  76124. /**
  76125. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76126. * This will only apply for non looping animation (default is true)
  76127. */
  76128. disposeOnEnd: boolean;
  76129. /**
  76130. * Gets a boolean indicating if the animation has started
  76131. */
  76132. animationStarted: boolean;
  76133. /**
  76134. * Observer raised when the animation ends
  76135. */
  76136. onAnimationEndObservable: Observable<Animatable>;
  76137. /**
  76138. * Observer raised when the animation loops
  76139. */
  76140. onAnimationLoopObservable: Observable<Animatable>;
  76141. /**
  76142. * Gets the root Animatable used to synchronize and normalize animations
  76143. */
  76144. readonly syncRoot: Animatable;
  76145. /**
  76146. * Gets the current frame of the first RuntimeAnimation
  76147. * Used to synchronize Animatables
  76148. */
  76149. readonly masterFrame: number;
  76150. /**
  76151. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76152. */
  76153. weight: number;
  76154. /**
  76155. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76156. */
  76157. speedRatio: number;
  76158. /**
  76159. * Creates a new Animatable
  76160. * @param scene defines the hosting scene
  76161. * @param target defines the target object
  76162. * @param fromFrame defines the starting frame number (default is 0)
  76163. * @param toFrame defines the ending frame number (default is 100)
  76164. * @param loopAnimation defines if the animation must loop (default is false)
  76165. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76166. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76167. * @param animations defines a group of animation to add to the new Animatable
  76168. * @param onAnimationLoop defines a callback to call when animation loops
  76169. */
  76170. constructor(scene: Scene,
  76171. /** defines the target object */
  76172. target: any,
  76173. /** defines the starting frame number (default is 0) */
  76174. fromFrame?: number,
  76175. /** defines the ending frame number (default is 100) */
  76176. toFrame?: number,
  76177. /** defines if the animation must loop (default is false) */
  76178. loopAnimation?: boolean, speedRatio?: number,
  76179. /** defines a callback to call when animation ends if it is not looping */
  76180. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76181. /** defines a callback to call when animation loops */
  76182. onAnimationLoop?: (() => void) | null | undefined);
  76183. /**
  76184. * Synchronize and normalize current Animatable with a source Animatable
  76185. * This is useful when using animation weights and when animations are not of the same length
  76186. * @param root defines the root Animatable to synchronize with
  76187. * @returns the current Animatable
  76188. */
  76189. syncWith(root: Animatable): Animatable;
  76190. /**
  76191. * Gets the list of runtime animations
  76192. * @returns an array of RuntimeAnimation
  76193. */
  76194. getAnimations(): RuntimeAnimation[];
  76195. /**
  76196. * Adds more animations to the current animatable
  76197. * @param target defines the target of the animations
  76198. * @param animations defines the new animations to add
  76199. */
  76200. appendAnimations(target: any, animations: Animation[]): void;
  76201. /**
  76202. * Gets the source animation for a specific property
  76203. * @param property defines the propertyu to look for
  76204. * @returns null or the source animation for the given property
  76205. */
  76206. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76207. /**
  76208. * Gets the runtime animation for a specific property
  76209. * @param property defines the propertyu to look for
  76210. * @returns null or the runtime animation for the given property
  76211. */
  76212. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76213. /**
  76214. * Resets the animatable to its original state
  76215. */
  76216. reset(): void;
  76217. /**
  76218. * Allows the animatable to blend with current running animations
  76219. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76220. * @param blendingSpeed defines the blending speed to use
  76221. */
  76222. enableBlending(blendingSpeed: number): void;
  76223. /**
  76224. * Disable animation blending
  76225. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76226. */
  76227. disableBlending(): void;
  76228. /**
  76229. * Jump directly to a given frame
  76230. * @param frame defines the frame to jump to
  76231. */
  76232. goToFrame(frame: number): void;
  76233. /**
  76234. * Pause the animation
  76235. */
  76236. pause(): void;
  76237. /**
  76238. * Restart the animation
  76239. */
  76240. restart(): void;
  76241. private _raiseOnAnimationEnd;
  76242. /**
  76243. * Stop and delete the current animation
  76244. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76245. * @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)
  76246. */
  76247. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76248. /**
  76249. * Wait asynchronously for the animation to end
  76250. * @returns a promise which will be fullfilled when the animation ends
  76251. */
  76252. waitAsync(): Promise<Animatable>;
  76253. /** @hidden */
  76254. _animate(delay: number): boolean;
  76255. }
  76256. interface Scene {
  76257. /** @hidden */
  76258. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76259. /** @hidden */
  76260. _processLateAnimationBindingsForMatrices(holder: {
  76261. totalWeight: number;
  76262. animations: RuntimeAnimation[];
  76263. originalValue: Matrix;
  76264. }): any;
  76265. /** @hidden */
  76266. _processLateAnimationBindingsForQuaternions(holder: {
  76267. totalWeight: number;
  76268. animations: RuntimeAnimation[];
  76269. originalValue: Quaternion;
  76270. }, refQuaternion: Quaternion): Quaternion;
  76271. /** @hidden */
  76272. _processLateAnimationBindings(): void;
  76273. /**
  76274. * Will start the animation sequence of a given target
  76275. * @param target defines the target
  76276. * @param from defines from which frame should animation start
  76277. * @param to defines until which frame should animation run.
  76278. * @param weight defines the weight to apply to the animation (1.0 by default)
  76279. * @param loop defines if the animation loops
  76280. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76281. * @param onAnimationEnd defines the function to be executed when the animation ends
  76282. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76283. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76284. * @param onAnimationLoop defines the callback to call when an animation loops
  76285. * @returns the animatable object created for this animation
  76286. */
  76287. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76288. /**
  76289. * Will start the animation sequence of a given target
  76290. * @param target defines the target
  76291. * @param from defines from which frame should animation start
  76292. * @param to defines until which frame should animation run.
  76293. * @param loop defines if the animation loops
  76294. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76295. * @param onAnimationEnd defines the function to be executed when the animation ends
  76296. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76297. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76298. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76299. * @param onAnimationLoop defines the callback to call when an animation loops
  76300. * @returns the animatable object created for this animation
  76301. */
  76302. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76303. /**
  76304. * Will start the animation sequence of a given target and its hierarchy
  76305. * @param target defines the target
  76306. * @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.
  76307. * @param from defines from which frame should animation start
  76308. * @param to defines until which frame should animation run.
  76309. * @param loop defines if the animation loops
  76310. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76311. * @param onAnimationEnd defines the function to be executed when the animation ends
  76312. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76313. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76314. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76315. * @param onAnimationLoop defines the callback to call when an animation loops
  76316. * @returns the list of created animatables
  76317. */
  76318. 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[];
  76319. /**
  76320. * Begin a new animation on a given node
  76321. * @param target defines the target where the animation will take place
  76322. * @param animations defines the list of animations to start
  76323. * @param from defines the initial value
  76324. * @param to defines the final value
  76325. * @param loop defines if you want animation to loop (off by default)
  76326. * @param speedRatio defines the speed ratio to apply to all animations
  76327. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76328. * @param onAnimationLoop defines the callback to call when an animation loops
  76329. * @returns the list of created animatables
  76330. */
  76331. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76332. /**
  76333. * Begin a new animation on a given node and its hierarchy
  76334. * @param target defines the root node where the animation will take place
  76335. * @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.
  76336. * @param animations defines the list of animations to start
  76337. * @param from defines the initial value
  76338. * @param to defines the final value
  76339. * @param loop defines if you want animation to loop (off by default)
  76340. * @param speedRatio defines the speed ratio to apply to all animations
  76341. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76342. * @param onAnimationLoop defines the callback to call when an animation loops
  76343. * @returns the list of animatables created for all nodes
  76344. */
  76345. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76346. /**
  76347. * Gets the animatable associated with a specific target
  76348. * @param target defines the target of the animatable
  76349. * @returns the required animatable if found
  76350. */
  76351. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76352. /**
  76353. * Gets all animatables associated with a given target
  76354. * @param target defines the target to look animatables for
  76355. * @returns an array of Animatables
  76356. */
  76357. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76358. /**
  76359. * Will stop the animation of the given target
  76360. * @param target - the target
  76361. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76362. * @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)
  76363. */
  76364. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76365. /**
  76366. * Stops and removes all animations that have been applied to the scene
  76367. */
  76368. stopAllAnimations(): void;
  76369. }
  76370. interface Bone {
  76371. /**
  76372. * Copy an animation range from another bone
  76373. * @param source defines the source bone
  76374. * @param rangeName defines the range name to copy
  76375. * @param frameOffset defines the frame offset
  76376. * @param rescaleAsRequired defines if rescaling must be applied if required
  76377. * @param skelDimensionsRatio defines the scaling ratio
  76378. * @returns true if operation was successful
  76379. */
  76380. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76381. }
  76382. }
  76383. declare module BABYLON {
  76384. /**
  76385. * Class used to handle skinning animations
  76386. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76387. */
  76388. export class Skeleton implements IAnimatable {
  76389. /** defines the skeleton name */
  76390. name: string;
  76391. /** defines the skeleton Id */
  76392. id: string;
  76393. /**
  76394. * Defines the list of child bones
  76395. */
  76396. bones: Bone[];
  76397. /**
  76398. * Defines an estimate of the dimension of the skeleton at rest
  76399. */
  76400. dimensionsAtRest: Vector3;
  76401. /**
  76402. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76403. */
  76404. needInitialSkinMatrix: boolean;
  76405. /**
  76406. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76407. */
  76408. overrideMesh: Nullable<AbstractMesh>;
  76409. /**
  76410. * Gets the list of animations attached to this skeleton
  76411. */
  76412. animations: Array<Animation>;
  76413. private _scene;
  76414. private _isDirty;
  76415. private _transformMatrices;
  76416. private _transformMatrixTexture;
  76417. private _meshesWithPoseMatrix;
  76418. private _animatables;
  76419. private _identity;
  76420. private _synchronizedWithMesh;
  76421. private _ranges;
  76422. private _lastAbsoluteTransformsUpdateId;
  76423. private _canUseTextureForBones;
  76424. /** @hidden */
  76425. _numBonesWithLinkedTransformNode: number;
  76426. /**
  76427. * Specifies if the skeleton should be serialized
  76428. */
  76429. doNotSerialize: boolean;
  76430. private _useTextureToStoreBoneMatrices;
  76431. /**
  76432. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76433. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  76434. */
  76435. useTextureToStoreBoneMatrices: boolean;
  76436. private _animationPropertiesOverride;
  76437. /**
  76438. * Gets or sets the animation properties override
  76439. */
  76440. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76441. /**
  76442. * An observable triggered before computing the skeleton's matrices
  76443. */
  76444. onBeforeComputeObservable: Observable<Skeleton>;
  76445. /**
  76446. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76447. */
  76448. readonly isUsingTextureForMatrices: boolean;
  76449. /**
  76450. * Creates a new skeleton
  76451. * @param name defines the skeleton name
  76452. * @param id defines the skeleton Id
  76453. * @param scene defines the hosting scene
  76454. */
  76455. constructor(
  76456. /** defines the skeleton name */
  76457. name: string,
  76458. /** defines the skeleton Id */
  76459. id: string, scene: Scene);
  76460. /**
  76461. * Gets the current object class name.
  76462. * @return the class name
  76463. */
  76464. getClassName(): string;
  76465. /**
  76466. * Returns an array containing the root bones
  76467. * @returns an array containing the root bones
  76468. */
  76469. getChildren(): Array<Bone>;
  76470. /**
  76471. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76472. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76473. * @returns a Float32Array containing matrices data
  76474. */
  76475. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76476. /**
  76477. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76478. * @returns a raw texture containing the data
  76479. */
  76480. getTransformMatrixTexture(): Nullable<RawTexture>;
  76481. /**
  76482. * Gets the current hosting scene
  76483. * @returns a scene object
  76484. */
  76485. getScene(): Scene;
  76486. /**
  76487. * Gets a string representing the current skeleton data
  76488. * @param fullDetails defines a boolean indicating if we want a verbose version
  76489. * @returns a string representing the current skeleton data
  76490. */
  76491. toString(fullDetails?: boolean): string;
  76492. /**
  76493. * Get bone's index searching by name
  76494. * @param name defines bone's name to search for
  76495. * @return the indice of the bone. Returns -1 if not found
  76496. */
  76497. getBoneIndexByName(name: string): number;
  76498. /**
  76499. * Creater a new animation range
  76500. * @param name defines the name of the range
  76501. * @param from defines the start key
  76502. * @param to defines the end key
  76503. */
  76504. createAnimationRange(name: string, from: number, to: number): void;
  76505. /**
  76506. * Delete a specific animation range
  76507. * @param name defines the name of the range
  76508. * @param deleteFrames defines if frames must be removed as well
  76509. */
  76510. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76511. /**
  76512. * Gets a specific animation range
  76513. * @param name defines the name of the range to look for
  76514. * @returns the requested animation range or null if not found
  76515. */
  76516. getAnimationRange(name: string): Nullable<AnimationRange>;
  76517. /**
  76518. * Gets the list of all animation ranges defined on this skeleton
  76519. * @returns an array
  76520. */
  76521. getAnimationRanges(): Nullable<AnimationRange>[];
  76522. /**
  76523. * Copy animation range from a source skeleton.
  76524. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76525. * @param source defines the source skeleton
  76526. * @param name defines the name of the range to copy
  76527. * @param rescaleAsRequired defines if rescaling must be applied if required
  76528. * @returns true if operation was successful
  76529. */
  76530. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76531. /**
  76532. * Forces the skeleton to go to rest pose
  76533. */
  76534. returnToRest(): void;
  76535. private _getHighestAnimationFrame;
  76536. /**
  76537. * Begin a specific animation range
  76538. * @param name defines the name of the range to start
  76539. * @param loop defines if looping must be turned on (false by default)
  76540. * @param speedRatio defines the speed ratio to apply (1 by default)
  76541. * @param onAnimationEnd defines a callback which will be called when animation will end
  76542. * @returns a new animatable
  76543. */
  76544. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76545. /** @hidden */
  76546. _markAsDirty(): void;
  76547. /** @hidden */
  76548. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76549. /** @hidden */
  76550. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76551. private _computeTransformMatrices;
  76552. /**
  76553. * Build all resources required to render a skeleton
  76554. */
  76555. prepare(): void;
  76556. /**
  76557. * Gets the list of animatables currently running for this skeleton
  76558. * @returns an array of animatables
  76559. */
  76560. getAnimatables(): IAnimatable[];
  76561. /**
  76562. * Clone the current skeleton
  76563. * @param name defines the name of the new skeleton
  76564. * @param id defines the id of the enw skeleton
  76565. * @returns the new skeleton
  76566. */
  76567. clone(name: string, id: string): Skeleton;
  76568. /**
  76569. * Enable animation blending for this skeleton
  76570. * @param blendingSpeed defines the blending speed to apply
  76571. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76572. */
  76573. enableBlending(blendingSpeed?: number): void;
  76574. /**
  76575. * Releases all resources associated with the current skeleton
  76576. */
  76577. dispose(): void;
  76578. /**
  76579. * Serialize the skeleton in a JSON object
  76580. * @returns a JSON object
  76581. */
  76582. serialize(): any;
  76583. /**
  76584. * Creates a new skeleton from serialized data
  76585. * @param parsedSkeleton defines the serialized data
  76586. * @param scene defines the hosting scene
  76587. * @returns a new skeleton
  76588. */
  76589. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76590. /**
  76591. * Compute all node absolute transforms
  76592. * @param forceUpdate defines if computation must be done even if cache is up to date
  76593. */
  76594. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76595. /**
  76596. * Gets the root pose matrix
  76597. * @returns a matrix
  76598. */
  76599. getPoseMatrix(): Nullable<Matrix>;
  76600. /**
  76601. * Sorts bones per internal index
  76602. */
  76603. sortBones(): void;
  76604. private _sortBones;
  76605. }
  76606. }
  76607. declare module BABYLON {
  76608. /**
  76609. * Defines a target to use with MorphTargetManager
  76610. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76611. */
  76612. export class MorphTarget implements IAnimatable {
  76613. /** defines the name of the target */
  76614. name: string;
  76615. /**
  76616. * Gets or sets the list of animations
  76617. */
  76618. animations: Animation[];
  76619. private _scene;
  76620. private _positions;
  76621. private _normals;
  76622. private _tangents;
  76623. private _influence;
  76624. /**
  76625. * Observable raised when the influence changes
  76626. */
  76627. onInfluenceChanged: Observable<boolean>;
  76628. /** @hidden */
  76629. _onDataLayoutChanged: Observable<void>;
  76630. /**
  76631. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76632. */
  76633. influence: number;
  76634. /**
  76635. * Gets or sets the id of the morph Target
  76636. */
  76637. id: string;
  76638. private _animationPropertiesOverride;
  76639. /**
  76640. * Gets or sets the animation properties override
  76641. */
  76642. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76643. /**
  76644. * Creates a new MorphTarget
  76645. * @param name defines the name of the target
  76646. * @param influence defines the influence to use
  76647. * @param scene defines the scene the morphtarget belongs to
  76648. */
  76649. constructor(
  76650. /** defines the name of the target */
  76651. name: string, influence?: number, scene?: Nullable<Scene>);
  76652. /**
  76653. * Gets a boolean defining if the target contains position data
  76654. */
  76655. readonly hasPositions: boolean;
  76656. /**
  76657. * Gets a boolean defining if the target contains normal data
  76658. */
  76659. readonly hasNormals: boolean;
  76660. /**
  76661. * Gets a boolean defining if the target contains tangent data
  76662. */
  76663. readonly hasTangents: boolean;
  76664. /**
  76665. * Affects position data to this target
  76666. * @param data defines the position data to use
  76667. */
  76668. setPositions(data: Nullable<FloatArray>): void;
  76669. /**
  76670. * Gets the position data stored in this target
  76671. * @returns a FloatArray containing the position data (or null if not present)
  76672. */
  76673. getPositions(): Nullable<FloatArray>;
  76674. /**
  76675. * Affects normal data to this target
  76676. * @param data defines the normal data to use
  76677. */
  76678. setNormals(data: Nullable<FloatArray>): void;
  76679. /**
  76680. * Gets the normal data stored in this target
  76681. * @returns a FloatArray containing the normal data (or null if not present)
  76682. */
  76683. getNormals(): Nullable<FloatArray>;
  76684. /**
  76685. * Affects tangent data to this target
  76686. * @param data defines the tangent data to use
  76687. */
  76688. setTangents(data: Nullable<FloatArray>): void;
  76689. /**
  76690. * Gets the tangent data stored in this target
  76691. * @returns a FloatArray containing the tangent data (or null if not present)
  76692. */
  76693. getTangents(): Nullable<FloatArray>;
  76694. /**
  76695. * Serializes the current target into a Serialization object
  76696. * @returns the serialized object
  76697. */
  76698. serialize(): any;
  76699. /**
  76700. * Returns the string "MorphTarget"
  76701. * @returns "MorphTarget"
  76702. */
  76703. getClassName(): string;
  76704. /**
  76705. * Creates a new target from serialized data
  76706. * @param serializationObject defines the serialized data to use
  76707. * @returns a new MorphTarget
  76708. */
  76709. static Parse(serializationObject: any): MorphTarget;
  76710. /**
  76711. * Creates a MorphTarget from mesh data
  76712. * @param mesh defines the source mesh
  76713. * @param name defines the name to use for the new target
  76714. * @param influence defines the influence to attach to the target
  76715. * @returns a new MorphTarget
  76716. */
  76717. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76718. }
  76719. }
  76720. declare module BABYLON {
  76721. /**
  76722. * This class is used to deform meshes using morphing between different targets
  76723. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76724. */
  76725. export class MorphTargetManager {
  76726. private _targets;
  76727. private _targetInfluenceChangedObservers;
  76728. private _targetDataLayoutChangedObservers;
  76729. private _activeTargets;
  76730. private _scene;
  76731. private _influences;
  76732. private _supportsNormals;
  76733. private _supportsTangents;
  76734. private _vertexCount;
  76735. private _uniqueId;
  76736. private _tempInfluences;
  76737. /**
  76738. * Creates a new MorphTargetManager
  76739. * @param scene defines the current scene
  76740. */
  76741. constructor(scene?: Nullable<Scene>);
  76742. /**
  76743. * Gets the unique ID of this manager
  76744. */
  76745. readonly uniqueId: number;
  76746. /**
  76747. * Gets the number of vertices handled by this manager
  76748. */
  76749. readonly vertexCount: number;
  76750. /**
  76751. * Gets a boolean indicating if this manager supports morphing of normals
  76752. */
  76753. readonly supportsNormals: boolean;
  76754. /**
  76755. * Gets a boolean indicating if this manager supports morphing of tangents
  76756. */
  76757. readonly supportsTangents: boolean;
  76758. /**
  76759. * Gets the number of targets stored in this manager
  76760. */
  76761. readonly numTargets: number;
  76762. /**
  76763. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76764. */
  76765. readonly numInfluencers: number;
  76766. /**
  76767. * Gets the list of influences (one per target)
  76768. */
  76769. readonly influences: Float32Array;
  76770. /**
  76771. * Gets the active target at specified index. An active target is a target with an influence > 0
  76772. * @param index defines the index to check
  76773. * @returns the requested target
  76774. */
  76775. getActiveTarget(index: number): MorphTarget;
  76776. /**
  76777. * Gets the target at specified index
  76778. * @param index defines the index to check
  76779. * @returns the requested target
  76780. */
  76781. getTarget(index: number): MorphTarget;
  76782. /**
  76783. * Add a new target to this manager
  76784. * @param target defines the target to add
  76785. */
  76786. addTarget(target: MorphTarget): void;
  76787. /**
  76788. * Removes a target from the manager
  76789. * @param target defines the target to remove
  76790. */
  76791. removeTarget(target: MorphTarget): void;
  76792. /**
  76793. * Serializes the current manager into a Serialization object
  76794. * @returns the serialized object
  76795. */
  76796. serialize(): any;
  76797. private _syncActiveTargets;
  76798. /**
  76799. * Syncrhonize the targets with all the meshes using this morph target manager
  76800. */
  76801. synchronize(): void;
  76802. /**
  76803. * Creates a new MorphTargetManager from serialized data
  76804. * @param serializationObject defines the serialized data
  76805. * @param scene defines the hosting scene
  76806. * @returns the new MorphTargetManager
  76807. */
  76808. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76809. }
  76810. }
  76811. declare module BABYLON {
  76812. /**
  76813. * Mesh representing the gorund
  76814. */
  76815. export class GroundMesh extends Mesh {
  76816. /** If octree should be generated */
  76817. generateOctree: boolean;
  76818. private _heightQuads;
  76819. /** @hidden */
  76820. _subdivisionsX: number;
  76821. /** @hidden */
  76822. _subdivisionsY: number;
  76823. /** @hidden */
  76824. _width: number;
  76825. /** @hidden */
  76826. _height: number;
  76827. /** @hidden */
  76828. _minX: number;
  76829. /** @hidden */
  76830. _maxX: number;
  76831. /** @hidden */
  76832. _minZ: number;
  76833. /** @hidden */
  76834. _maxZ: number;
  76835. constructor(name: string, scene: Scene);
  76836. /**
  76837. * "GroundMesh"
  76838. * @returns "GroundMesh"
  76839. */
  76840. getClassName(): string;
  76841. /**
  76842. * The minimum of x and y subdivisions
  76843. */
  76844. readonly subdivisions: number;
  76845. /**
  76846. * X subdivisions
  76847. */
  76848. readonly subdivisionsX: number;
  76849. /**
  76850. * Y subdivisions
  76851. */
  76852. readonly subdivisionsY: number;
  76853. /**
  76854. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76855. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76856. * @param chunksCount the number of subdivisions for x and y
  76857. * @param octreeBlocksSize (Default: 32)
  76858. */
  76859. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76860. /**
  76861. * Returns a height (y) value in the Worl system :
  76862. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76863. * @param x x coordinate
  76864. * @param z z coordinate
  76865. * @returns the ground y position if (x, z) are outside the ground surface.
  76866. */
  76867. getHeightAtCoordinates(x: number, z: number): number;
  76868. /**
  76869. * Returns a normalized vector (Vector3) orthogonal to the ground
  76870. * at the ground coordinates (x, z) expressed in the World system.
  76871. * @param x x coordinate
  76872. * @param z z coordinate
  76873. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76874. */
  76875. getNormalAtCoordinates(x: number, z: number): Vector3;
  76876. /**
  76877. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76878. * at the ground coordinates (x, z) expressed in the World system.
  76879. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76880. * @param x x coordinate
  76881. * @param z z coordinate
  76882. * @param ref vector to store the result
  76883. * @returns the GroundMesh.
  76884. */
  76885. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76886. /**
  76887. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76888. * if the ground has been updated.
  76889. * This can be used in the render loop.
  76890. * @returns the GroundMesh.
  76891. */
  76892. updateCoordinateHeights(): GroundMesh;
  76893. private _getFacetAt;
  76894. private _initHeightQuads;
  76895. private _computeHeightQuads;
  76896. /**
  76897. * Serializes this ground mesh
  76898. * @param serializationObject object to write serialization to
  76899. */
  76900. serialize(serializationObject: any): void;
  76901. /**
  76902. * Parses a serialized ground mesh
  76903. * @param parsedMesh the serialized mesh
  76904. * @param scene the scene to create the ground mesh in
  76905. * @returns the created ground mesh
  76906. */
  76907. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76908. }
  76909. }
  76910. declare module BABYLON {
  76911. /**
  76912. * Interface for Physics-Joint data
  76913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76914. */
  76915. export interface PhysicsJointData {
  76916. /**
  76917. * The main pivot of the joint
  76918. */
  76919. mainPivot?: Vector3;
  76920. /**
  76921. * The connected pivot of the joint
  76922. */
  76923. connectedPivot?: Vector3;
  76924. /**
  76925. * The main axis of the joint
  76926. */
  76927. mainAxis?: Vector3;
  76928. /**
  76929. * The connected axis of the joint
  76930. */
  76931. connectedAxis?: Vector3;
  76932. /**
  76933. * The collision of the joint
  76934. */
  76935. collision?: boolean;
  76936. /**
  76937. * Native Oimo/Cannon/Energy data
  76938. */
  76939. nativeParams?: any;
  76940. }
  76941. /**
  76942. * This is a holder class for the physics joint created by the physics plugin
  76943. * It holds a set of functions to control the underlying joint
  76944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76945. */
  76946. export class PhysicsJoint {
  76947. /**
  76948. * The type of the physics joint
  76949. */
  76950. type: number;
  76951. /**
  76952. * The data for the physics joint
  76953. */
  76954. jointData: PhysicsJointData;
  76955. private _physicsJoint;
  76956. protected _physicsPlugin: IPhysicsEnginePlugin;
  76957. /**
  76958. * Initializes the physics joint
  76959. * @param type The type of the physics joint
  76960. * @param jointData The data for the physics joint
  76961. */
  76962. constructor(
  76963. /**
  76964. * The type of the physics joint
  76965. */
  76966. type: number,
  76967. /**
  76968. * The data for the physics joint
  76969. */
  76970. jointData: PhysicsJointData);
  76971. /**
  76972. * Gets the physics joint
  76973. */
  76974. /**
  76975. * Sets the physics joint
  76976. */
  76977. physicsJoint: any;
  76978. /**
  76979. * Sets the physics plugin
  76980. */
  76981. physicsPlugin: IPhysicsEnginePlugin;
  76982. /**
  76983. * Execute a function that is physics-plugin specific.
  76984. * @param {Function} func the function that will be executed.
  76985. * It accepts two parameters: the physics world and the physics joint
  76986. */
  76987. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76988. /**
  76989. * Distance-Joint type
  76990. */
  76991. static DistanceJoint: number;
  76992. /**
  76993. * Hinge-Joint type
  76994. */
  76995. static HingeJoint: number;
  76996. /**
  76997. * Ball-and-Socket joint type
  76998. */
  76999. static BallAndSocketJoint: number;
  77000. /**
  77001. * Wheel-Joint type
  77002. */
  77003. static WheelJoint: number;
  77004. /**
  77005. * Slider-Joint type
  77006. */
  77007. static SliderJoint: number;
  77008. /**
  77009. * Prismatic-Joint type
  77010. */
  77011. static PrismaticJoint: number;
  77012. /**
  77013. * Universal-Joint type
  77014. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  77015. */
  77016. static UniversalJoint: number;
  77017. /**
  77018. * Hinge-Joint 2 type
  77019. */
  77020. static Hinge2Joint: number;
  77021. /**
  77022. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  77023. */
  77024. static PointToPointJoint: number;
  77025. /**
  77026. * Spring-Joint type
  77027. */
  77028. static SpringJoint: number;
  77029. /**
  77030. * Lock-Joint type
  77031. */
  77032. static LockJoint: number;
  77033. }
  77034. /**
  77035. * A class representing a physics distance joint
  77036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77037. */
  77038. export class DistanceJoint extends PhysicsJoint {
  77039. /**
  77040. *
  77041. * @param jointData The data for the Distance-Joint
  77042. */
  77043. constructor(jointData: DistanceJointData);
  77044. /**
  77045. * Update the predefined distance.
  77046. * @param maxDistance The maximum preferred distance
  77047. * @param minDistance The minimum preferred distance
  77048. */
  77049. updateDistance(maxDistance: number, minDistance?: number): void;
  77050. }
  77051. /**
  77052. * Represents a Motor-Enabled Joint
  77053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77054. */
  77055. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  77056. /**
  77057. * Initializes the Motor-Enabled Joint
  77058. * @param type The type of the joint
  77059. * @param jointData The physica joint data for the joint
  77060. */
  77061. constructor(type: number, jointData: PhysicsJointData);
  77062. /**
  77063. * Set the motor values.
  77064. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77065. * @param force the force to apply
  77066. * @param maxForce max force for this motor.
  77067. */
  77068. setMotor(force?: number, maxForce?: number): void;
  77069. /**
  77070. * Set the motor's limits.
  77071. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77072. * @param upperLimit The upper limit of the motor
  77073. * @param lowerLimit The lower limit of the motor
  77074. */
  77075. setLimit(upperLimit: number, lowerLimit?: number): void;
  77076. }
  77077. /**
  77078. * This class represents a single physics Hinge-Joint
  77079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77080. */
  77081. export class HingeJoint extends MotorEnabledJoint {
  77082. /**
  77083. * Initializes the Hinge-Joint
  77084. * @param jointData The joint data for the Hinge-Joint
  77085. */
  77086. constructor(jointData: PhysicsJointData);
  77087. /**
  77088. * Set the motor values.
  77089. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77090. * @param {number} force the force to apply
  77091. * @param {number} maxForce max force for this motor.
  77092. */
  77093. setMotor(force?: number, maxForce?: number): void;
  77094. /**
  77095. * Set the motor's limits.
  77096. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77097. * @param upperLimit The upper limit of the motor
  77098. * @param lowerLimit The lower limit of the motor
  77099. */
  77100. setLimit(upperLimit: number, lowerLimit?: number): void;
  77101. }
  77102. /**
  77103. * This class represents a dual hinge physics joint (same as wheel joint)
  77104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77105. */
  77106. export class Hinge2Joint extends MotorEnabledJoint {
  77107. /**
  77108. * Initializes the Hinge2-Joint
  77109. * @param jointData The joint data for the Hinge2-Joint
  77110. */
  77111. constructor(jointData: PhysicsJointData);
  77112. /**
  77113. * Set the motor values.
  77114. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77115. * @param {number} targetSpeed the speed the motor is to reach
  77116. * @param {number} maxForce max force for this motor.
  77117. * @param {motorIndex} the motor's index, 0 or 1.
  77118. */
  77119. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  77120. /**
  77121. * Set the motor limits.
  77122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77123. * @param {number} upperLimit the upper limit
  77124. * @param {number} lowerLimit lower limit
  77125. * @param {motorIndex} the motor's index, 0 or 1.
  77126. */
  77127. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77128. }
  77129. /**
  77130. * Interface for a motor enabled joint
  77131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77132. */
  77133. export interface IMotorEnabledJoint {
  77134. /**
  77135. * Physics joint
  77136. */
  77137. physicsJoint: any;
  77138. /**
  77139. * Sets the motor of the motor-enabled joint
  77140. * @param force The force of the motor
  77141. * @param maxForce The maximum force of the motor
  77142. * @param motorIndex The index of the motor
  77143. */
  77144. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  77145. /**
  77146. * Sets the limit of the motor
  77147. * @param upperLimit The upper limit of the motor
  77148. * @param lowerLimit The lower limit of the motor
  77149. * @param motorIndex The index of the motor
  77150. */
  77151. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77152. }
  77153. /**
  77154. * Joint data for a Distance-Joint
  77155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77156. */
  77157. export interface DistanceJointData extends PhysicsJointData {
  77158. /**
  77159. * Max distance the 2 joint objects can be apart
  77160. */
  77161. maxDistance: number;
  77162. }
  77163. /**
  77164. * Joint data from a spring joint
  77165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77166. */
  77167. export interface SpringJointData extends PhysicsJointData {
  77168. /**
  77169. * Length of the spring
  77170. */
  77171. length: number;
  77172. /**
  77173. * Stiffness of the spring
  77174. */
  77175. stiffness: number;
  77176. /**
  77177. * Damping of the spring
  77178. */
  77179. damping: number;
  77180. /** this callback will be called when applying the force to the impostors. */
  77181. forceApplicationCallback: () => void;
  77182. }
  77183. }
  77184. declare module BABYLON {
  77185. /**
  77186. * Interface used to describe a physics joint
  77187. */
  77188. export interface PhysicsImpostorJoint {
  77189. /** Defines the main impostor to which the joint is linked */
  77190. mainImpostor: PhysicsImpostor;
  77191. /** Defines the impostor that is connected to the main impostor using this joint */
  77192. connectedImpostor: PhysicsImpostor;
  77193. /** Defines the joint itself */
  77194. joint: PhysicsJoint;
  77195. }
  77196. /** @hidden */
  77197. export interface IPhysicsEnginePlugin {
  77198. world: any;
  77199. name: string;
  77200. setGravity(gravity: Vector3): void;
  77201. setTimeStep(timeStep: number): void;
  77202. getTimeStep(): number;
  77203. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  77204. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77205. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77206. generatePhysicsBody(impostor: PhysicsImpostor): void;
  77207. removePhysicsBody(impostor: PhysicsImpostor): void;
  77208. generateJoint(joint: PhysicsImpostorJoint): void;
  77209. removeJoint(joint: PhysicsImpostorJoint): void;
  77210. isSupported(): boolean;
  77211. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  77212. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  77213. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77214. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77215. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77216. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77217. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  77218. getBodyMass(impostor: PhysicsImpostor): number;
  77219. getBodyFriction(impostor: PhysicsImpostor): number;
  77220. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  77221. getBodyRestitution(impostor: PhysicsImpostor): number;
  77222. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  77223. sleepBody(impostor: PhysicsImpostor): void;
  77224. wakeUpBody(impostor: PhysicsImpostor): void;
  77225. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  77226. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  77227. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77228. getRadius(impostor: PhysicsImpostor): number;
  77229. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  77230. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  77231. dispose(): void;
  77232. }
  77233. /**
  77234. * Interface used to define a physics engine
  77235. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  77236. */
  77237. export interface IPhysicsEngine {
  77238. /**
  77239. * Gets the gravity vector used by the simulation
  77240. */
  77241. gravity: Vector3;
  77242. /**
  77243. * Sets the gravity vector used by the simulation
  77244. * @param gravity defines the gravity vector to use
  77245. */
  77246. setGravity(gravity: Vector3): void;
  77247. /**
  77248. * Set the time step of the physics engine.
  77249. * Default is 1/60.
  77250. * To slow it down, enter 1/600 for example.
  77251. * To speed it up, 1/30
  77252. * @param newTimeStep the new timestep to apply to this world.
  77253. */
  77254. setTimeStep(newTimeStep: number): void;
  77255. /**
  77256. * Get the time step of the physics engine.
  77257. * @returns the current time step
  77258. */
  77259. getTimeStep(): number;
  77260. /**
  77261. * Release all resources
  77262. */
  77263. dispose(): void;
  77264. /**
  77265. * Gets the name of the current physics plugin
  77266. * @returns the name of the plugin
  77267. */
  77268. getPhysicsPluginName(): string;
  77269. /**
  77270. * Adding a new impostor for the impostor tracking.
  77271. * This will be done by the impostor itself.
  77272. * @param impostor the impostor to add
  77273. */
  77274. addImpostor(impostor: PhysicsImpostor): void;
  77275. /**
  77276. * Remove an impostor from the engine.
  77277. * This impostor and its mesh will not longer be updated by the physics engine.
  77278. * @param impostor the impostor to remove
  77279. */
  77280. removeImpostor(impostor: PhysicsImpostor): void;
  77281. /**
  77282. * Add a joint to the physics engine
  77283. * @param mainImpostor defines the main impostor to which the joint is added.
  77284. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  77285. * @param joint defines the joint that will connect both impostors.
  77286. */
  77287. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77288. /**
  77289. * Removes a joint from the simulation
  77290. * @param mainImpostor defines the impostor used with the joint
  77291. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  77292. * @param joint defines the joint to remove
  77293. */
  77294. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77295. /**
  77296. * Gets the current plugin used to run the simulation
  77297. * @returns current plugin
  77298. */
  77299. getPhysicsPlugin(): IPhysicsEnginePlugin;
  77300. /**
  77301. * Gets the list of physic impostors
  77302. * @returns an array of PhysicsImpostor
  77303. */
  77304. getImpostors(): Array<PhysicsImpostor>;
  77305. /**
  77306. * Gets the impostor for a physics enabled object
  77307. * @param object defines the object impersonated by the impostor
  77308. * @returns the PhysicsImpostor or null if not found
  77309. */
  77310. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77311. /**
  77312. * Gets the impostor for a physics body object
  77313. * @param body defines physics body used by the impostor
  77314. * @returns the PhysicsImpostor or null if not found
  77315. */
  77316. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  77317. /**
  77318. * Called by the scene. No need to call it.
  77319. * @param delta defines the timespam between frames
  77320. */
  77321. _step(delta: number): void;
  77322. }
  77323. }
  77324. declare module BABYLON {
  77325. /**
  77326. * The interface for the physics imposter parameters
  77327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77328. */
  77329. export interface PhysicsImpostorParameters {
  77330. /**
  77331. * The mass of the physics imposter
  77332. */
  77333. mass: number;
  77334. /**
  77335. * The friction of the physics imposter
  77336. */
  77337. friction?: number;
  77338. /**
  77339. * The coefficient of restitution of the physics imposter
  77340. */
  77341. restitution?: number;
  77342. /**
  77343. * The native options of the physics imposter
  77344. */
  77345. nativeOptions?: any;
  77346. /**
  77347. * Specifies if the parent should be ignored
  77348. */
  77349. ignoreParent?: boolean;
  77350. /**
  77351. * Specifies if bi-directional transformations should be disabled
  77352. */
  77353. disableBidirectionalTransformation?: boolean;
  77354. }
  77355. /**
  77356. * Interface for a physics-enabled object
  77357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77358. */
  77359. export interface IPhysicsEnabledObject {
  77360. /**
  77361. * The position of the physics-enabled object
  77362. */
  77363. position: Vector3;
  77364. /**
  77365. * The rotation of the physics-enabled object
  77366. */
  77367. rotationQuaternion: Nullable<Quaternion>;
  77368. /**
  77369. * The scale of the physics-enabled object
  77370. */
  77371. scaling: Vector3;
  77372. /**
  77373. * The rotation of the physics-enabled object
  77374. */
  77375. rotation?: Vector3;
  77376. /**
  77377. * The parent of the physics-enabled object
  77378. */
  77379. parent?: any;
  77380. /**
  77381. * The bounding info of the physics-enabled object
  77382. * @returns The bounding info of the physics-enabled object
  77383. */
  77384. getBoundingInfo(): BoundingInfo;
  77385. /**
  77386. * Computes the world matrix
  77387. * @param force Specifies if the world matrix should be computed by force
  77388. * @returns A world matrix
  77389. */
  77390. computeWorldMatrix(force: boolean): Matrix;
  77391. /**
  77392. * Gets the world matrix
  77393. * @returns A world matrix
  77394. */
  77395. getWorldMatrix?(): Matrix;
  77396. /**
  77397. * Gets the child meshes
  77398. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  77399. * @returns An array of abstract meshes
  77400. */
  77401. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  77402. /**
  77403. * Gets the vertex data
  77404. * @param kind The type of vertex data
  77405. * @returns A nullable array of numbers, or a float32 array
  77406. */
  77407. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  77408. /**
  77409. * Gets the indices from the mesh
  77410. * @returns A nullable array of index arrays
  77411. */
  77412. getIndices?(): Nullable<IndicesArray>;
  77413. /**
  77414. * Gets the scene from the mesh
  77415. * @returns the indices array or null
  77416. */
  77417. getScene?(): Scene;
  77418. /**
  77419. * Gets the absolute position from the mesh
  77420. * @returns the absolute position
  77421. */
  77422. getAbsolutePosition(): Vector3;
  77423. /**
  77424. * Gets the absolute pivot point from the mesh
  77425. * @returns the absolute pivot point
  77426. */
  77427. getAbsolutePivotPoint(): Vector3;
  77428. /**
  77429. * Rotates the mesh
  77430. * @param axis The axis of rotation
  77431. * @param amount The amount of rotation
  77432. * @param space The space of the rotation
  77433. * @returns The rotation transform node
  77434. */
  77435. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77436. /**
  77437. * Translates the mesh
  77438. * @param axis The axis of translation
  77439. * @param distance The distance of translation
  77440. * @param space The space of the translation
  77441. * @returns The transform node
  77442. */
  77443. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77444. /**
  77445. * Sets the absolute position of the mesh
  77446. * @param absolutePosition The absolute position of the mesh
  77447. * @returns The transform node
  77448. */
  77449. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77450. /**
  77451. * Gets the class name of the mesh
  77452. * @returns The class name
  77453. */
  77454. getClassName(): string;
  77455. }
  77456. /**
  77457. * Represents a physics imposter
  77458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77459. */
  77460. export class PhysicsImpostor {
  77461. /**
  77462. * The physics-enabled object used as the physics imposter
  77463. */
  77464. object: IPhysicsEnabledObject;
  77465. /**
  77466. * The type of the physics imposter
  77467. */
  77468. type: number;
  77469. private _options;
  77470. private _scene?;
  77471. /**
  77472. * The default object size of the imposter
  77473. */
  77474. static DEFAULT_OBJECT_SIZE: Vector3;
  77475. /**
  77476. * The identity quaternion of the imposter
  77477. */
  77478. static IDENTITY_QUATERNION: Quaternion;
  77479. /** @hidden */
  77480. _pluginData: any;
  77481. private _physicsEngine;
  77482. private _physicsBody;
  77483. private _bodyUpdateRequired;
  77484. private _onBeforePhysicsStepCallbacks;
  77485. private _onAfterPhysicsStepCallbacks;
  77486. /** @hidden */
  77487. _onPhysicsCollideCallbacks: Array<{
  77488. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  77489. otherImpostors: Array<PhysicsImpostor>;
  77490. }>;
  77491. private _deltaPosition;
  77492. private _deltaRotation;
  77493. private _deltaRotationConjugated;
  77494. private _parent;
  77495. private _isDisposed;
  77496. private static _tmpVecs;
  77497. private static _tmpQuat;
  77498. /**
  77499. * Specifies if the physics imposter is disposed
  77500. */
  77501. readonly isDisposed: boolean;
  77502. /**
  77503. * Gets the mass of the physics imposter
  77504. */
  77505. mass: number;
  77506. /**
  77507. * Gets the coefficient of friction
  77508. */
  77509. /**
  77510. * Sets the coefficient of friction
  77511. */
  77512. friction: number;
  77513. /**
  77514. * Gets the coefficient of restitution
  77515. */
  77516. /**
  77517. * Sets the coefficient of restitution
  77518. */
  77519. restitution: number;
  77520. /**
  77521. * The unique id of the physics imposter
  77522. * set by the physics engine when adding this impostor to the array
  77523. */
  77524. uniqueId: number;
  77525. private _joints;
  77526. /**
  77527. * Initializes the physics imposter
  77528. * @param object The physics-enabled object used as the physics imposter
  77529. * @param type The type of the physics imposter
  77530. * @param _options The options for the physics imposter
  77531. * @param _scene The Babylon scene
  77532. */
  77533. constructor(
  77534. /**
  77535. * The physics-enabled object used as the physics imposter
  77536. */
  77537. object: IPhysicsEnabledObject,
  77538. /**
  77539. * The type of the physics imposter
  77540. */
  77541. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  77542. /**
  77543. * This function will completly initialize this impostor.
  77544. * It will create a new body - but only if this mesh has no parent.
  77545. * If it has, this impostor will not be used other than to define the impostor
  77546. * of the child mesh.
  77547. * @hidden
  77548. */
  77549. _init(): void;
  77550. private _getPhysicsParent;
  77551. /**
  77552. * Should a new body be generated.
  77553. * @returns boolean specifying if body initialization is required
  77554. */
  77555. isBodyInitRequired(): boolean;
  77556. /**
  77557. * Sets the updated scaling
  77558. * @param updated Specifies if the scaling is updated
  77559. */
  77560. setScalingUpdated(): void;
  77561. /**
  77562. * Force a regeneration of this or the parent's impostor's body.
  77563. * Use under cautious - This will remove all joints already implemented.
  77564. */
  77565. forceUpdate(): void;
  77566. /**
  77567. * Gets the body that holds this impostor. Either its own, or its parent.
  77568. */
  77569. /**
  77570. * Set the physics body. Used mainly by the physics engine/plugin
  77571. */
  77572. physicsBody: any;
  77573. /**
  77574. * Get the parent of the physics imposter
  77575. * @returns Physics imposter or null
  77576. */
  77577. /**
  77578. * Sets the parent of the physics imposter
  77579. */
  77580. parent: Nullable<PhysicsImpostor>;
  77581. /**
  77582. * Resets the update flags
  77583. */
  77584. resetUpdateFlags(): void;
  77585. /**
  77586. * Gets the object extend size
  77587. * @returns the object extend size
  77588. */
  77589. getObjectExtendSize(): Vector3;
  77590. /**
  77591. * Gets the object center
  77592. * @returns The object center
  77593. */
  77594. getObjectCenter(): Vector3;
  77595. /**
  77596. * Get a specific parametes from the options parameter
  77597. * @param paramName The object parameter name
  77598. * @returns The object parameter
  77599. */
  77600. getParam(paramName: string): any;
  77601. /**
  77602. * Sets a specific parameter in the options given to the physics plugin
  77603. * @param paramName The parameter name
  77604. * @param value The value of the parameter
  77605. */
  77606. setParam(paramName: string, value: number): void;
  77607. /**
  77608. * Specifically change the body's mass option. Won't recreate the physics body object
  77609. * @param mass The mass of the physics imposter
  77610. */
  77611. setMass(mass: number): void;
  77612. /**
  77613. * Gets the linear velocity
  77614. * @returns linear velocity or null
  77615. */
  77616. getLinearVelocity(): Nullable<Vector3>;
  77617. /**
  77618. * Sets the linear velocity
  77619. * @param velocity linear velocity or null
  77620. */
  77621. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77622. /**
  77623. * Gets the angular velocity
  77624. * @returns angular velocity or null
  77625. */
  77626. getAngularVelocity(): Nullable<Vector3>;
  77627. /**
  77628. * Sets the angular velocity
  77629. * @param velocity The velocity or null
  77630. */
  77631. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77632. /**
  77633. * Execute a function with the physics plugin native code
  77634. * Provide a function the will have two variables - the world object and the physics body object
  77635. * @param func The function to execute with the physics plugin native code
  77636. */
  77637. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77638. /**
  77639. * Register a function that will be executed before the physics world is stepping forward
  77640. * @param func The function to execute before the physics world is stepped forward
  77641. */
  77642. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77643. /**
  77644. * Unregister a function that will be executed before the physics world is stepping forward
  77645. * @param func The function to execute before the physics world is stepped forward
  77646. */
  77647. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77648. /**
  77649. * Register a function that will be executed after the physics step
  77650. * @param func The function to execute after physics step
  77651. */
  77652. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77653. /**
  77654. * Unregisters a function that will be executed after the physics step
  77655. * @param func The function to execute after physics step
  77656. */
  77657. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77658. /**
  77659. * register a function that will be executed when this impostor collides against a different body
  77660. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77661. * @param func Callback that is executed on collision
  77662. */
  77663. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77664. /**
  77665. * Unregisters the physics imposter on contact
  77666. * @param collideAgainst The physics object to collide against
  77667. * @param func Callback to execute on collision
  77668. */
  77669. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77670. private _tmpQuat;
  77671. private _tmpQuat2;
  77672. /**
  77673. * Get the parent rotation
  77674. * @returns The parent rotation
  77675. */
  77676. getParentsRotation(): Quaternion;
  77677. /**
  77678. * this function is executed by the physics engine.
  77679. */
  77680. beforeStep: () => void;
  77681. /**
  77682. * this function is executed by the physics engine
  77683. */
  77684. afterStep: () => void;
  77685. /**
  77686. * Legacy collision detection event support
  77687. */
  77688. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77689. /**
  77690. * event and body object due to cannon's event-based architecture.
  77691. */
  77692. onCollide: (e: {
  77693. body: any;
  77694. }) => void;
  77695. /**
  77696. * Apply a force
  77697. * @param force The force to apply
  77698. * @param contactPoint The contact point for the force
  77699. * @returns The physics imposter
  77700. */
  77701. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77702. /**
  77703. * Apply an impulse
  77704. * @param force The impulse force
  77705. * @param contactPoint The contact point for the impulse force
  77706. * @returns The physics imposter
  77707. */
  77708. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77709. /**
  77710. * A help function to create a joint
  77711. * @param otherImpostor A physics imposter used to create a joint
  77712. * @param jointType The type of joint
  77713. * @param jointData The data for the joint
  77714. * @returns The physics imposter
  77715. */
  77716. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77717. /**
  77718. * Add a joint to this impostor with a different impostor
  77719. * @param otherImpostor A physics imposter used to add a joint
  77720. * @param joint The joint to add
  77721. * @returns The physics imposter
  77722. */
  77723. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77724. /**
  77725. * Will keep this body still, in a sleep mode.
  77726. * @returns the physics imposter
  77727. */
  77728. sleep(): PhysicsImpostor;
  77729. /**
  77730. * Wake the body up.
  77731. * @returns The physics imposter
  77732. */
  77733. wakeUp(): PhysicsImpostor;
  77734. /**
  77735. * Clones the physics imposter
  77736. * @param newObject The physics imposter clones to this physics-enabled object
  77737. * @returns A nullable physics imposter
  77738. */
  77739. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77740. /**
  77741. * Disposes the physics imposter
  77742. */
  77743. dispose(): void;
  77744. /**
  77745. * Sets the delta position
  77746. * @param position The delta position amount
  77747. */
  77748. setDeltaPosition(position: Vector3): void;
  77749. /**
  77750. * Sets the delta rotation
  77751. * @param rotation The delta rotation amount
  77752. */
  77753. setDeltaRotation(rotation: Quaternion): void;
  77754. /**
  77755. * Gets the box size of the physics imposter and stores the result in the input parameter
  77756. * @param result Stores the box size
  77757. * @returns The physics imposter
  77758. */
  77759. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77760. /**
  77761. * Gets the radius of the physics imposter
  77762. * @returns Radius of the physics imposter
  77763. */
  77764. getRadius(): number;
  77765. /**
  77766. * Sync a bone with this impostor
  77767. * @param bone The bone to sync to the impostor.
  77768. * @param boneMesh The mesh that the bone is influencing.
  77769. * @param jointPivot The pivot of the joint / bone in local space.
  77770. * @param distToJoint Optional distance from the impostor to the joint.
  77771. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77772. */
  77773. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77774. /**
  77775. * Sync impostor to a bone
  77776. * @param bone The bone that the impostor will be synced to.
  77777. * @param boneMesh The mesh that the bone is influencing.
  77778. * @param jointPivot The pivot of the joint / bone in local space.
  77779. * @param distToJoint Optional distance from the impostor to the joint.
  77780. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77781. * @param boneAxis Optional vector3 axis the bone is aligned with
  77782. */
  77783. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77784. /**
  77785. * No-Imposter type
  77786. */
  77787. static NoImpostor: number;
  77788. /**
  77789. * Sphere-Imposter type
  77790. */
  77791. static SphereImpostor: number;
  77792. /**
  77793. * Box-Imposter type
  77794. */
  77795. static BoxImpostor: number;
  77796. /**
  77797. * Plane-Imposter type
  77798. */
  77799. static PlaneImpostor: number;
  77800. /**
  77801. * Mesh-imposter type
  77802. */
  77803. static MeshImpostor: number;
  77804. /**
  77805. * Cylinder-Imposter type
  77806. */
  77807. static CylinderImpostor: number;
  77808. /**
  77809. * Particle-Imposter type
  77810. */
  77811. static ParticleImpostor: number;
  77812. /**
  77813. * Heightmap-Imposter type
  77814. */
  77815. static HeightmapImpostor: number;
  77816. }
  77817. }
  77818. declare module BABYLON {
  77819. /**
  77820. * Class used to represent a specific level of detail of a mesh
  77821. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77822. */
  77823. export class MeshLODLevel {
  77824. /** Defines the distance where this level should star being displayed */
  77825. distance: number;
  77826. /** Defines the mesh to use to render this level */
  77827. mesh: Nullable<Mesh>;
  77828. /**
  77829. * Creates a new LOD level
  77830. * @param distance defines the distance where this level should star being displayed
  77831. * @param mesh defines the mesh to use to render this level
  77832. */
  77833. constructor(
  77834. /** Defines the distance where this level should star being displayed */
  77835. distance: number,
  77836. /** Defines the mesh to use to render this level */
  77837. mesh: Nullable<Mesh>);
  77838. }
  77839. /**
  77840. * @hidden
  77841. **/
  77842. export class _CreationDataStorage {
  77843. closePath?: boolean;
  77844. closeArray?: boolean;
  77845. idx: number[];
  77846. dashSize: number;
  77847. gapSize: number;
  77848. path3D: Path3D;
  77849. pathArray: Vector3[][];
  77850. arc: number;
  77851. radius: number;
  77852. cap: number;
  77853. tessellation: number;
  77854. }
  77855. /**
  77856. * @hidden
  77857. **/
  77858. class _InstanceDataStorage {
  77859. visibleInstances: any;
  77860. renderIdForInstances: number[];
  77861. batchCache: _InstancesBatch;
  77862. instancesBufferSize: number;
  77863. instancesBuffer: Nullable<Buffer>;
  77864. instancesData: Float32Array;
  77865. overridenInstanceCount: number;
  77866. }
  77867. /**
  77868. * @hidden
  77869. **/
  77870. export class _InstancesBatch {
  77871. mustReturn: boolean;
  77872. visibleInstances: Nullable<InstancedMesh[]>[];
  77873. renderSelf: boolean[];
  77874. }
  77875. /**
  77876. * Class used to represent renderable models
  77877. */
  77878. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77879. /**
  77880. * Mesh side orientation : usually the external or front surface
  77881. */
  77882. static readonly FRONTSIDE: number;
  77883. /**
  77884. * Mesh side orientation : usually the internal or back surface
  77885. */
  77886. static readonly BACKSIDE: number;
  77887. /**
  77888. * Mesh side orientation : both internal and external or front and back surfaces
  77889. */
  77890. static readonly DOUBLESIDE: number;
  77891. /**
  77892. * Mesh side orientation : by default, `FRONTSIDE`
  77893. */
  77894. static readonly DEFAULTSIDE: number;
  77895. /**
  77896. * Mesh cap setting : no cap
  77897. */
  77898. static readonly NO_CAP: number;
  77899. /**
  77900. * Mesh cap setting : one cap at the beginning of the mesh
  77901. */
  77902. static readonly CAP_START: number;
  77903. /**
  77904. * Mesh cap setting : one cap at the end of the mesh
  77905. */
  77906. static readonly CAP_END: number;
  77907. /**
  77908. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77909. */
  77910. static readonly CAP_ALL: number;
  77911. /**
  77912. * Gets the default side orientation.
  77913. * @param orientation the orientation to value to attempt to get
  77914. * @returns the default orientation
  77915. * @hidden
  77916. */
  77917. static _GetDefaultSideOrientation(orientation?: number): number;
  77918. private _onBeforeRenderObservable;
  77919. private _onBeforeBindObservable;
  77920. private _onAfterRenderObservable;
  77921. private _onBeforeDrawObservable;
  77922. /**
  77923. * An event triggered before rendering the mesh
  77924. */
  77925. readonly onBeforeRenderObservable: Observable<Mesh>;
  77926. /**
  77927. * An event triggered before binding the mesh
  77928. */
  77929. readonly onBeforeBindObservable: Observable<Mesh>;
  77930. /**
  77931. * An event triggered after rendering the mesh
  77932. */
  77933. readonly onAfterRenderObservable: Observable<Mesh>;
  77934. /**
  77935. * An event triggered before drawing the mesh
  77936. */
  77937. readonly onBeforeDrawObservable: Observable<Mesh>;
  77938. private _onBeforeDrawObserver;
  77939. /**
  77940. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77941. */
  77942. onBeforeDraw: () => void;
  77943. /**
  77944. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77945. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77946. */
  77947. delayLoadState: number;
  77948. /**
  77949. * Gets the list of instances created from this mesh
  77950. * it is not supposed to be modified manually.
  77951. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77952. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77953. */
  77954. instances: InstancedMesh[];
  77955. /**
  77956. * Gets the file containing delay loading data for this mesh
  77957. */
  77958. delayLoadingFile: string;
  77959. /** @hidden */
  77960. _binaryInfo: any;
  77961. private _LODLevels;
  77962. /**
  77963. * User defined function used to change how LOD level selection is done
  77964. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77965. */
  77966. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77967. private _morphTargetManager;
  77968. /**
  77969. * Gets or sets the morph target manager
  77970. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77971. */
  77972. morphTargetManager: Nullable<MorphTargetManager>;
  77973. /** @hidden */
  77974. _creationDataStorage: Nullable<_CreationDataStorage>;
  77975. /** @hidden */
  77976. _geometry: Nullable<Geometry>;
  77977. /** @hidden */
  77978. _delayInfo: Array<string>;
  77979. /** @hidden */
  77980. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77981. /** @hidden */
  77982. _instanceDataStorage: _InstanceDataStorage;
  77983. private _effectiveMaterial;
  77984. /** @hidden */
  77985. _shouldGenerateFlatShading: boolean;
  77986. private _preActivateId;
  77987. /** @hidden */
  77988. _originalBuilderSideOrientation: number;
  77989. /**
  77990. * Use this property to change the original side orientation defined at construction time
  77991. */
  77992. overrideMaterialSideOrientation: Nullable<number>;
  77993. private _areNormalsFrozen;
  77994. private _sourcePositions;
  77995. private _sourceNormals;
  77996. private _source;
  77997. private meshMap;
  77998. /**
  77999. * Gets the source mesh (the one used to clone this one from)
  78000. */
  78001. readonly source: Nullable<Mesh>;
  78002. /**
  78003. * Gets or sets a boolean indicating that this mesh does not use index buffer
  78004. */
  78005. isUnIndexed: boolean;
  78006. /**
  78007. * @constructor
  78008. * @param name The value used by scene.getMeshByName() to do a lookup.
  78009. * @param scene The scene to add this mesh to.
  78010. * @param parent The parent of this mesh, if it has one
  78011. * @param source An optional Mesh from which geometry is shared, cloned.
  78012. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  78013. * When false, achieved by calling a clone(), also passing False.
  78014. * This will make creation of children, recursive.
  78015. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  78016. */
  78017. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  78018. /**
  78019. * Gets the class name
  78020. * @returns the string "Mesh".
  78021. */
  78022. getClassName(): string;
  78023. /** @hidden */
  78024. readonly _isMesh: boolean;
  78025. /**
  78026. * Returns a description of this mesh
  78027. * @param fullDetails define if full details about this mesh must be used
  78028. * @returns a descriptive string representing this mesh
  78029. */
  78030. toString(fullDetails?: boolean): string;
  78031. /** @hidden */
  78032. _unBindEffect(): void;
  78033. /**
  78034. * Gets a boolean indicating if this mesh has LOD
  78035. */
  78036. readonly hasLODLevels: boolean;
  78037. /**
  78038. * Gets the list of MeshLODLevel associated with the current mesh
  78039. * @returns an array of MeshLODLevel
  78040. */
  78041. getLODLevels(): MeshLODLevel[];
  78042. private _sortLODLevels;
  78043. /**
  78044. * Add a mesh as LOD level triggered at the given distance.
  78045. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78046. * @param distance The distance from the center of the object to show this level
  78047. * @param mesh The mesh to be added as LOD level (can be null)
  78048. * @return This mesh (for chaining)
  78049. */
  78050. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  78051. /**
  78052. * Returns the LOD level mesh at the passed distance or null if not found.
  78053. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78054. * @param distance The distance from the center of the object to show this level
  78055. * @returns a Mesh or `null`
  78056. */
  78057. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  78058. /**
  78059. * Remove a mesh from the LOD array
  78060. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78061. * @param mesh defines the mesh to be removed
  78062. * @return This mesh (for chaining)
  78063. */
  78064. removeLODLevel(mesh: Mesh): Mesh;
  78065. /**
  78066. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  78067. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78068. * @param camera defines the camera to use to compute distance
  78069. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  78070. * @return This mesh (for chaining)
  78071. */
  78072. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  78073. /**
  78074. * Gets the mesh internal Geometry object
  78075. */
  78076. readonly geometry: Nullable<Geometry>;
  78077. /**
  78078. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  78079. * @returns the total number of vertices
  78080. */
  78081. getTotalVertices(): number;
  78082. /**
  78083. * Returns the content of an associated vertex buffer
  78084. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78085. * - VertexBuffer.PositionKind
  78086. * - VertexBuffer.UVKind
  78087. * - VertexBuffer.UV2Kind
  78088. * - VertexBuffer.UV3Kind
  78089. * - VertexBuffer.UV4Kind
  78090. * - VertexBuffer.UV5Kind
  78091. * - VertexBuffer.UV6Kind
  78092. * - VertexBuffer.ColorKind
  78093. * - VertexBuffer.MatricesIndicesKind
  78094. * - VertexBuffer.MatricesIndicesExtraKind
  78095. * - VertexBuffer.MatricesWeightsKind
  78096. * - VertexBuffer.MatricesWeightsExtraKind
  78097. * @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
  78098. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  78099. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  78100. */
  78101. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78102. /**
  78103. * Returns the mesh VertexBuffer object from the requested `kind`
  78104. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78105. * - VertexBuffer.PositionKind
  78106. * - VertexBuffer.UVKind
  78107. * - VertexBuffer.UV2Kind
  78108. * - VertexBuffer.UV3Kind
  78109. * - VertexBuffer.UV4Kind
  78110. * - VertexBuffer.UV5Kind
  78111. * - VertexBuffer.UV6Kind
  78112. * - VertexBuffer.ColorKind
  78113. * - VertexBuffer.MatricesIndicesKind
  78114. * - VertexBuffer.MatricesIndicesExtraKind
  78115. * - VertexBuffer.MatricesWeightsKind
  78116. * - VertexBuffer.MatricesWeightsExtraKind
  78117. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  78118. */
  78119. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  78120. /**
  78121. * Tests if a specific vertex buffer is associated with this mesh
  78122. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78123. * - VertexBuffer.PositionKind
  78124. * - VertexBuffer.UVKind
  78125. * - VertexBuffer.UV2Kind
  78126. * - VertexBuffer.UV3Kind
  78127. * - VertexBuffer.UV4Kind
  78128. * - VertexBuffer.UV5Kind
  78129. * - VertexBuffer.UV6Kind
  78130. * - VertexBuffer.ColorKind
  78131. * - VertexBuffer.MatricesIndicesKind
  78132. * - VertexBuffer.MatricesIndicesExtraKind
  78133. * - VertexBuffer.MatricesWeightsKind
  78134. * - VertexBuffer.MatricesWeightsExtraKind
  78135. * @returns a boolean
  78136. */
  78137. isVerticesDataPresent(kind: string): boolean;
  78138. /**
  78139. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  78140. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78141. * - VertexBuffer.PositionKind
  78142. * - VertexBuffer.UVKind
  78143. * - VertexBuffer.UV2Kind
  78144. * - VertexBuffer.UV3Kind
  78145. * - VertexBuffer.UV4Kind
  78146. * - VertexBuffer.UV5Kind
  78147. * - VertexBuffer.UV6Kind
  78148. * - VertexBuffer.ColorKind
  78149. * - VertexBuffer.MatricesIndicesKind
  78150. * - VertexBuffer.MatricesIndicesExtraKind
  78151. * - VertexBuffer.MatricesWeightsKind
  78152. * - VertexBuffer.MatricesWeightsExtraKind
  78153. * @returns a boolean
  78154. */
  78155. isVertexBufferUpdatable(kind: string): boolean;
  78156. /**
  78157. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  78158. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78159. * - VertexBuffer.PositionKind
  78160. * - VertexBuffer.UVKind
  78161. * - VertexBuffer.UV2Kind
  78162. * - VertexBuffer.UV3Kind
  78163. * - VertexBuffer.UV4Kind
  78164. * - VertexBuffer.UV5Kind
  78165. * - VertexBuffer.UV6Kind
  78166. * - VertexBuffer.ColorKind
  78167. * - VertexBuffer.MatricesIndicesKind
  78168. * - VertexBuffer.MatricesIndicesExtraKind
  78169. * - VertexBuffer.MatricesWeightsKind
  78170. * - VertexBuffer.MatricesWeightsExtraKind
  78171. * @returns an array of strings
  78172. */
  78173. getVerticesDataKinds(): string[];
  78174. /**
  78175. * Returns a positive integer : the total number of indices in this mesh geometry.
  78176. * @returns the numner of indices or zero if the mesh has no geometry.
  78177. */
  78178. getTotalIndices(): number;
  78179. /**
  78180. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78181. * @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.
  78182. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78183. * @returns the indices array or an empty array if the mesh has no geometry
  78184. */
  78185. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78186. readonly isBlocked: boolean;
  78187. /**
  78188. * Determine if the current mesh is ready to be rendered
  78189. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  78190. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  78191. * @returns true if all associated assets are ready (material, textures, shaders)
  78192. */
  78193. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  78194. /**
  78195. * 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.
  78196. */
  78197. readonly areNormalsFrozen: boolean;
  78198. /**
  78199. * 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.
  78200. * @returns the current mesh
  78201. */
  78202. freezeNormals(): Mesh;
  78203. /**
  78204. * 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
  78205. * @returns the current mesh
  78206. */
  78207. unfreezeNormals(): Mesh;
  78208. /**
  78209. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  78210. */
  78211. overridenInstanceCount: number;
  78212. /** @hidden */
  78213. _preActivate(): Mesh;
  78214. /** @hidden */
  78215. _preActivateForIntermediateRendering(renderId: number): Mesh;
  78216. /** @hidden */
  78217. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  78218. /**
  78219. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  78220. * This means the mesh underlying bounding box and sphere are recomputed.
  78221. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  78222. * @returns the current mesh
  78223. */
  78224. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  78225. /** @hidden */
  78226. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  78227. /**
  78228. * This function will subdivide the mesh into multiple submeshes
  78229. * @param count defines the expected number of submeshes
  78230. */
  78231. subdivide(count: number): void;
  78232. /**
  78233. * Copy a FloatArray into a specific associated vertex buffer
  78234. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78235. * - VertexBuffer.PositionKind
  78236. * - VertexBuffer.UVKind
  78237. * - VertexBuffer.UV2Kind
  78238. * - VertexBuffer.UV3Kind
  78239. * - VertexBuffer.UV4Kind
  78240. * - VertexBuffer.UV5Kind
  78241. * - VertexBuffer.UV6Kind
  78242. * - VertexBuffer.ColorKind
  78243. * - VertexBuffer.MatricesIndicesKind
  78244. * - VertexBuffer.MatricesIndicesExtraKind
  78245. * - VertexBuffer.MatricesWeightsKind
  78246. * - VertexBuffer.MatricesWeightsExtraKind
  78247. * @param data defines the data source
  78248. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78249. * @param stride defines the data stride size (can be null)
  78250. * @returns the current mesh
  78251. */
  78252. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  78253. /**
  78254. * Flags an associated vertex buffer as updatable
  78255. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  78256. * - VertexBuffer.PositionKind
  78257. * - VertexBuffer.UVKind
  78258. * - VertexBuffer.UV2Kind
  78259. * - VertexBuffer.UV3Kind
  78260. * - VertexBuffer.UV4Kind
  78261. * - VertexBuffer.UV5Kind
  78262. * - VertexBuffer.UV6Kind
  78263. * - VertexBuffer.ColorKind
  78264. * - VertexBuffer.MatricesIndicesKind
  78265. * - VertexBuffer.MatricesIndicesExtraKind
  78266. * - VertexBuffer.MatricesWeightsKind
  78267. * - VertexBuffer.MatricesWeightsExtraKind
  78268. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78269. */
  78270. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  78271. /**
  78272. * Sets the mesh global Vertex Buffer
  78273. * @param buffer defines the buffer to use
  78274. * @returns the current mesh
  78275. */
  78276. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  78277. /**
  78278. * Update a specific associated vertex buffer
  78279. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78280. * - VertexBuffer.PositionKind
  78281. * - VertexBuffer.UVKind
  78282. * - VertexBuffer.UV2Kind
  78283. * - VertexBuffer.UV3Kind
  78284. * - VertexBuffer.UV4Kind
  78285. * - VertexBuffer.UV5Kind
  78286. * - VertexBuffer.UV6Kind
  78287. * - VertexBuffer.ColorKind
  78288. * - VertexBuffer.MatricesIndicesKind
  78289. * - VertexBuffer.MatricesIndicesExtraKind
  78290. * - VertexBuffer.MatricesWeightsKind
  78291. * - VertexBuffer.MatricesWeightsExtraKind
  78292. * @param data defines the data source
  78293. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  78294. * @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)
  78295. * @returns the current mesh
  78296. */
  78297. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  78298. /**
  78299. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  78300. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  78301. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  78302. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  78303. * @returns the current mesh
  78304. */
  78305. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  78306. /**
  78307. * Creates a un-shared specific occurence of the geometry for the mesh.
  78308. * @returns the current mesh
  78309. */
  78310. makeGeometryUnique(): Mesh;
  78311. /**
  78312. * Set the index buffer of this mesh
  78313. * @param indices defines the source data
  78314. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  78315. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  78316. * @returns the current mesh
  78317. */
  78318. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  78319. /**
  78320. * Update the current index buffer
  78321. * @param indices defines the source data
  78322. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  78323. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  78324. * @returns the current mesh
  78325. */
  78326. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  78327. /**
  78328. * Invert the geometry to move from a right handed system to a left handed one.
  78329. * @returns the current mesh
  78330. */
  78331. toLeftHanded(): Mesh;
  78332. /** @hidden */
  78333. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  78334. /** @hidden */
  78335. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  78336. /**
  78337. * Registers for this mesh a javascript function called just before the rendering process
  78338. * @param func defines the function to call before rendering this mesh
  78339. * @returns the current mesh
  78340. */
  78341. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78342. /**
  78343. * Disposes a previously registered javascript function called before the rendering
  78344. * @param func defines the function to remove
  78345. * @returns the current mesh
  78346. */
  78347. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78348. /**
  78349. * Registers for this mesh a javascript function called just after the rendering is complete
  78350. * @param func defines the function to call after rendering this mesh
  78351. * @returns the current mesh
  78352. */
  78353. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78354. /**
  78355. * Disposes a previously registered javascript function called after the rendering.
  78356. * @param func defines the function to remove
  78357. * @returns the current mesh
  78358. */
  78359. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78360. /** @hidden */
  78361. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  78362. /** @hidden */
  78363. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  78364. /** @hidden */
  78365. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  78366. /**
  78367. * 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
  78368. * @param subMesh defines the subMesh to render
  78369. * @param enableAlphaMode defines if alpha mode can be changed
  78370. * @returns the current mesh
  78371. */
  78372. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  78373. private _onBeforeDraw;
  78374. /**
  78375. * Renormalize the mesh and patch it up if there are no weights
  78376. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  78377. * However in the case of zero weights then we set just a single influence to 1.
  78378. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  78379. */
  78380. cleanMatrixWeights(): void;
  78381. private normalizeSkinFourWeights;
  78382. private normalizeSkinWeightsAndExtra;
  78383. /**
  78384. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  78385. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  78386. * the user know there was an issue with importing the mesh
  78387. * @returns a validation object with skinned, valid and report string
  78388. */
  78389. validateSkinning(): {
  78390. skinned: boolean;
  78391. valid: boolean;
  78392. report: string;
  78393. };
  78394. /** @hidden */
  78395. _checkDelayState(): Mesh;
  78396. private _queueLoad;
  78397. /**
  78398. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  78399. * A mesh is in the frustum if its bounding box intersects the frustum
  78400. * @param frustumPlanes defines the frustum to test
  78401. * @returns true if the mesh is in the frustum planes
  78402. */
  78403. isInFrustum(frustumPlanes: Plane[]): boolean;
  78404. /**
  78405. * Sets the mesh material by the material or multiMaterial `id` property
  78406. * @param id is a string identifying the material or the multiMaterial
  78407. * @returns the current mesh
  78408. */
  78409. setMaterialByID(id: string): Mesh;
  78410. /**
  78411. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  78412. * @returns an array of IAnimatable
  78413. */
  78414. getAnimatables(): IAnimatable[];
  78415. /**
  78416. * Modifies the mesh geometry according to the passed transformation matrix.
  78417. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  78418. * The mesh normals are modified using the same transformation.
  78419. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78420. * @param transform defines the transform matrix to use
  78421. * @see http://doc.babylonjs.com/resources/baking_transformations
  78422. * @returns the current mesh
  78423. */
  78424. bakeTransformIntoVertices(transform: Matrix): Mesh;
  78425. /**
  78426. * Modifies the mesh geometry according to its own current World Matrix.
  78427. * The mesh World Matrix is then reset.
  78428. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  78429. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78430. * @see http://doc.babylonjs.com/resources/baking_transformations
  78431. * @returns the current mesh
  78432. */
  78433. bakeCurrentTransformIntoVertices(): Mesh;
  78434. /** @hidden */
  78435. readonly _positions: Nullable<Vector3[]>;
  78436. /** @hidden */
  78437. _resetPointsArrayCache(): Mesh;
  78438. /** @hidden */
  78439. _generatePointsArray(): boolean;
  78440. /**
  78441. * Returns a new Mesh object generated from the current mesh properties.
  78442. * This method must not get confused with createInstance()
  78443. * @param name is a string, the name given to the new mesh
  78444. * @param newParent can be any Node object (default `null`)
  78445. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  78446. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  78447. * @returns a new mesh
  78448. */
  78449. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  78450. /**
  78451. * Releases resources associated with this mesh.
  78452. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78453. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78454. */
  78455. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78456. /**
  78457. * Modifies the mesh geometry according to a displacement map.
  78458. * 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.
  78459. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78460. * @param url is a string, the URL from the image file is to be downloaded.
  78461. * @param minHeight is the lower limit of the displacement.
  78462. * @param maxHeight is the upper limit of the displacement.
  78463. * @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.
  78464. * @param uvOffset is an optional vector2 used to offset UV.
  78465. * @param uvScale is an optional vector2 used to scale UV.
  78466. * @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.
  78467. * @returns the Mesh.
  78468. */
  78469. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78470. /**
  78471. * Modifies the mesh geometry according to a displacementMap buffer.
  78472. * 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.
  78473. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78474. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  78475. * @param heightMapWidth is the width of the buffer image.
  78476. * @param heightMapHeight is the height of the buffer image.
  78477. * @param minHeight is the lower limit of the displacement.
  78478. * @param maxHeight is the upper limit of the displacement.
  78479. * @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.
  78480. * @param uvOffset is an optional vector2 used to offset UV.
  78481. * @param uvScale is an optional vector2 used to scale UV.
  78482. * @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.
  78483. * @returns the Mesh.
  78484. */
  78485. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78486. /**
  78487. * Modify the mesh to get a flat shading rendering.
  78488. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  78489. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  78490. * @returns current mesh
  78491. */
  78492. convertToFlatShadedMesh(): Mesh;
  78493. /**
  78494. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  78495. * In other words, more vertices, no more indices and a single bigger VBO.
  78496. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  78497. * @returns current mesh
  78498. */
  78499. convertToUnIndexedMesh(): Mesh;
  78500. /**
  78501. * Inverses facet orientations.
  78502. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  78503. * @param flipNormals will also inverts the normals
  78504. * @returns current mesh
  78505. */
  78506. flipFaces(flipNormals?: boolean): Mesh;
  78507. /** @hidden */
  78508. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  78509. /** @hidden */
  78510. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  78511. /**
  78512. * Creates a new InstancedMesh object from the mesh model.
  78513. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78514. * @param name defines the name of the new instance
  78515. * @returns a new InstancedMesh
  78516. */
  78517. createInstance(name: string): InstancedMesh;
  78518. /**
  78519. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  78520. * After this call, all the mesh instances have the same submeshes than the current mesh.
  78521. * @returns the current mesh
  78522. */
  78523. synchronizeInstances(): Mesh;
  78524. /**
  78525. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  78526. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  78527. * This should be used together with the simplification to avoid disappearing triangles.
  78528. * @param successCallback an optional success callback to be called after the optimization finished.
  78529. * @returns the current mesh
  78530. */
  78531. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  78532. /**
  78533. * Serialize current mesh
  78534. * @param serializationObject defines the object which will receive the serialization data
  78535. */
  78536. serialize(serializationObject: any): void;
  78537. /** @hidden */
  78538. _syncGeometryWithMorphTargetManager(): void;
  78539. /** @hidden */
  78540. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  78541. /**
  78542. * Returns a new Mesh object parsed from the source provided.
  78543. * @param parsedMesh is the source
  78544. * @param scene defines the hosting scene
  78545. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  78546. * @returns a new Mesh
  78547. */
  78548. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  78549. /**
  78550. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  78551. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78552. * @param name defines the name of the mesh to create
  78553. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  78554. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  78555. * @param closePath creates a seam between the first and the last points of each path of the path array
  78556. * @param offset is taken in account only if the `pathArray` is containing a single path
  78557. * @param scene defines the hosting scene
  78558. * @param updatable defines if the mesh must be flagged as updatable
  78559. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78560. * @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)
  78561. * @returns a new Mesh
  78562. */
  78563. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78564. /**
  78565. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  78566. * @param name defines the name of the mesh to create
  78567. * @param radius sets the radius size (float) of the polygon (default 0.5)
  78568. * @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
  78569. * @param scene defines the hosting scene
  78570. * @param updatable defines if the mesh must be flagged as updatable
  78571. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78572. * @returns a new Mesh
  78573. */
  78574. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78575. /**
  78576. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78577. * @param name defines the name of the mesh to create
  78578. * @param size sets the size (float) of each box side (default 1)
  78579. * @param scene defines the hosting scene
  78580. * @param updatable defines if the mesh must be flagged as updatable
  78581. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78582. * @returns a new Mesh
  78583. */
  78584. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78585. /**
  78586. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78587. * @param name defines the name of the mesh to create
  78588. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78589. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78590. * @param scene defines the hosting scene
  78591. * @param updatable defines if the mesh must be flagged as updatable
  78592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78593. * @returns a new Mesh
  78594. */
  78595. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78596. /**
  78597. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78598. * @param name defines the name of the mesh to create
  78599. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78600. * @param diameterTop set the top cap diameter (floats, default 1)
  78601. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78602. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78603. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78604. * @param scene defines the hosting scene
  78605. * @param updatable defines if the mesh must be flagged as updatable
  78606. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78607. * @returns a new Mesh
  78608. */
  78609. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78610. /**
  78611. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78612. * @param name defines the name of the mesh to create
  78613. * @param diameter sets the diameter size (float) of the torus (default 1)
  78614. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78615. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78616. * @param scene defines the hosting scene
  78617. * @param updatable defines if the mesh must be flagged as updatable
  78618. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78619. * @returns a new Mesh
  78620. */
  78621. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78622. /**
  78623. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78624. * @param name defines the name of the mesh to create
  78625. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78626. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78627. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78628. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78629. * @param p the number of windings on X axis (positive integers, default 2)
  78630. * @param q the number of windings on Y axis (positive integers, default 3)
  78631. * @param scene defines the hosting scene
  78632. * @param updatable defines if the mesh must be flagged as updatable
  78633. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78634. * @returns a new Mesh
  78635. */
  78636. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78637. /**
  78638. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78639. * @param name defines the name of the mesh to create
  78640. * @param points is an array successive Vector3
  78641. * @param scene defines the hosting scene
  78642. * @param updatable defines if the mesh must be flagged as updatable
  78643. * @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).
  78644. * @returns a new Mesh
  78645. */
  78646. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78647. /**
  78648. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78649. * @param name defines the name of the mesh to create
  78650. * @param points is an array successive Vector3
  78651. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78652. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78653. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78654. * @param scene defines the hosting scene
  78655. * @param updatable defines if the mesh must be flagged as updatable
  78656. * @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)
  78657. * @returns a new Mesh
  78658. */
  78659. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78660. /**
  78661. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78662. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78663. * 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.
  78664. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78665. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78666. * Remember you can only change the shape positions, not their number when updating a polygon.
  78667. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78668. * @param name defines the name of the mesh to create
  78669. * @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
  78670. * @param scene defines the hosting scene
  78671. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78672. * @param updatable defines if the mesh must be flagged as updatable
  78673. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78674. * @param earcutInjection can be used to inject your own earcut reference
  78675. * @returns a new Mesh
  78676. */
  78677. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78678. /**
  78679. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78680. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78681. * @param name defines the name of the mesh to create
  78682. * @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
  78683. * @param depth defines the height of extrusion
  78684. * @param scene defines the hosting scene
  78685. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78686. * @param updatable defines if the mesh must be flagged as updatable
  78687. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78688. * @param earcutInjection can be used to inject your own earcut reference
  78689. * @returns a new Mesh
  78690. */
  78691. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78692. /**
  78693. * Creates an extruded shape mesh.
  78694. * 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
  78695. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78696. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78697. * @param name defines the name of the mesh to create
  78698. * @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
  78699. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78700. * @param scale is the value to scale the shape
  78701. * @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
  78702. * @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
  78703. * @param scene defines the hosting scene
  78704. * @param updatable defines if the mesh must be flagged as updatable
  78705. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78706. * @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)
  78707. * @returns a new Mesh
  78708. */
  78709. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78710. /**
  78711. * Creates an custom extruded shape mesh.
  78712. * The custom extrusion is a parametric shape.
  78713. * It has no predefined shape. Its final shape will depend on the input parameters.
  78714. * Please consider using the same method from the MeshBuilder class instead
  78715. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78716. * @param name defines the name of the mesh to create
  78717. * @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
  78718. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78719. * @param scaleFunction is a custom Javascript function called on each path point
  78720. * @param rotationFunction is a custom Javascript function called on each path point
  78721. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78722. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78723. * @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
  78724. * @param scene defines the hosting scene
  78725. * @param updatable defines if the mesh must be flagged as updatable
  78726. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78727. * @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)
  78728. * @returns a new Mesh
  78729. */
  78730. 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;
  78731. /**
  78732. * Creates lathe mesh.
  78733. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78734. * Please consider using the same method from the MeshBuilder class instead
  78735. * @param name defines the name of the mesh to create
  78736. * @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
  78737. * @param radius is the radius value of the lathe
  78738. * @param tessellation is the side number of the lathe.
  78739. * @param scene defines the hosting scene
  78740. * @param updatable defines if the mesh must be flagged as updatable
  78741. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78742. * @returns a new Mesh
  78743. */
  78744. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78745. /**
  78746. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78747. * @param name defines the name of the mesh to create
  78748. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78749. * @param scene defines the hosting scene
  78750. * @param updatable defines if the mesh must be flagged as updatable
  78751. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78752. * @returns a new Mesh
  78753. */
  78754. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78755. /**
  78756. * Creates a ground mesh.
  78757. * Please consider using the same method from the MeshBuilder class instead
  78758. * @param name defines the name of the mesh to create
  78759. * @param width set the width of the ground
  78760. * @param height set the height of the ground
  78761. * @param subdivisions sets the number of subdivisions per side
  78762. * @param scene defines the hosting scene
  78763. * @param updatable defines if the mesh must be flagged as updatable
  78764. * @returns a new Mesh
  78765. */
  78766. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78767. /**
  78768. * Creates a tiled ground mesh.
  78769. * Please consider using the same method from the MeshBuilder class instead
  78770. * @param name defines the name of the mesh to create
  78771. * @param xmin set the ground minimum X coordinate
  78772. * @param zmin set the ground minimum Y coordinate
  78773. * @param xmax set the ground maximum X coordinate
  78774. * @param zmax set the ground maximum Z coordinate
  78775. * @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
  78776. * @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
  78777. * @param scene defines the hosting scene
  78778. * @param updatable defines if the mesh must be flagged as updatable
  78779. * @returns a new Mesh
  78780. */
  78781. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78782. w: number;
  78783. h: number;
  78784. }, precision: {
  78785. w: number;
  78786. h: number;
  78787. }, scene: Scene, updatable?: boolean): Mesh;
  78788. /**
  78789. * Creates a ground mesh from a height map.
  78790. * Please consider using the same method from the MeshBuilder class instead
  78791. * @see http://doc.babylonjs.com/babylon101/height_map
  78792. * @param name defines the name of the mesh to create
  78793. * @param url sets the URL of the height map image resource
  78794. * @param width set the ground width size
  78795. * @param height set the ground height size
  78796. * @param subdivisions sets the number of subdivision per side
  78797. * @param minHeight is the minimum altitude on the ground
  78798. * @param maxHeight is the maximum altitude on the ground
  78799. * @param scene defines the hosting scene
  78800. * @param updatable defines if the mesh must be flagged as updatable
  78801. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78802. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78803. * @returns a new Mesh
  78804. */
  78805. 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;
  78806. /**
  78807. * Creates a tube mesh.
  78808. * The tube is a parametric shape.
  78809. * It has no predefined shape. Its final shape will depend on the input parameters.
  78810. * Please consider using the same method from the MeshBuilder class instead
  78811. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78812. * @param name defines the name of the mesh to create
  78813. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78814. * @param radius sets the tube radius size
  78815. * @param tessellation is the number of sides on the tubular surface
  78816. * @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
  78817. * @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
  78818. * @param scene defines the hosting scene
  78819. * @param updatable defines if the mesh must be flagged as updatable
  78820. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78821. * @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)
  78822. * @returns a new Mesh
  78823. */
  78824. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78825. (i: number, distance: number): number;
  78826. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78827. /**
  78828. * Creates a polyhedron mesh.
  78829. * Please consider using the same method from the MeshBuilder class instead.
  78830. * * 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
  78831. * * The parameter `size` (positive float, default 1) sets the polygon size
  78832. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78833. * * 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`
  78834. * * 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
  78835. * * 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)`)
  78836. * * 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
  78837. * * 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
  78838. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78839. * * If you create a double-sided mesh, you can choose what parts of 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
  78840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78841. * @param name defines the name of the mesh to create
  78842. * @param options defines the options used to create the mesh
  78843. * @param scene defines the hosting scene
  78844. * @returns a new Mesh
  78845. */
  78846. static CreatePolyhedron(name: string, options: {
  78847. type?: number;
  78848. size?: number;
  78849. sizeX?: number;
  78850. sizeY?: number;
  78851. sizeZ?: number;
  78852. custom?: any;
  78853. faceUV?: Vector4[];
  78854. faceColors?: Color4[];
  78855. updatable?: boolean;
  78856. sideOrientation?: number;
  78857. }, scene: Scene): Mesh;
  78858. /**
  78859. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78860. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78861. * * 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`)
  78862. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78863. * * 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
  78864. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78865. * * If you create a double-sided mesh, you can choose what parts of 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
  78866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78867. * @param name defines the name of the mesh
  78868. * @param options defines the options used to create the mesh
  78869. * @param scene defines the hosting scene
  78870. * @returns a new Mesh
  78871. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78872. */
  78873. static CreateIcoSphere(name: string, options: {
  78874. radius?: number;
  78875. flat?: boolean;
  78876. subdivisions?: number;
  78877. sideOrientation?: number;
  78878. updatable?: boolean;
  78879. }, scene: Scene): Mesh;
  78880. /**
  78881. * Creates a decal mesh.
  78882. * Please consider using the same method from the MeshBuilder class instead.
  78883. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78884. * @param name defines the name of the mesh
  78885. * @param sourceMesh defines the mesh receiving the decal
  78886. * @param position sets the position of the decal in world coordinates
  78887. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78888. * @param size sets the decal scaling
  78889. * @param angle sets the angle to rotate the decal
  78890. * @returns a new Mesh
  78891. */
  78892. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78893. /**
  78894. * Prepare internal position array for software CPU skinning
  78895. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78896. */
  78897. setPositionsForCPUSkinning(): Float32Array;
  78898. /**
  78899. * Prepare internal normal array for software CPU skinning
  78900. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78901. */
  78902. setNormalsForCPUSkinning(): Float32Array;
  78903. /**
  78904. * Updates the vertex buffer by applying transformation from the bones
  78905. * @param skeleton defines the skeleton to apply to current mesh
  78906. * @returns the current mesh
  78907. */
  78908. applySkeleton(skeleton: Skeleton): Mesh;
  78909. /**
  78910. * 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
  78911. * @param meshes defines the list of meshes to scan
  78912. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78913. */
  78914. static MinMax(meshes: AbstractMesh[]): {
  78915. min: Vector3;
  78916. max: Vector3;
  78917. };
  78918. /**
  78919. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78920. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78921. * @returns a vector3
  78922. */
  78923. static Center(meshesOrMinMaxVector: {
  78924. min: Vector3;
  78925. max: Vector3;
  78926. } | AbstractMesh[]): Vector3;
  78927. /**
  78928. * Merge the array of meshes into a single mesh for performance reasons.
  78929. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78930. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78931. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78932. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78933. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78934. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78935. * @returns a new mesh
  78936. */
  78937. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78938. /** @hidden */
  78939. addInstance(instance: InstancedMesh): void;
  78940. /** @hidden */
  78941. removeInstance(instance: InstancedMesh): void;
  78942. }
  78943. }
  78944. declare module BABYLON {
  78945. /**
  78946. * Base class for the main features of a material in Babylon.js
  78947. */
  78948. export class Material implements IAnimatable {
  78949. /**
  78950. * Returns the triangle fill mode
  78951. */
  78952. static readonly TriangleFillMode: number;
  78953. /**
  78954. * Returns the wireframe mode
  78955. */
  78956. static readonly WireFrameFillMode: number;
  78957. /**
  78958. * Returns the point fill mode
  78959. */
  78960. static readonly PointFillMode: number;
  78961. /**
  78962. * Returns the point list draw mode
  78963. */
  78964. static readonly PointListDrawMode: number;
  78965. /**
  78966. * Returns the line list draw mode
  78967. */
  78968. static readonly LineListDrawMode: number;
  78969. /**
  78970. * Returns the line loop draw mode
  78971. */
  78972. static readonly LineLoopDrawMode: number;
  78973. /**
  78974. * Returns the line strip draw mode
  78975. */
  78976. static readonly LineStripDrawMode: number;
  78977. /**
  78978. * Returns the triangle strip draw mode
  78979. */
  78980. static readonly TriangleStripDrawMode: number;
  78981. /**
  78982. * Returns the triangle fan draw mode
  78983. */
  78984. static readonly TriangleFanDrawMode: number;
  78985. /**
  78986. * Stores the clock-wise side orientation
  78987. */
  78988. static readonly ClockWiseSideOrientation: number;
  78989. /**
  78990. * Stores the counter clock-wise side orientation
  78991. */
  78992. static readonly CounterClockWiseSideOrientation: number;
  78993. /**
  78994. * The dirty texture flag value
  78995. */
  78996. static readonly TextureDirtyFlag: number;
  78997. /**
  78998. * The dirty light flag value
  78999. */
  79000. static readonly LightDirtyFlag: number;
  79001. /**
  79002. * The dirty fresnel flag value
  79003. */
  79004. static readonly FresnelDirtyFlag: number;
  79005. /**
  79006. * The dirty attribute flag value
  79007. */
  79008. static readonly AttributesDirtyFlag: number;
  79009. /**
  79010. * The dirty misc flag value
  79011. */
  79012. static readonly MiscDirtyFlag: number;
  79013. /**
  79014. * The all dirty flag value
  79015. */
  79016. static readonly AllDirtyFlag: number;
  79017. /**
  79018. * The ID of the material
  79019. */
  79020. id: string;
  79021. /**
  79022. * Gets or sets the unique id of the material
  79023. */
  79024. uniqueId: number;
  79025. /**
  79026. * The name of the material
  79027. */
  79028. name: string;
  79029. /**
  79030. * Gets or sets user defined metadata
  79031. */
  79032. metadata: any;
  79033. /**
  79034. * For internal use only. Please do not use.
  79035. */
  79036. reservedDataStore: any;
  79037. /**
  79038. * Specifies if the ready state should be checked on each call
  79039. */
  79040. checkReadyOnEveryCall: boolean;
  79041. /**
  79042. * Specifies if the ready state should be checked once
  79043. */
  79044. checkReadyOnlyOnce: boolean;
  79045. /**
  79046. * The state of the material
  79047. */
  79048. state: string;
  79049. /**
  79050. * The alpha value of the material
  79051. */
  79052. protected _alpha: number;
  79053. /**
  79054. * Sets the alpha value of the material
  79055. */
  79056. /**
  79057. * Gets the alpha value of the material
  79058. */
  79059. alpha: number;
  79060. /**
  79061. * Specifies if back face culling is enabled
  79062. */
  79063. protected _backFaceCulling: boolean;
  79064. /**
  79065. * Sets the back-face culling state
  79066. */
  79067. /**
  79068. * Gets the back-face culling state
  79069. */
  79070. backFaceCulling: boolean;
  79071. /**
  79072. * Stores the value for side orientation
  79073. */
  79074. sideOrientation: number;
  79075. /**
  79076. * Callback triggered when the material is compiled
  79077. */
  79078. onCompiled: (effect: Effect) => void;
  79079. /**
  79080. * Callback triggered when an error occurs
  79081. */
  79082. onError: (effect: Effect, errors: string) => void;
  79083. /**
  79084. * Callback triggered to get the render target textures
  79085. */
  79086. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  79087. /**
  79088. * Gets a boolean indicating that current material needs to register RTT
  79089. */
  79090. readonly hasRenderTargetTextures: boolean;
  79091. /**
  79092. * Specifies if the material should be serialized
  79093. */
  79094. doNotSerialize: boolean;
  79095. /**
  79096. * @hidden
  79097. */
  79098. _storeEffectOnSubMeshes: boolean;
  79099. /**
  79100. * Stores the animations for the material
  79101. */
  79102. animations: Array<Animation>;
  79103. /**
  79104. * An event triggered when the material is disposed
  79105. */
  79106. onDisposeObservable: Observable<Material>;
  79107. /**
  79108. * An observer which watches for dispose events
  79109. */
  79110. private _onDisposeObserver;
  79111. private _onUnBindObservable;
  79112. /**
  79113. * Called during a dispose event
  79114. */
  79115. onDispose: () => void;
  79116. private _onBindObservable;
  79117. /**
  79118. * An event triggered when the material is bound
  79119. */
  79120. readonly onBindObservable: Observable<AbstractMesh>;
  79121. /**
  79122. * An observer which watches for bind events
  79123. */
  79124. private _onBindObserver;
  79125. /**
  79126. * Called during a bind event
  79127. */
  79128. onBind: (Mesh: AbstractMesh) => void;
  79129. /**
  79130. * An event triggered when the material is unbound
  79131. */
  79132. readonly onUnBindObservable: Observable<Material>;
  79133. /**
  79134. * Stores the value of the alpha mode
  79135. */
  79136. private _alphaMode;
  79137. /**
  79138. * Sets the value of the alpha mode.
  79139. *
  79140. * | Value | Type | Description |
  79141. * | --- | --- | --- |
  79142. * | 0 | ALPHA_DISABLE | |
  79143. * | 1 | ALPHA_ADD | |
  79144. * | 2 | ALPHA_COMBINE | |
  79145. * | 3 | ALPHA_SUBTRACT | |
  79146. * | 4 | ALPHA_MULTIPLY | |
  79147. * | 5 | ALPHA_MAXIMIZED | |
  79148. * | 6 | ALPHA_ONEONE | |
  79149. * | 7 | ALPHA_PREMULTIPLIED | |
  79150. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  79151. * | 9 | ALPHA_INTERPOLATE | |
  79152. * | 10 | ALPHA_SCREENMODE | |
  79153. *
  79154. */
  79155. /**
  79156. * Gets the value of the alpha mode
  79157. */
  79158. alphaMode: number;
  79159. /**
  79160. * Stores the state of the need depth pre-pass value
  79161. */
  79162. private _needDepthPrePass;
  79163. /**
  79164. * Sets the need depth pre-pass value
  79165. */
  79166. /**
  79167. * Gets the depth pre-pass value
  79168. */
  79169. needDepthPrePass: boolean;
  79170. /**
  79171. * Specifies if depth writing should be disabled
  79172. */
  79173. disableDepthWrite: boolean;
  79174. /**
  79175. * Specifies if depth writing should be forced
  79176. */
  79177. forceDepthWrite: boolean;
  79178. /**
  79179. * Specifies if there should be a separate pass for culling
  79180. */
  79181. separateCullingPass: boolean;
  79182. /**
  79183. * Stores the state specifing if fog should be enabled
  79184. */
  79185. private _fogEnabled;
  79186. /**
  79187. * Sets the state for enabling fog
  79188. */
  79189. /**
  79190. * Gets the value of the fog enabled state
  79191. */
  79192. fogEnabled: boolean;
  79193. /**
  79194. * Stores the size of points
  79195. */
  79196. pointSize: number;
  79197. /**
  79198. * Stores the z offset value
  79199. */
  79200. zOffset: number;
  79201. /**
  79202. * Gets a value specifying if wireframe mode is enabled
  79203. */
  79204. /**
  79205. * Sets the state of wireframe mode
  79206. */
  79207. wireframe: boolean;
  79208. /**
  79209. * Gets the value specifying if point clouds are enabled
  79210. */
  79211. /**
  79212. * Sets the state of point cloud mode
  79213. */
  79214. pointsCloud: boolean;
  79215. /**
  79216. * Gets the material fill mode
  79217. */
  79218. /**
  79219. * Sets the material fill mode
  79220. */
  79221. fillMode: number;
  79222. /**
  79223. * @hidden
  79224. * Stores the effects for the material
  79225. */
  79226. _effect: Nullable<Effect>;
  79227. /**
  79228. * @hidden
  79229. * Specifies if the material was previously ready
  79230. */
  79231. _wasPreviouslyReady: boolean;
  79232. /**
  79233. * Specifies if uniform buffers should be used
  79234. */
  79235. private _useUBO;
  79236. /**
  79237. * Stores a reference to the scene
  79238. */
  79239. private _scene;
  79240. /**
  79241. * Stores the fill mode state
  79242. */
  79243. private _fillMode;
  79244. /**
  79245. * Specifies if the depth write state should be cached
  79246. */
  79247. private _cachedDepthWriteState;
  79248. /**
  79249. * Stores the uniform buffer
  79250. */
  79251. protected _uniformBuffer: UniformBuffer;
  79252. /** @hidden */
  79253. _indexInSceneMaterialArray: number;
  79254. /** @hidden */
  79255. meshMap: Nullable<{
  79256. [id: string]: AbstractMesh | undefined;
  79257. }>;
  79258. /**
  79259. * Creates a material instance
  79260. * @param name defines the name of the material
  79261. * @param scene defines the scene to reference
  79262. * @param doNotAdd specifies if the material should be added to the scene
  79263. */
  79264. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  79265. /**
  79266. * Returns a string representation of the current material
  79267. * @param fullDetails defines a boolean indicating which levels of logging is desired
  79268. * @returns a string with material information
  79269. */
  79270. toString(fullDetails?: boolean): string;
  79271. /**
  79272. * Gets the class name of the material
  79273. * @returns a string with the class name of the material
  79274. */
  79275. getClassName(): string;
  79276. /**
  79277. * Specifies if updates for the material been locked
  79278. */
  79279. readonly isFrozen: boolean;
  79280. /**
  79281. * Locks updates for the material
  79282. */
  79283. freeze(): void;
  79284. /**
  79285. * Unlocks updates for the material
  79286. */
  79287. unfreeze(): void;
  79288. /**
  79289. * Specifies if the material is ready to be used
  79290. * @param mesh defines the mesh to check
  79291. * @param useInstances specifies if instances should be used
  79292. * @returns a boolean indicating if the material is ready to be used
  79293. */
  79294. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  79295. /**
  79296. * Specifies that the submesh is ready to be used
  79297. * @param mesh defines the mesh to check
  79298. * @param subMesh defines which submesh to check
  79299. * @param useInstances specifies that instances should be used
  79300. * @returns a boolean indicating that the submesh is ready or not
  79301. */
  79302. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  79303. /**
  79304. * Returns the material effect
  79305. * @returns the effect associated with the material
  79306. */
  79307. getEffect(): Nullable<Effect>;
  79308. /**
  79309. * Returns the current scene
  79310. * @returns a Scene
  79311. */
  79312. getScene(): Scene;
  79313. /**
  79314. * Specifies if the material will require alpha blending
  79315. * @returns a boolean specifying if alpha blending is needed
  79316. */
  79317. needAlphaBlending(): boolean;
  79318. /**
  79319. * Specifies if the mesh will require alpha blending
  79320. * @param mesh defines the mesh to check
  79321. * @returns a boolean specifying if alpha blending is needed for the mesh
  79322. */
  79323. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  79324. /**
  79325. * Specifies if this material should be rendered in alpha test mode
  79326. * @returns a boolean specifying if an alpha test is needed.
  79327. */
  79328. needAlphaTesting(): boolean;
  79329. /**
  79330. * Gets the texture used for the alpha test
  79331. * @returns the texture to use for alpha testing
  79332. */
  79333. getAlphaTestTexture(): Nullable<BaseTexture>;
  79334. /**
  79335. * Marks the material to indicate that it needs to be re-calculated
  79336. */
  79337. markDirty(): void;
  79338. /** @hidden */
  79339. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  79340. /**
  79341. * Binds the material to the mesh
  79342. * @param world defines the world transformation matrix
  79343. * @param mesh defines the mesh to bind the material to
  79344. */
  79345. bind(world: Matrix, mesh?: Mesh): void;
  79346. /**
  79347. * Binds the submesh to the material
  79348. * @param world defines the world transformation matrix
  79349. * @param mesh defines the mesh containing the submesh
  79350. * @param subMesh defines the submesh to bind the material to
  79351. */
  79352. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  79353. /**
  79354. * Binds the world matrix to the material
  79355. * @param world defines the world transformation matrix
  79356. */
  79357. bindOnlyWorldMatrix(world: Matrix): void;
  79358. /**
  79359. * Binds the scene's uniform buffer to the effect.
  79360. * @param effect defines the effect to bind to the scene uniform buffer
  79361. * @param sceneUbo defines the uniform buffer storing scene data
  79362. */
  79363. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  79364. /**
  79365. * Binds the view matrix to the effect
  79366. * @param effect defines the effect to bind the view matrix to
  79367. */
  79368. bindView(effect: Effect): void;
  79369. /**
  79370. * Binds the view projection matrix to the effect
  79371. * @param effect defines the effect to bind the view projection matrix to
  79372. */
  79373. bindViewProjection(effect: Effect): void;
  79374. /**
  79375. * Specifies if material alpha testing should be turned on for the mesh
  79376. * @param mesh defines the mesh to check
  79377. */
  79378. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  79379. /**
  79380. * Processes to execute after binding the material to a mesh
  79381. * @param mesh defines the rendered mesh
  79382. */
  79383. protected _afterBind(mesh?: Mesh): void;
  79384. /**
  79385. * Unbinds the material from the mesh
  79386. */
  79387. unbind(): void;
  79388. /**
  79389. * Gets the active textures from the material
  79390. * @returns an array of textures
  79391. */
  79392. getActiveTextures(): BaseTexture[];
  79393. /**
  79394. * Specifies if the material uses a texture
  79395. * @param texture defines the texture to check against the material
  79396. * @returns a boolean specifying if the material uses the texture
  79397. */
  79398. hasTexture(texture: BaseTexture): boolean;
  79399. /**
  79400. * Makes a duplicate of the material, and gives it a new name
  79401. * @param name defines the new name for the duplicated material
  79402. * @returns the cloned material
  79403. */
  79404. clone(name: string): Nullable<Material>;
  79405. /**
  79406. * Gets the meshes bound to the material
  79407. * @returns an array of meshes bound to the material
  79408. */
  79409. getBindedMeshes(): AbstractMesh[];
  79410. /**
  79411. * Force shader compilation
  79412. * @param mesh defines the mesh associated with this material
  79413. * @param onCompiled defines a function to execute once the material is compiled
  79414. * @param options defines the options to configure the compilation
  79415. */
  79416. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  79417. clipPlane: boolean;
  79418. }>): void;
  79419. /**
  79420. * Force shader compilation
  79421. * @param mesh defines the mesh that will use this material
  79422. * @param options defines additional options for compiling the shaders
  79423. * @returns a promise that resolves when the compilation completes
  79424. */
  79425. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  79426. clipPlane: boolean;
  79427. }>): Promise<void>;
  79428. private static readonly _ImageProcessingDirtyCallBack;
  79429. private static readonly _TextureDirtyCallBack;
  79430. private static readonly _FresnelDirtyCallBack;
  79431. private static readonly _MiscDirtyCallBack;
  79432. private static readonly _LightsDirtyCallBack;
  79433. private static readonly _AttributeDirtyCallBack;
  79434. private static _FresnelAndMiscDirtyCallBack;
  79435. private static _TextureAndMiscDirtyCallBack;
  79436. private static readonly _DirtyCallbackArray;
  79437. private static readonly _RunDirtyCallBacks;
  79438. /**
  79439. * Marks a define in the material to indicate that it needs to be re-computed
  79440. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  79441. */
  79442. markAsDirty(flag: number): void;
  79443. /**
  79444. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  79445. * @param func defines a function which checks material defines against the submeshes
  79446. */
  79447. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  79448. /**
  79449. * Indicates that image processing needs to be re-calculated for all submeshes
  79450. */
  79451. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  79452. /**
  79453. * Indicates that textures need to be re-calculated for all submeshes
  79454. */
  79455. protected _markAllSubMeshesAsTexturesDirty(): void;
  79456. /**
  79457. * Indicates that fresnel needs to be re-calculated for all submeshes
  79458. */
  79459. protected _markAllSubMeshesAsFresnelDirty(): void;
  79460. /**
  79461. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  79462. */
  79463. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  79464. /**
  79465. * Indicates that lights need to be re-calculated for all submeshes
  79466. */
  79467. protected _markAllSubMeshesAsLightsDirty(): void;
  79468. /**
  79469. * Indicates that attributes need to be re-calculated for all submeshes
  79470. */
  79471. protected _markAllSubMeshesAsAttributesDirty(): void;
  79472. /**
  79473. * Indicates that misc needs to be re-calculated for all submeshes
  79474. */
  79475. protected _markAllSubMeshesAsMiscDirty(): void;
  79476. /**
  79477. * Indicates that textures and misc need to be re-calculated for all submeshes
  79478. */
  79479. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  79480. /**
  79481. * Disposes the material
  79482. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79483. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79484. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79485. */
  79486. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79487. /** @hidden */
  79488. private releaseVertexArrayObject;
  79489. /**
  79490. * Serializes this material
  79491. * @returns the serialized material object
  79492. */
  79493. serialize(): any;
  79494. /**
  79495. * Creates a material from parsed material data
  79496. * @param parsedMaterial defines parsed material data
  79497. * @param scene defines the hosting scene
  79498. * @param rootUrl defines the root URL to use to load textures
  79499. * @returns a new material
  79500. */
  79501. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  79502. }
  79503. }
  79504. declare module BABYLON {
  79505. /**
  79506. * Base class for submeshes
  79507. */
  79508. export class BaseSubMesh {
  79509. /** @hidden */
  79510. _materialDefines: Nullable<MaterialDefines>;
  79511. /** @hidden */
  79512. _materialEffect: Nullable<Effect>;
  79513. /**
  79514. * Gets associated effect
  79515. */
  79516. readonly effect: Nullable<Effect>;
  79517. /**
  79518. * Sets associated effect (effect used to render this submesh)
  79519. * @param effect defines the effect to associate with
  79520. * @param defines defines the set of defines used to compile this effect
  79521. */
  79522. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  79523. }
  79524. /**
  79525. * Defines a subdivision inside a mesh
  79526. */
  79527. export class SubMesh extends BaseSubMesh implements ICullable {
  79528. /** the material index to use */
  79529. materialIndex: number;
  79530. /** vertex index start */
  79531. verticesStart: number;
  79532. /** vertices count */
  79533. verticesCount: number;
  79534. /** index start */
  79535. indexStart: number;
  79536. /** indices count */
  79537. indexCount: number;
  79538. /** @hidden */
  79539. _linesIndexCount: number;
  79540. private _mesh;
  79541. private _renderingMesh;
  79542. private _boundingInfo;
  79543. private _linesIndexBuffer;
  79544. /** @hidden */
  79545. _lastColliderWorldVertices: Nullable<Vector3[]>;
  79546. /** @hidden */
  79547. _trianglePlanes: Plane[];
  79548. /** @hidden */
  79549. _lastColliderTransformMatrix: Matrix;
  79550. /** @hidden */
  79551. _renderId: number;
  79552. /** @hidden */
  79553. _alphaIndex: number;
  79554. /** @hidden */
  79555. _distanceToCamera: number;
  79556. /** @hidden */
  79557. _id: number;
  79558. private _currentMaterial;
  79559. /**
  79560. * Add a new submesh to a mesh
  79561. * @param materialIndex defines the material index to use
  79562. * @param verticesStart defines vertex index start
  79563. * @param verticesCount defines vertices count
  79564. * @param indexStart defines index start
  79565. * @param indexCount defines indices count
  79566. * @param mesh defines the parent mesh
  79567. * @param renderingMesh defines an optional rendering mesh
  79568. * @param createBoundingBox defines if bounding box should be created for this submesh
  79569. * @returns the new submesh
  79570. */
  79571. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  79572. /**
  79573. * Creates a new submesh
  79574. * @param materialIndex defines the material index to use
  79575. * @param verticesStart defines vertex index start
  79576. * @param verticesCount defines vertices count
  79577. * @param indexStart defines index start
  79578. * @param indexCount defines indices count
  79579. * @param mesh defines the parent mesh
  79580. * @param renderingMesh defines an optional rendering mesh
  79581. * @param createBoundingBox defines if bounding box should be created for this submesh
  79582. */
  79583. constructor(
  79584. /** the material index to use */
  79585. materialIndex: number,
  79586. /** vertex index start */
  79587. verticesStart: number,
  79588. /** vertices count */
  79589. verticesCount: number,
  79590. /** index start */
  79591. indexStart: number,
  79592. /** indices count */
  79593. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79594. /**
  79595. * Returns true if this submesh covers the entire parent mesh
  79596. * @ignorenaming
  79597. */
  79598. readonly IsGlobal: boolean;
  79599. /**
  79600. * Returns the submesh BoudingInfo object
  79601. * @returns current bounding info (or mesh's one if the submesh is global)
  79602. */
  79603. getBoundingInfo(): BoundingInfo;
  79604. /**
  79605. * Sets the submesh BoundingInfo
  79606. * @param boundingInfo defines the new bounding info to use
  79607. * @returns the SubMesh
  79608. */
  79609. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79610. /**
  79611. * Returns the mesh of the current submesh
  79612. * @return the parent mesh
  79613. */
  79614. getMesh(): AbstractMesh;
  79615. /**
  79616. * Returns the rendering mesh of the submesh
  79617. * @returns the rendering mesh (could be different from parent mesh)
  79618. */
  79619. getRenderingMesh(): Mesh;
  79620. /**
  79621. * Returns the submesh material
  79622. * @returns null or the current material
  79623. */
  79624. getMaterial(): Nullable<Material>;
  79625. /**
  79626. * Sets a new updated BoundingInfo object to the submesh
  79627. * @returns the SubMesh
  79628. */
  79629. refreshBoundingInfo(): SubMesh;
  79630. /** @hidden */
  79631. _checkCollision(collider: Collider): boolean;
  79632. /**
  79633. * Updates the submesh BoundingInfo
  79634. * @param world defines the world matrix to use to update the bounding info
  79635. * @returns the submesh
  79636. */
  79637. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79638. /**
  79639. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79640. * @param frustumPlanes defines the frustum planes
  79641. * @returns true if the submesh is intersecting with the frustum
  79642. */
  79643. isInFrustum(frustumPlanes: Plane[]): boolean;
  79644. /**
  79645. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79646. * @param frustumPlanes defines the frustum planes
  79647. * @returns true if the submesh is inside the frustum
  79648. */
  79649. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79650. /**
  79651. * Renders the submesh
  79652. * @param enableAlphaMode defines if alpha needs to be used
  79653. * @returns the submesh
  79654. */
  79655. render(enableAlphaMode: boolean): SubMesh;
  79656. /**
  79657. * @hidden
  79658. */
  79659. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79660. /**
  79661. * Checks if the submesh intersects with a ray
  79662. * @param ray defines the ray to test
  79663. * @returns true is the passed ray intersects the submesh bounding box
  79664. */
  79665. canIntersects(ray: Ray): boolean;
  79666. /**
  79667. * Intersects current submesh with a ray
  79668. * @param ray defines the ray to test
  79669. * @param positions defines mesh's positions array
  79670. * @param indices defines mesh's indices array
  79671. * @param fastCheck defines if only bounding info should be used
  79672. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79673. * @returns intersection info or null if no intersection
  79674. */
  79675. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79676. /** @hidden */
  79677. private _intersectLines;
  79678. /** @hidden */
  79679. private _intersectTriangles;
  79680. /** @hidden */
  79681. _rebuild(): void;
  79682. /**
  79683. * Creates a new submesh from the passed mesh
  79684. * @param newMesh defines the new hosting mesh
  79685. * @param newRenderingMesh defines an optional rendering mesh
  79686. * @returns the new submesh
  79687. */
  79688. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79689. /**
  79690. * Release associated resources
  79691. */
  79692. dispose(): void;
  79693. /**
  79694. * Gets the class name
  79695. * @returns the string "SubMesh".
  79696. */
  79697. getClassName(): string;
  79698. /**
  79699. * Creates a new submesh from indices data
  79700. * @param materialIndex the index of the main mesh material
  79701. * @param startIndex the index where to start the copy in the mesh indices array
  79702. * @param indexCount the number of indices to copy then from the startIndex
  79703. * @param mesh the main mesh to create the submesh from
  79704. * @param renderingMesh the optional rendering mesh
  79705. * @returns a new submesh
  79706. */
  79707. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79708. }
  79709. }
  79710. declare module BABYLON {
  79711. /**
  79712. * Class used to store geometry data (vertex buffers + index buffer)
  79713. */
  79714. export class Geometry implements IGetSetVerticesData {
  79715. /**
  79716. * Gets or sets the ID of the geometry
  79717. */
  79718. id: string;
  79719. /**
  79720. * Gets or sets the unique ID of the geometry
  79721. */
  79722. uniqueId: number;
  79723. /**
  79724. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79725. */
  79726. delayLoadState: number;
  79727. /**
  79728. * Gets the file containing the data to load when running in delay load state
  79729. */
  79730. delayLoadingFile: Nullable<string>;
  79731. /**
  79732. * Callback called when the geometry is updated
  79733. */
  79734. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79735. private _scene;
  79736. private _engine;
  79737. private _meshes;
  79738. private _totalVertices;
  79739. /** @hidden */
  79740. _indices: IndicesArray;
  79741. /** @hidden */
  79742. _vertexBuffers: {
  79743. [key: string]: VertexBuffer;
  79744. };
  79745. private _isDisposed;
  79746. private _extend;
  79747. private _boundingBias;
  79748. /** @hidden */
  79749. _delayInfo: Array<string>;
  79750. private _indexBuffer;
  79751. private _indexBufferIsUpdatable;
  79752. /** @hidden */
  79753. _boundingInfo: Nullable<BoundingInfo>;
  79754. /** @hidden */
  79755. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79756. /** @hidden */
  79757. _softwareSkinningFrameId: number;
  79758. private _vertexArrayObjects;
  79759. private _updatable;
  79760. /** @hidden */
  79761. _positions: Nullable<Vector3[]>;
  79762. /**
  79763. * 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
  79764. */
  79765. /**
  79766. * 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
  79767. */
  79768. boundingBias: Vector2;
  79769. /**
  79770. * Static function used to attach a new empty geometry to a mesh
  79771. * @param mesh defines the mesh to attach the geometry to
  79772. * @returns the new Geometry
  79773. */
  79774. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79775. /**
  79776. * Creates a new geometry
  79777. * @param id defines the unique ID
  79778. * @param scene defines the hosting scene
  79779. * @param vertexData defines the VertexData used to get geometry data
  79780. * @param updatable defines if geometry must be updatable (false by default)
  79781. * @param mesh defines the mesh that will be associated with the geometry
  79782. */
  79783. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79784. /**
  79785. * Gets the current extend of the geometry
  79786. */
  79787. readonly extend: {
  79788. minimum: Vector3;
  79789. maximum: Vector3;
  79790. };
  79791. /**
  79792. * Gets the hosting scene
  79793. * @returns the hosting Scene
  79794. */
  79795. getScene(): Scene;
  79796. /**
  79797. * Gets the hosting engine
  79798. * @returns the hosting Engine
  79799. */
  79800. getEngine(): Engine;
  79801. /**
  79802. * Defines if the geometry is ready to use
  79803. * @returns true if the geometry is ready to be used
  79804. */
  79805. isReady(): boolean;
  79806. /**
  79807. * Gets a value indicating that the geometry should not be serialized
  79808. */
  79809. readonly doNotSerialize: boolean;
  79810. /** @hidden */
  79811. _rebuild(): void;
  79812. /**
  79813. * Affects all geometry data in one call
  79814. * @param vertexData defines the geometry data
  79815. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79816. */
  79817. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79818. /**
  79819. * Set specific vertex data
  79820. * @param kind defines the data kind (Position, normal, etc...)
  79821. * @param data defines the vertex data to use
  79822. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79823. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79824. */
  79825. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79826. /**
  79827. * Removes a specific vertex data
  79828. * @param kind defines the data kind (Position, normal, etc...)
  79829. */
  79830. removeVerticesData(kind: string): void;
  79831. /**
  79832. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79833. * @param buffer defines the vertex buffer to use
  79834. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79835. */
  79836. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79837. /**
  79838. * Update a specific vertex buffer
  79839. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79840. * It will do nothing if the buffer is not updatable
  79841. * @param kind defines the data kind (Position, normal, etc...)
  79842. * @param data defines the data to use
  79843. * @param offset defines the offset in the target buffer where to store the data
  79844. * @param useBytes set to true if the offset is in bytes
  79845. */
  79846. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79847. /**
  79848. * Update a specific vertex buffer
  79849. * This function will create a new buffer if the current one is not updatable
  79850. * @param kind defines the data kind (Position, normal, etc...)
  79851. * @param data defines the data to use
  79852. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79853. */
  79854. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79855. private _updateBoundingInfo;
  79856. /** @hidden */
  79857. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79858. /**
  79859. * Gets total number of vertices
  79860. * @returns the total number of vertices
  79861. */
  79862. getTotalVertices(): number;
  79863. /**
  79864. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79865. * @param kind defines the data kind (Position, normal, etc...)
  79866. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79867. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79868. * @returns a float array containing vertex data
  79869. */
  79870. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79871. /**
  79872. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79873. * @param kind defines the data kind (Position, normal, etc...)
  79874. * @returns true if the vertex buffer with the specified kind is updatable
  79875. */
  79876. isVertexBufferUpdatable(kind: string): boolean;
  79877. /**
  79878. * Gets a specific vertex buffer
  79879. * @param kind defines the data kind (Position, normal, etc...)
  79880. * @returns a VertexBuffer
  79881. */
  79882. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79883. /**
  79884. * Returns all vertex buffers
  79885. * @return an object holding all vertex buffers indexed by kind
  79886. */
  79887. getVertexBuffers(): Nullable<{
  79888. [key: string]: VertexBuffer;
  79889. }>;
  79890. /**
  79891. * Gets a boolean indicating if specific vertex buffer is present
  79892. * @param kind defines the data kind (Position, normal, etc...)
  79893. * @returns true if data is present
  79894. */
  79895. isVerticesDataPresent(kind: string): boolean;
  79896. /**
  79897. * Gets a list of all attached data kinds (Position, normal, etc...)
  79898. * @returns a list of string containing all kinds
  79899. */
  79900. getVerticesDataKinds(): string[];
  79901. /**
  79902. * Update index buffer
  79903. * @param indices defines the indices to store in the index buffer
  79904. * @param offset defines the offset in the target buffer where to store the data
  79905. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  79906. */
  79907. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  79908. /**
  79909. * Creates a new index buffer
  79910. * @param indices defines the indices to store in the index buffer
  79911. * @param totalVertices defines the total number of vertices (could be null)
  79912. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79913. */
  79914. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79915. /**
  79916. * Return the total number of indices
  79917. * @returns the total number of indices
  79918. */
  79919. getTotalIndices(): number;
  79920. /**
  79921. * Gets the index buffer array
  79922. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79923. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79924. * @returns the index buffer array
  79925. */
  79926. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79927. /**
  79928. * Gets the index buffer
  79929. * @return the index buffer
  79930. */
  79931. getIndexBuffer(): Nullable<WebGLBuffer>;
  79932. /** @hidden */
  79933. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79934. /**
  79935. * Release the associated resources for a specific mesh
  79936. * @param mesh defines the source mesh
  79937. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79938. */
  79939. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79940. /**
  79941. * Apply current geometry to a given mesh
  79942. * @param mesh defines the mesh to apply geometry to
  79943. */
  79944. applyToMesh(mesh: Mesh): void;
  79945. private _updateExtend;
  79946. private _applyToMesh;
  79947. private notifyUpdate;
  79948. /**
  79949. * Load the geometry if it was flagged as delay loaded
  79950. * @param scene defines the hosting scene
  79951. * @param onLoaded defines a callback called when the geometry is loaded
  79952. */
  79953. load(scene: Scene, onLoaded?: () => void): void;
  79954. private _queueLoad;
  79955. /**
  79956. * Invert the geometry to move from a right handed system to a left handed one.
  79957. */
  79958. toLeftHanded(): void;
  79959. /** @hidden */
  79960. _resetPointsArrayCache(): void;
  79961. /** @hidden */
  79962. _generatePointsArray(): boolean;
  79963. /**
  79964. * Gets a value indicating if the geometry is disposed
  79965. * @returns true if the geometry was disposed
  79966. */
  79967. isDisposed(): boolean;
  79968. private _disposeVertexArrayObjects;
  79969. /**
  79970. * Free all associated resources
  79971. */
  79972. dispose(): void;
  79973. /**
  79974. * Clone the current geometry into a new geometry
  79975. * @param id defines the unique ID of the new geometry
  79976. * @returns a new geometry object
  79977. */
  79978. copy(id: string): Geometry;
  79979. /**
  79980. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79981. * @return a JSON representation of the current geometry data (without the vertices data)
  79982. */
  79983. serialize(): any;
  79984. private toNumberArray;
  79985. /**
  79986. * Serialize all vertices data into a JSON oject
  79987. * @returns a JSON representation of the current geometry data
  79988. */
  79989. serializeVerticeData(): any;
  79990. /**
  79991. * Extracts a clone of a mesh geometry
  79992. * @param mesh defines the source mesh
  79993. * @param id defines the unique ID of the new geometry object
  79994. * @returns the new geometry object
  79995. */
  79996. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79997. /**
  79998. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79999. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  80000. * Be aware Math.random() could cause collisions, but:
  80001. * "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"
  80002. * @returns a string containing a new GUID
  80003. */
  80004. static RandomId(): string;
  80005. /** @hidden */
  80006. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  80007. private static _CleanMatricesWeights;
  80008. /**
  80009. * Create a new geometry from persisted data (Using .babylon file format)
  80010. * @param parsedVertexData defines the persisted data
  80011. * @param scene defines the hosting scene
  80012. * @param rootUrl defines the root url to use to load assets (like delayed data)
  80013. * @returns the new geometry object
  80014. */
  80015. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  80016. }
  80017. }
  80018. declare module BABYLON {
  80019. /**
  80020. * Define an interface for all classes that will get and set the data on vertices
  80021. */
  80022. export interface IGetSetVerticesData {
  80023. /**
  80024. * Gets a boolean indicating if specific vertex data is present
  80025. * @param kind defines the vertex data kind to use
  80026. * @returns true is data kind is present
  80027. */
  80028. isVerticesDataPresent(kind: string): boolean;
  80029. /**
  80030. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80031. * @param kind defines the data kind (Position, normal, etc...)
  80032. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80033. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80034. * @returns a float array containing vertex data
  80035. */
  80036. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80037. /**
  80038. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80039. * @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.
  80040. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80041. * @returns the indices array or an empty array if the mesh has no geometry
  80042. */
  80043. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80044. /**
  80045. * Set specific vertex data
  80046. * @param kind defines the data kind (Position, normal, etc...)
  80047. * @param data defines the vertex data to use
  80048. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80049. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80050. */
  80051. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  80052. /**
  80053. * Update a specific associated vertex buffer
  80054. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80055. * - VertexBuffer.PositionKind
  80056. * - VertexBuffer.UVKind
  80057. * - VertexBuffer.UV2Kind
  80058. * - VertexBuffer.UV3Kind
  80059. * - VertexBuffer.UV4Kind
  80060. * - VertexBuffer.UV5Kind
  80061. * - VertexBuffer.UV6Kind
  80062. * - VertexBuffer.ColorKind
  80063. * - VertexBuffer.MatricesIndicesKind
  80064. * - VertexBuffer.MatricesIndicesExtraKind
  80065. * - VertexBuffer.MatricesWeightsKind
  80066. * - VertexBuffer.MatricesWeightsExtraKind
  80067. * @param data defines the data source
  80068. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80069. * @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)
  80070. */
  80071. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  80072. /**
  80073. * Creates a new index buffer
  80074. * @param indices defines the indices to store in the index buffer
  80075. * @param totalVertices defines the total number of vertices (could be null)
  80076. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80077. */
  80078. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  80079. }
  80080. /**
  80081. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  80082. */
  80083. export class VertexData {
  80084. /**
  80085. * Mesh side orientation : usually the external or front surface
  80086. */
  80087. static readonly FRONTSIDE: number;
  80088. /**
  80089. * Mesh side orientation : usually the internal or back surface
  80090. */
  80091. static readonly BACKSIDE: number;
  80092. /**
  80093. * Mesh side orientation : both internal and external or front and back surfaces
  80094. */
  80095. static readonly DOUBLESIDE: number;
  80096. /**
  80097. * Mesh side orientation : by default, `FRONTSIDE`
  80098. */
  80099. static readonly DEFAULTSIDE: number;
  80100. /**
  80101. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  80102. */
  80103. positions: Nullable<FloatArray>;
  80104. /**
  80105. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  80106. */
  80107. normals: Nullable<FloatArray>;
  80108. /**
  80109. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  80110. */
  80111. tangents: Nullable<FloatArray>;
  80112. /**
  80113. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80114. */
  80115. uvs: Nullable<FloatArray>;
  80116. /**
  80117. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80118. */
  80119. uvs2: Nullable<FloatArray>;
  80120. /**
  80121. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80122. */
  80123. uvs3: Nullable<FloatArray>;
  80124. /**
  80125. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80126. */
  80127. uvs4: Nullable<FloatArray>;
  80128. /**
  80129. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80130. */
  80131. uvs5: Nullable<FloatArray>;
  80132. /**
  80133. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80134. */
  80135. uvs6: Nullable<FloatArray>;
  80136. /**
  80137. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  80138. */
  80139. colors: Nullable<FloatArray>;
  80140. /**
  80141. * 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).
  80142. */
  80143. matricesIndices: Nullable<FloatArray>;
  80144. /**
  80145. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  80146. */
  80147. matricesWeights: Nullable<FloatArray>;
  80148. /**
  80149. * An array extending the number of possible indices
  80150. */
  80151. matricesIndicesExtra: Nullable<FloatArray>;
  80152. /**
  80153. * An array extending the number of possible weights when the number of indices is extended
  80154. */
  80155. matricesWeightsExtra: Nullable<FloatArray>;
  80156. /**
  80157. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  80158. */
  80159. indices: Nullable<IndicesArray>;
  80160. /**
  80161. * Uses the passed data array to set the set the values for the specified kind of data
  80162. * @param data a linear array of floating numbers
  80163. * @param kind the type of data that is being set, eg positions, colors etc
  80164. */
  80165. set(data: FloatArray, kind: string): void;
  80166. /**
  80167. * Associates the vertexData to the passed Mesh.
  80168. * Sets it as updatable or not (default `false`)
  80169. * @param mesh the mesh the vertexData is applied to
  80170. * @param updatable when used and having the value true allows new data to update the vertexData
  80171. * @returns the VertexData
  80172. */
  80173. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  80174. /**
  80175. * Associates the vertexData to the passed Geometry.
  80176. * Sets it as updatable or not (default `false`)
  80177. * @param geometry the geometry the vertexData is applied to
  80178. * @param updatable when used and having the value true allows new data to update the vertexData
  80179. * @returns VertexData
  80180. */
  80181. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  80182. /**
  80183. * Updates the associated mesh
  80184. * @param mesh the mesh to be updated
  80185. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80186. * @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
  80187. * @returns VertexData
  80188. */
  80189. updateMesh(mesh: Mesh): VertexData;
  80190. /**
  80191. * Updates the associated geometry
  80192. * @param geometry the geometry to be updated
  80193. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80194. * @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
  80195. * @returns VertexData.
  80196. */
  80197. updateGeometry(geometry: Geometry): VertexData;
  80198. private _applyTo;
  80199. private _update;
  80200. /**
  80201. * Transforms each position and each normal of the vertexData according to the passed Matrix
  80202. * @param matrix the transforming matrix
  80203. * @returns the VertexData
  80204. */
  80205. transform(matrix: Matrix): VertexData;
  80206. /**
  80207. * Merges the passed VertexData into the current one
  80208. * @param other the VertexData to be merged into the current one
  80209. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  80210. * @returns the modified VertexData
  80211. */
  80212. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  80213. private _mergeElement;
  80214. private _validate;
  80215. /**
  80216. * Serializes the VertexData
  80217. * @returns a serialized object
  80218. */
  80219. serialize(): any;
  80220. /**
  80221. * Extracts the vertexData from a mesh
  80222. * @param mesh the mesh from which to extract the VertexData
  80223. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  80224. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80225. * @returns the object VertexData associated to the passed mesh
  80226. */
  80227. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80228. /**
  80229. * Extracts the vertexData from the geometry
  80230. * @param geometry the geometry from which to extract the VertexData
  80231. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  80232. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80233. * @returns the object VertexData associated to the passed mesh
  80234. */
  80235. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80236. private static _ExtractFrom;
  80237. /**
  80238. * Creates the VertexData for a Ribbon
  80239. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  80240. * * pathArray array of paths, each of which an array of successive Vector3
  80241. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  80242. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  80243. * * 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
  80244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80245. * * 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)
  80246. * * 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)
  80247. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  80248. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  80249. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  80250. * @returns the VertexData of the ribbon
  80251. */
  80252. static CreateRibbon(options: {
  80253. pathArray: Vector3[][];
  80254. closeArray?: boolean;
  80255. closePath?: boolean;
  80256. offset?: number;
  80257. sideOrientation?: number;
  80258. frontUVs?: Vector4;
  80259. backUVs?: Vector4;
  80260. invertUV?: boolean;
  80261. uvs?: Vector2[];
  80262. colors?: Color4[];
  80263. }): VertexData;
  80264. /**
  80265. * Creates the VertexData for a box
  80266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80267. * * size sets the width, height and depth of the box to the value of size, optional default 1
  80268. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  80269. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  80270. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  80271. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  80272. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  80273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80274. * * 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)
  80275. * * 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)
  80276. * @returns the VertexData of the box
  80277. */
  80278. static CreateBox(options: {
  80279. size?: number;
  80280. width?: number;
  80281. height?: number;
  80282. depth?: number;
  80283. faceUV?: Vector4[];
  80284. faceColors?: Color4[];
  80285. sideOrientation?: number;
  80286. frontUVs?: Vector4;
  80287. backUVs?: Vector4;
  80288. }): VertexData;
  80289. /**
  80290. * Creates the VertexData for an ellipsoid, defaults to a sphere
  80291. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80292. * * segments sets the number of horizontal strips optional, default 32
  80293. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  80294. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  80295. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  80296. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  80297. * * 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
  80298. * * 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
  80299. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80300. * * 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)
  80301. * * 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)
  80302. * @returns the VertexData of the ellipsoid
  80303. */
  80304. static CreateSphere(options: {
  80305. segments?: number;
  80306. diameter?: number;
  80307. diameterX?: number;
  80308. diameterY?: number;
  80309. diameterZ?: number;
  80310. arc?: number;
  80311. slice?: number;
  80312. sideOrientation?: number;
  80313. frontUVs?: Vector4;
  80314. backUVs?: Vector4;
  80315. }): VertexData;
  80316. /**
  80317. * Creates the VertexData for a cylinder, cone or prism
  80318. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80319. * * height sets the height (y direction) of the cylinder, optional, default 2
  80320. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  80321. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  80322. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  80323. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80324. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  80325. * * 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
  80326. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80327. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80328. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  80329. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  80330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80331. * * 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)
  80332. * * 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)
  80333. * @returns the VertexData of the cylinder, cone or prism
  80334. */
  80335. static CreateCylinder(options: {
  80336. height?: number;
  80337. diameterTop?: number;
  80338. diameterBottom?: number;
  80339. diameter?: number;
  80340. tessellation?: number;
  80341. subdivisions?: number;
  80342. arc?: number;
  80343. faceColors?: Color4[];
  80344. faceUV?: Vector4[];
  80345. hasRings?: boolean;
  80346. enclose?: boolean;
  80347. sideOrientation?: number;
  80348. frontUVs?: Vector4;
  80349. backUVs?: Vector4;
  80350. }): VertexData;
  80351. /**
  80352. * Creates the VertexData for a torus
  80353. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80354. * * diameter the diameter of the torus, optional default 1
  80355. * * thickness the diameter of the tube forming the torus, optional default 0.5
  80356. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80357. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80358. * * 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)
  80359. * * 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)
  80360. * @returns the VertexData of the torus
  80361. */
  80362. static CreateTorus(options: {
  80363. diameter?: number;
  80364. thickness?: number;
  80365. tessellation?: number;
  80366. sideOrientation?: number;
  80367. frontUVs?: Vector4;
  80368. backUVs?: Vector4;
  80369. }): VertexData;
  80370. /**
  80371. * Creates the VertexData of the LineSystem
  80372. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  80373. * - lines an array of lines, each line being an array of successive Vector3
  80374. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  80375. * @returns the VertexData of the LineSystem
  80376. */
  80377. static CreateLineSystem(options: {
  80378. lines: Vector3[][];
  80379. colors?: Nullable<Color4[][]>;
  80380. }): VertexData;
  80381. /**
  80382. * Create the VertexData for a DashedLines
  80383. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  80384. * - points an array successive Vector3
  80385. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  80386. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  80387. * - dashNb the intended total number of dashes, optional, default 200
  80388. * @returns the VertexData for the DashedLines
  80389. */
  80390. static CreateDashedLines(options: {
  80391. points: Vector3[];
  80392. dashSize?: number;
  80393. gapSize?: number;
  80394. dashNb?: number;
  80395. }): VertexData;
  80396. /**
  80397. * Creates the VertexData for a Ground
  80398. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80399. * - width the width (x direction) of the ground, optional, default 1
  80400. * - height the height (z direction) of the ground, optional, default 1
  80401. * - subdivisions the number of subdivisions per side, optional, default 1
  80402. * @returns the VertexData of the Ground
  80403. */
  80404. static CreateGround(options: {
  80405. width?: number;
  80406. height?: number;
  80407. subdivisions?: number;
  80408. subdivisionsX?: number;
  80409. subdivisionsY?: number;
  80410. }): VertexData;
  80411. /**
  80412. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  80413. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80414. * * xmin the ground minimum X coordinate, optional, default -1
  80415. * * zmin the ground minimum Z coordinate, optional, default -1
  80416. * * xmax the ground maximum X coordinate, optional, default 1
  80417. * * zmax the ground maximum Z coordinate, optional, default 1
  80418. * * 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}
  80419. * * 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}
  80420. * @returns the VertexData of the TiledGround
  80421. */
  80422. static CreateTiledGround(options: {
  80423. xmin: number;
  80424. zmin: number;
  80425. xmax: number;
  80426. zmax: number;
  80427. subdivisions?: {
  80428. w: number;
  80429. h: number;
  80430. };
  80431. precision?: {
  80432. w: number;
  80433. h: number;
  80434. };
  80435. }): VertexData;
  80436. /**
  80437. * Creates the VertexData of the Ground designed from a heightmap
  80438. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  80439. * * width the width (x direction) of the ground
  80440. * * height the height (z direction) of the ground
  80441. * * subdivisions the number of subdivisions per side
  80442. * * minHeight the minimum altitude on the ground, optional, default 0
  80443. * * maxHeight the maximum altitude on the ground, optional default 1
  80444. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  80445. * * buffer the array holding the image color data
  80446. * * bufferWidth the width of image
  80447. * * bufferHeight the height of image
  80448. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  80449. * @returns the VertexData of the Ground designed from a heightmap
  80450. */
  80451. static CreateGroundFromHeightMap(options: {
  80452. width: number;
  80453. height: number;
  80454. subdivisions: number;
  80455. minHeight: number;
  80456. maxHeight: number;
  80457. colorFilter: Color3;
  80458. buffer: Uint8Array;
  80459. bufferWidth: number;
  80460. bufferHeight: number;
  80461. alphaFilter: number;
  80462. }): VertexData;
  80463. /**
  80464. * Creates the VertexData for a Plane
  80465. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  80466. * * size sets the width and height of the plane to the value of size, optional default 1
  80467. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  80468. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  80469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80470. * * 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)
  80471. * * 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)
  80472. * @returns the VertexData of the box
  80473. */
  80474. static CreatePlane(options: {
  80475. size?: number;
  80476. width?: number;
  80477. height?: number;
  80478. sideOrientation?: number;
  80479. frontUVs?: Vector4;
  80480. backUVs?: Vector4;
  80481. }): VertexData;
  80482. /**
  80483. * Creates the VertexData of the Disc or regular Polygon
  80484. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  80485. * * radius the radius of the disc, optional default 0.5
  80486. * * tessellation the number of polygon sides, optional, default 64
  80487. * * 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
  80488. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80489. * * 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)
  80490. * * 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)
  80491. * @returns the VertexData of the box
  80492. */
  80493. static CreateDisc(options: {
  80494. radius?: number;
  80495. tessellation?: number;
  80496. arc?: number;
  80497. sideOrientation?: number;
  80498. frontUVs?: Vector4;
  80499. backUVs?: Vector4;
  80500. }): VertexData;
  80501. /**
  80502. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  80503. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  80504. * @param polygon a mesh built from polygonTriangulation.build()
  80505. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80506. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80507. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80508. * @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)
  80509. * @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)
  80510. * @returns the VertexData of the Polygon
  80511. */
  80512. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  80513. /**
  80514. * Creates the VertexData of the IcoSphere
  80515. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  80516. * * radius the radius of the IcoSphere, optional default 1
  80517. * * radiusX allows stretching in the x direction, optional, default radius
  80518. * * radiusY allows stretching in the y direction, optional, default radius
  80519. * * radiusZ allows stretching in the z direction, optional, default radius
  80520. * * flat when true creates a flat shaded mesh, optional, default true
  80521. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80522. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80523. * * 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)
  80524. * * 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)
  80525. * @returns the VertexData of the IcoSphere
  80526. */
  80527. static CreateIcoSphere(options: {
  80528. radius?: number;
  80529. radiusX?: number;
  80530. radiusY?: number;
  80531. radiusZ?: number;
  80532. flat?: boolean;
  80533. subdivisions?: number;
  80534. sideOrientation?: number;
  80535. frontUVs?: Vector4;
  80536. backUVs?: Vector4;
  80537. }): VertexData;
  80538. /**
  80539. * Creates the VertexData for a Polyhedron
  80540. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  80541. * * type provided types are:
  80542. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80543. * * 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)
  80544. * * size the size of the IcoSphere, optional default 1
  80545. * * sizeX allows stretching in the x direction, optional, default size
  80546. * * sizeY allows stretching in the y direction, optional, default size
  80547. * * sizeZ allows stretching in the z direction, optional, default size
  80548. * * 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
  80549. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80550. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80551. * * flat when true creates a flat shaded mesh, optional, default true
  80552. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80553. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80554. * * 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)
  80555. * * 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)
  80556. * @returns the VertexData of the Polyhedron
  80557. */
  80558. static CreatePolyhedron(options: {
  80559. type?: number;
  80560. size?: number;
  80561. sizeX?: number;
  80562. sizeY?: number;
  80563. sizeZ?: number;
  80564. custom?: any;
  80565. faceUV?: Vector4[];
  80566. faceColors?: Color4[];
  80567. flat?: boolean;
  80568. sideOrientation?: number;
  80569. frontUVs?: Vector4;
  80570. backUVs?: Vector4;
  80571. }): VertexData;
  80572. /**
  80573. * Creates the VertexData for a TorusKnot
  80574. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  80575. * * radius the radius of the torus knot, optional, default 2
  80576. * * tube the thickness of the tube, optional, default 0.5
  80577. * * radialSegments the number of sides on each tube segments, optional, default 32
  80578. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80579. * * p the number of windings around the z axis, optional, default 2
  80580. * * q the number of windings around the x axis, optional, default 3
  80581. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80582. * * 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)
  80583. * * 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)
  80584. * @returns the VertexData of the Torus Knot
  80585. */
  80586. static CreateTorusKnot(options: {
  80587. radius?: number;
  80588. tube?: number;
  80589. radialSegments?: number;
  80590. tubularSegments?: number;
  80591. p?: number;
  80592. q?: number;
  80593. sideOrientation?: number;
  80594. frontUVs?: Vector4;
  80595. backUVs?: Vector4;
  80596. }): VertexData;
  80597. /**
  80598. * Compute normals for given positions and indices
  80599. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80600. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80601. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80602. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80603. * * facetNormals : optional array of facet normals (vector3)
  80604. * * facetPositions : optional array of facet positions (vector3)
  80605. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80606. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80607. * * bInfo : optional bounding info, required for facetPartitioning computation
  80608. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80609. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80610. * * useRightHandedSystem: optional boolean to for right handed system computation
  80611. * * depthSort : optional boolean to enable the facet depth sort computation
  80612. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80613. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80614. */
  80615. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80616. facetNormals?: any;
  80617. facetPositions?: any;
  80618. facetPartitioning?: any;
  80619. ratio?: number;
  80620. bInfo?: any;
  80621. bbSize?: Vector3;
  80622. subDiv?: any;
  80623. useRightHandedSystem?: boolean;
  80624. depthSort?: boolean;
  80625. distanceTo?: Vector3;
  80626. depthSortedFacets?: any;
  80627. }): void;
  80628. /** @hidden */
  80629. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80630. /**
  80631. * Applies VertexData created from the imported parameters to the geometry
  80632. * @param parsedVertexData the parsed data from an imported file
  80633. * @param geometry the geometry to apply the VertexData to
  80634. */
  80635. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80636. }
  80637. }
  80638. declare module BABYLON {
  80639. /**
  80640. * Class containing static functions to help procedurally build meshes
  80641. */
  80642. export class DiscBuilder {
  80643. /**
  80644. * Creates a plane polygonal mesh. By default, this is a disc
  80645. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80646. * * 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
  80647. * * 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
  80648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80651. * @param name defines the name of the mesh
  80652. * @param options defines the options used to create the mesh
  80653. * @param scene defines the hosting scene
  80654. * @returns the plane polygonal mesh
  80655. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80656. */
  80657. static CreateDisc(name: string, options: {
  80658. radius?: number;
  80659. tessellation?: number;
  80660. arc?: number;
  80661. updatable?: boolean;
  80662. sideOrientation?: number;
  80663. frontUVs?: Vector4;
  80664. backUVs?: Vector4;
  80665. }, scene?: Nullable<Scene>): Mesh;
  80666. }
  80667. }
  80668. declare module BABYLON {
  80669. /**
  80670. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80671. *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.
  80672. * The SPS is also a particle system. It provides some methods to manage the particles.
  80673. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80674. *
  80675. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80676. */
  80677. export class SolidParticleSystem implements IDisposable {
  80678. /**
  80679. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80680. * Example : var p = SPS.particles[i];
  80681. */
  80682. particles: SolidParticle[];
  80683. /**
  80684. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80685. */
  80686. nbParticles: number;
  80687. /**
  80688. * If the particles must ever face the camera (default false). Useful for planar particles.
  80689. */
  80690. billboard: boolean;
  80691. /**
  80692. * Recompute normals when adding a shape
  80693. */
  80694. recomputeNormals: boolean;
  80695. /**
  80696. * This a counter ofr your own usage. It's not set by any SPS functions.
  80697. */
  80698. counter: number;
  80699. /**
  80700. * The SPS name. This name is also given to the underlying mesh.
  80701. */
  80702. name: string;
  80703. /**
  80704. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80705. */
  80706. mesh: Mesh;
  80707. /**
  80708. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80709. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80710. */
  80711. vars: any;
  80712. /**
  80713. * This array is populated when the SPS is set as 'pickable'.
  80714. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80715. * Each element of this array is an object `{idx: int, faceId: int}`.
  80716. * `idx` is the picked particle index in the `SPS.particles` array
  80717. * `faceId` is the picked face index counted within this particle.
  80718. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80719. */
  80720. pickedParticles: {
  80721. idx: number;
  80722. faceId: number;
  80723. }[];
  80724. /**
  80725. * This array is populated when `enableDepthSort` is set to true.
  80726. * Each element of this array is an instance of the class DepthSortedParticle.
  80727. */
  80728. depthSortedParticles: DepthSortedParticle[];
  80729. /**
  80730. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80731. * @hidden
  80732. */
  80733. _bSphereOnly: boolean;
  80734. /**
  80735. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80736. * @hidden
  80737. */
  80738. _bSphereRadiusFactor: number;
  80739. private _scene;
  80740. private _positions;
  80741. private _indices;
  80742. private _normals;
  80743. private _colors;
  80744. private _uvs;
  80745. private _indices32;
  80746. private _positions32;
  80747. private _normals32;
  80748. private _fixedNormal32;
  80749. private _colors32;
  80750. private _uvs32;
  80751. private _index;
  80752. private _updatable;
  80753. private _pickable;
  80754. private _isVisibilityBoxLocked;
  80755. private _alwaysVisible;
  80756. private _depthSort;
  80757. private _shapeCounter;
  80758. private _copy;
  80759. private _color;
  80760. private _computeParticleColor;
  80761. private _computeParticleTexture;
  80762. private _computeParticleRotation;
  80763. private _computeParticleVertex;
  80764. private _computeBoundingBox;
  80765. private _depthSortParticles;
  80766. private _camera;
  80767. private _mustUnrotateFixedNormals;
  80768. private _particlesIntersect;
  80769. private _needs32Bits;
  80770. /**
  80771. * Creates a SPS (Solid Particle System) object.
  80772. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80773. * @param scene (Scene) is the scene in which the SPS is added.
  80774. * @param options defines the options of the sps e.g.
  80775. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80776. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80777. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80778. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80779. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80780. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80781. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80782. */
  80783. constructor(name: string, scene: Scene, options?: {
  80784. updatable?: boolean;
  80785. isPickable?: boolean;
  80786. enableDepthSort?: boolean;
  80787. particleIntersection?: boolean;
  80788. boundingSphereOnly?: boolean;
  80789. bSphereRadiusFactor?: number;
  80790. });
  80791. /**
  80792. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80793. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80794. * @returns the created mesh
  80795. */
  80796. buildMesh(): Mesh;
  80797. /**
  80798. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80799. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80800. * Thus the particles generated from `digest()` have their property `position` set yet.
  80801. * @param mesh ( Mesh ) is the mesh to be digested
  80802. * @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
  80803. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80804. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80805. * @returns the current SPS
  80806. */
  80807. digest(mesh: Mesh, options?: {
  80808. facetNb?: number;
  80809. number?: number;
  80810. delta?: number;
  80811. }): SolidParticleSystem;
  80812. private _unrotateFixedNormals;
  80813. private _resetCopy;
  80814. private _meshBuilder;
  80815. private _posToShape;
  80816. private _uvsToShapeUV;
  80817. private _addParticle;
  80818. /**
  80819. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80820. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80821. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80822. * @param nb (positive integer) the number of particles to be created from this model
  80823. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80824. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80825. * @returns the number of shapes in the system
  80826. */
  80827. addShape(mesh: Mesh, nb: number, options?: {
  80828. positionFunction?: any;
  80829. vertexFunction?: any;
  80830. }): number;
  80831. private _rebuildParticle;
  80832. /**
  80833. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80834. * @returns the SPS.
  80835. */
  80836. rebuildMesh(): SolidParticleSystem;
  80837. /**
  80838. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80839. * This method calls `updateParticle()` for each particle of the SPS.
  80840. * For an animated SPS, it is usually called within the render loop.
  80841. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80842. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80843. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80844. * @returns the SPS.
  80845. */
  80846. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80847. /**
  80848. * Disposes the SPS.
  80849. */
  80850. dispose(): void;
  80851. /**
  80852. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80853. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80854. * @returns the SPS.
  80855. */
  80856. refreshVisibleSize(): SolidParticleSystem;
  80857. /**
  80858. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80859. * @param size the size (float) of the visibility box
  80860. * note : this doesn't lock the SPS mesh bounding box.
  80861. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80862. */
  80863. setVisibilityBox(size: number): void;
  80864. /**
  80865. * Gets whether the SPS as always visible or not
  80866. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80867. */
  80868. /**
  80869. * Sets the SPS as always visible or not
  80870. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80871. */
  80872. isAlwaysVisible: boolean;
  80873. /**
  80874. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80875. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80876. */
  80877. /**
  80878. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80879. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80880. */
  80881. isVisibilityBoxLocked: boolean;
  80882. /**
  80883. * Tells to `setParticles()` to compute the particle rotations or not.
  80884. * Default value : true. The SPS is faster when it's set to false.
  80885. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80886. */
  80887. /**
  80888. * Gets if `setParticles()` computes the particle rotations or not.
  80889. * Default value : true. The SPS is faster when it's set to false.
  80890. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80891. */
  80892. computeParticleRotation: boolean;
  80893. /**
  80894. * Tells to `setParticles()` to compute the particle colors or not.
  80895. * Default value : true. The SPS is faster when it's set to false.
  80896. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80897. */
  80898. /**
  80899. * Gets if `setParticles()` computes the particle colors or not.
  80900. * Default value : true. The SPS is faster when it's set to false.
  80901. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80902. */
  80903. computeParticleColor: boolean;
  80904. /**
  80905. * Gets if `setParticles()` computes the particle textures or not.
  80906. * Default value : true. The SPS is faster when it's set to false.
  80907. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80908. */
  80909. computeParticleTexture: boolean;
  80910. /**
  80911. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80912. * Default value : false. The SPS is faster when it's set to false.
  80913. * Note : the particle custom vertex positions aren't stored values.
  80914. */
  80915. /**
  80916. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80917. * Default value : false. The SPS is faster when it's set to false.
  80918. * Note : the particle custom vertex positions aren't stored values.
  80919. */
  80920. computeParticleVertex: boolean;
  80921. /**
  80922. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80923. */
  80924. /**
  80925. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80926. */
  80927. computeBoundingBox: boolean;
  80928. /**
  80929. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80930. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80931. * Default : `true`
  80932. */
  80933. /**
  80934. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80935. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80936. * Default : `true`
  80937. */
  80938. depthSortParticles: boolean;
  80939. /**
  80940. * This function does nothing. It may be overwritten to set all the particle first values.
  80941. * The SPS doesn't call this function, you may have to call it by your own.
  80942. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80943. */
  80944. initParticles(): void;
  80945. /**
  80946. * This function does nothing. It may be overwritten to recycle a particle.
  80947. * The SPS doesn't call this function, you may have to call it by your own.
  80948. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80949. * @param particle The particle to recycle
  80950. * @returns the recycled particle
  80951. */
  80952. recycleParticle(particle: SolidParticle): SolidParticle;
  80953. /**
  80954. * Updates a particle : this function should be overwritten by the user.
  80955. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80956. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80957. * @example : just set a particle position or velocity and recycle conditions
  80958. * @param particle The particle to update
  80959. * @returns the updated particle
  80960. */
  80961. updateParticle(particle: SolidParticle): SolidParticle;
  80962. /**
  80963. * Updates a vertex of a particle : it can be overwritten by the user.
  80964. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80965. * @param particle the current particle
  80966. * @param vertex the current index of the current particle
  80967. * @param pt the index of the current vertex in the particle shape
  80968. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80969. * @example : just set a vertex particle position
  80970. * @returns the updated vertex
  80971. */
  80972. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80973. /**
  80974. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80975. * This does nothing and may be overwritten by the user.
  80976. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80977. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80978. * @param update the boolean update value actually passed to setParticles()
  80979. */
  80980. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80981. /**
  80982. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80983. * This will be passed three parameters.
  80984. * This does nothing and may be overwritten by the user.
  80985. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80986. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80987. * @param update the boolean update value actually passed to setParticles()
  80988. */
  80989. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80990. }
  80991. }
  80992. declare module BABYLON {
  80993. /**
  80994. * Represents one particle of a solid particle system.
  80995. */
  80996. export class SolidParticle {
  80997. /**
  80998. * particle global index
  80999. */
  81000. idx: number;
  81001. /**
  81002. * The color of the particle
  81003. */
  81004. color: Nullable<Color4>;
  81005. /**
  81006. * The world space position of the particle.
  81007. */
  81008. position: Vector3;
  81009. /**
  81010. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  81011. */
  81012. rotation: Vector3;
  81013. /**
  81014. * The world space rotation quaternion of the particle.
  81015. */
  81016. rotationQuaternion: Nullable<Quaternion>;
  81017. /**
  81018. * The scaling of the particle.
  81019. */
  81020. scaling: Vector3;
  81021. /**
  81022. * The uvs of the particle.
  81023. */
  81024. uvs: Vector4;
  81025. /**
  81026. * The current speed of the particle.
  81027. */
  81028. velocity: Vector3;
  81029. /**
  81030. * The pivot point in the particle local space.
  81031. */
  81032. pivot: Vector3;
  81033. /**
  81034. * Must the particle be translated from its pivot point in its local space ?
  81035. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  81036. * Default : false
  81037. */
  81038. translateFromPivot: boolean;
  81039. /**
  81040. * Is the particle active or not ?
  81041. */
  81042. alive: boolean;
  81043. /**
  81044. * Is the particle visible or not ?
  81045. */
  81046. isVisible: boolean;
  81047. /**
  81048. * Index of this particle in the global "positions" array (Internal use)
  81049. * @hidden
  81050. */
  81051. _pos: number;
  81052. /**
  81053. * @hidden Index of this particle in the global "indices" array (Internal use)
  81054. */
  81055. _ind: number;
  81056. /**
  81057. * @hidden ModelShape of this particle (Internal use)
  81058. */
  81059. _model: ModelShape;
  81060. /**
  81061. * ModelShape id of this particle
  81062. */
  81063. shapeId: number;
  81064. /**
  81065. * Index of the particle in its shape id (Internal use)
  81066. */
  81067. idxInShape: number;
  81068. /**
  81069. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  81070. */
  81071. _modelBoundingInfo: BoundingInfo;
  81072. /**
  81073. * @hidden Particle BoundingInfo object (Internal use)
  81074. */
  81075. _boundingInfo: BoundingInfo;
  81076. /**
  81077. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  81078. */
  81079. _sps: SolidParticleSystem;
  81080. /**
  81081. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  81082. */
  81083. _stillInvisible: boolean;
  81084. /**
  81085. * @hidden Last computed particle rotation matrix
  81086. */
  81087. _rotationMatrix: number[];
  81088. /**
  81089. * Parent particle Id, if any.
  81090. * Default null.
  81091. */
  81092. parentId: Nullable<number>;
  81093. /**
  81094. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  81095. * The possible values are :
  81096. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81097. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81098. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81099. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81100. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81101. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  81102. * */
  81103. cullingStrategy: number;
  81104. /**
  81105. * @hidden Internal global position in the SPS.
  81106. */
  81107. _globalPosition: Vector3;
  81108. /**
  81109. * Creates a Solid Particle object.
  81110. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  81111. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  81112. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  81113. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  81114. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  81115. * @param shapeId (integer) is the model shape identifier in the SPS.
  81116. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  81117. * @param sps defines the sps it is associated to
  81118. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  81119. */
  81120. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  81121. /**
  81122. * Legacy support, changed scale to scaling
  81123. */
  81124. /**
  81125. * Legacy support, changed scale to scaling
  81126. */
  81127. scale: Vector3;
  81128. /**
  81129. * Legacy support, changed quaternion to rotationQuaternion
  81130. */
  81131. /**
  81132. * Legacy support, changed quaternion to rotationQuaternion
  81133. */
  81134. quaternion: Nullable<Quaternion>;
  81135. /**
  81136. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  81137. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  81138. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  81139. * @returns true if it intersects
  81140. */
  81141. intersectsMesh(target: Mesh | SolidParticle): boolean;
  81142. /**
  81143. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  81144. * A particle is in the frustum if its bounding box intersects the frustum
  81145. * @param frustumPlanes defines the frustum to test
  81146. * @returns true if the particle is in the frustum planes
  81147. */
  81148. isInFrustum(frustumPlanes: Plane[]): boolean;
  81149. /**
  81150. * get the rotation matrix of the particle
  81151. * @hidden
  81152. */
  81153. getRotationMatrix(m: Matrix): void;
  81154. }
  81155. /**
  81156. * Represents the shape of the model used by one particle of a solid particle system.
  81157. * SPS internal tool, don't use it manually.
  81158. */
  81159. export class ModelShape {
  81160. /**
  81161. * The shape id
  81162. * @hidden
  81163. */
  81164. shapeID: number;
  81165. /**
  81166. * flat array of model positions (internal use)
  81167. * @hidden
  81168. */
  81169. _shape: Vector3[];
  81170. /**
  81171. * flat array of model UVs (internal use)
  81172. * @hidden
  81173. */
  81174. _shapeUV: number[];
  81175. /**
  81176. * length of the shape in the model indices array (internal use)
  81177. * @hidden
  81178. */
  81179. _indicesLength: number;
  81180. /**
  81181. * Custom position function (internal use)
  81182. * @hidden
  81183. */
  81184. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  81185. /**
  81186. * Custom vertex function (internal use)
  81187. * @hidden
  81188. */
  81189. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  81190. /**
  81191. * 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.
  81192. * SPS internal tool, don't use it manually.
  81193. * @hidden
  81194. */
  81195. 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>);
  81196. }
  81197. /**
  81198. * Represents a Depth Sorted Particle in the solid particle system.
  81199. */
  81200. export class DepthSortedParticle {
  81201. /**
  81202. * Index of the particle in the "indices" array
  81203. */
  81204. ind: number;
  81205. /**
  81206. * Length of the particle shape in the "indices" array
  81207. */
  81208. indicesLength: number;
  81209. /**
  81210. * Squared distance from the particle to the camera
  81211. */
  81212. sqDistance: number;
  81213. }
  81214. }
  81215. declare module BABYLON {
  81216. /**
  81217. * Class used to store all common mesh properties
  81218. */
  81219. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  81220. /** No occlusion */
  81221. static OCCLUSION_TYPE_NONE: number;
  81222. /** Occlusion set to optimisitic */
  81223. static OCCLUSION_TYPE_OPTIMISTIC: number;
  81224. /** Occlusion set to strict */
  81225. static OCCLUSION_TYPE_STRICT: number;
  81226. /** Use an accurante occlusion algorithm */
  81227. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  81228. /** Use a conservative occlusion algorithm */
  81229. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  81230. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81231. * Test order :
  81232. * Is the bounding sphere outside the frustum ?
  81233. * If not, are the bounding box vertices outside the frustum ?
  81234. * It not, then the cullable object is in the frustum.
  81235. */
  81236. static readonly CULLINGSTRATEGY_STANDARD: number;
  81237. /** Culling strategy : Bounding Sphere Only.
  81238. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81239. * It's also less accurate than the standard because some not visible objects can still be selected.
  81240. * Test : is the bounding sphere outside the frustum ?
  81241. * If not, then the cullable object is in the frustum.
  81242. */
  81243. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81244. /** Culling strategy : Optimistic Inclusion.
  81245. * This in an inclusion test first, then the standard exclusion test.
  81246. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81247. * 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.
  81248. * Anyway, it's as accurate as the standard strategy.
  81249. * Test :
  81250. * Is the cullable object bounding sphere center in the frustum ?
  81251. * If not, apply the default culling strategy.
  81252. */
  81253. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81254. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81255. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81256. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81257. * 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.
  81258. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81259. * Test :
  81260. * Is the cullable object bounding sphere center in the frustum ?
  81261. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81262. */
  81263. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81264. /**
  81265. * No billboard
  81266. */
  81267. static readonly BILLBOARDMODE_NONE: number;
  81268. /** Billboard on X axis */
  81269. static readonly BILLBOARDMODE_X: number;
  81270. /** Billboard on Y axis */
  81271. static readonly BILLBOARDMODE_Y: number;
  81272. /** Billboard on Z axis */
  81273. static readonly BILLBOARDMODE_Z: number;
  81274. /** Billboard on all axes */
  81275. static readonly BILLBOARDMODE_ALL: number;
  81276. private _facetData;
  81277. /**
  81278. * The culling strategy to use to check whether the mesh must be rendered or not.
  81279. * This value can be changed at any time and will be used on the next render mesh selection.
  81280. * The possible values are :
  81281. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81282. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81283. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81284. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81285. * Please read each static variable documentation to get details about the culling process.
  81286. * */
  81287. cullingStrategy: number;
  81288. /**
  81289. * Gets the number of facets in the mesh
  81290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81291. */
  81292. readonly facetNb: number;
  81293. /**
  81294. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  81295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81296. */
  81297. partitioningSubdivisions: number;
  81298. /**
  81299. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  81300. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  81301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81302. */
  81303. partitioningBBoxRatio: number;
  81304. /**
  81305. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  81306. * Works only for updatable meshes.
  81307. * Doesn't work with multi-materials
  81308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81309. */
  81310. mustDepthSortFacets: boolean;
  81311. /**
  81312. * The location (Vector3) where the facet depth sort must be computed from.
  81313. * By default, the active camera position.
  81314. * Used only when facet depth sort is enabled
  81315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81316. */
  81317. facetDepthSortFrom: Vector3;
  81318. /**
  81319. * gets a boolean indicating if facetData is enabled
  81320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81321. */
  81322. readonly isFacetDataEnabled: boolean;
  81323. /** @hidden */
  81324. _updateNonUniformScalingState(value: boolean): boolean;
  81325. /**
  81326. * An event triggered when this mesh collides with another one
  81327. */
  81328. onCollideObservable: Observable<AbstractMesh>;
  81329. private _onCollideObserver;
  81330. /** Set a function to call when this mesh collides with another one */
  81331. onCollide: () => void;
  81332. /**
  81333. * An event triggered when the collision's position changes
  81334. */
  81335. onCollisionPositionChangeObservable: Observable<Vector3>;
  81336. private _onCollisionPositionChangeObserver;
  81337. /** Set a function to call when the collision's position changes */
  81338. onCollisionPositionChange: () => void;
  81339. /**
  81340. * An event triggered when material is changed
  81341. */
  81342. onMaterialChangedObservable: Observable<AbstractMesh>;
  81343. /**
  81344. * Gets or sets the orientation for POV movement & rotation
  81345. */
  81346. definedFacingForward: boolean;
  81347. /** @hidden */
  81348. _occlusionQuery: Nullable<WebGLQuery>;
  81349. private _visibility;
  81350. /**
  81351. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81352. */
  81353. /**
  81354. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81355. */
  81356. visibility: number;
  81357. /** Gets or sets the alpha index used to sort transparent meshes
  81358. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81359. */
  81360. alphaIndex: number;
  81361. /**
  81362. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81363. */
  81364. isVisible: boolean;
  81365. /**
  81366. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81367. */
  81368. isPickable: boolean;
  81369. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81370. showSubMeshesBoundingBox: boolean;
  81371. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81372. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81373. */
  81374. isBlocker: boolean;
  81375. /**
  81376. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81377. */
  81378. enablePointerMoveEvents: boolean;
  81379. /**
  81380. * Specifies the rendering group id for this mesh (0 by default)
  81381. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81382. */
  81383. renderingGroupId: number;
  81384. private _material;
  81385. /** Gets or sets current material */
  81386. material: Nullable<Material>;
  81387. private _receiveShadows;
  81388. /**
  81389. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  81390. * @see http://doc.babylonjs.com/babylon101/shadows
  81391. */
  81392. receiveShadows: boolean;
  81393. /** Defines color to use when rendering outline */
  81394. outlineColor: Color3;
  81395. /** Define width to use when rendering outline */
  81396. outlineWidth: number;
  81397. /** Defines color to use when rendering overlay */
  81398. overlayColor: Color3;
  81399. /** Defines alpha to use when rendering overlay */
  81400. overlayAlpha: number;
  81401. private _hasVertexAlpha;
  81402. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  81403. hasVertexAlpha: boolean;
  81404. private _useVertexColors;
  81405. /** 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) */
  81406. useVertexColors: boolean;
  81407. private _computeBonesUsingShaders;
  81408. /**
  81409. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  81410. */
  81411. computeBonesUsingShaders: boolean;
  81412. private _numBoneInfluencers;
  81413. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  81414. numBoneInfluencers: number;
  81415. private _applyFog;
  81416. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  81417. applyFog: boolean;
  81418. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81419. useOctreeForRenderingSelection: boolean;
  81420. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81421. useOctreeForPicking: boolean;
  81422. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81423. useOctreeForCollisions: boolean;
  81424. private _layerMask;
  81425. /**
  81426. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  81427. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  81428. */
  81429. layerMask: number;
  81430. /**
  81431. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81432. */
  81433. alwaysSelectAsActiveMesh: boolean;
  81434. /**
  81435. * Gets or sets the current action manager
  81436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81437. */
  81438. actionManager: Nullable<AbstractActionManager>;
  81439. private _checkCollisions;
  81440. private _collisionMask;
  81441. private _collisionGroup;
  81442. /**
  81443. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  81444. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81445. */
  81446. ellipsoid: Vector3;
  81447. /**
  81448. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  81449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81450. */
  81451. ellipsoidOffset: Vector3;
  81452. private _collider;
  81453. private _oldPositionForCollisions;
  81454. private _diffPositionForCollisions;
  81455. /**
  81456. * Gets or sets a collision mask used to mask collisions (default is -1).
  81457. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81458. */
  81459. collisionMask: number;
  81460. /**
  81461. * Gets or sets the current collision group mask (-1 by default).
  81462. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81463. */
  81464. collisionGroup: number;
  81465. /**
  81466. * Defines edge width used when edgesRenderer is enabled
  81467. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81468. */
  81469. edgesWidth: number;
  81470. /**
  81471. * Defines edge color used when edgesRenderer is enabled
  81472. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81473. */
  81474. edgesColor: Color4;
  81475. /** @hidden */
  81476. _edgesRenderer: Nullable<IEdgesRenderer>;
  81477. /** @hidden */
  81478. _masterMesh: Nullable<AbstractMesh>;
  81479. /** @hidden */
  81480. _boundingInfo: Nullable<BoundingInfo>;
  81481. /** @hidden */
  81482. _renderId: number;
  81483. /**
  81484. * Gets or sets the list of subMeshes
  81485. * @see http://doc.babylonjs.com/how_to/multi_materials
  81486. */
  81487. subMeshes: SubMesh[];
  81488. /** @hidden */
  81489. _intersectionsInProgress: AbstractMesh[];
  81490. /** @hidden */
  81491. _unIndexed: boolean;
  81492. /** @hidden */
  81493. _lightSources: Light[];
  81494. /** @hidden */
  81495. readonly _positions: Nullable<Vector3[]>;
  81496. /** @hidden */
  81497. _waitingActions: any;
  81498. /** @hidden */
  81499. _waitingFreezeWorldMatrix: Nullable<boolean>;
  81500. private _skeleton;
  81501. /** @hidden */
  81502. _bonesTransformMatrices: Nullable<Float32Array>;
  81503. /**
  81504. * Gets or sets a skeleton to apply skining transformations
  81505. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81506. */
  81507. skeleton: Nullable<Skeleton>;
  81508. /**
  81509. * An event triggered when the mesh is rebuilt.
  81510. */
  81511. onRebuildObservable: Observable<AbstractMesh>;
  81512. /**
  81513. * Creates a new AbstractMesh
  81514. * @param name defines the name of the mesh
  81515. * @param scene defines the hosting scene
  81516. */
  81517. constructor(name: string, scene?: Nullable<Scene>);
  81518. /**
  81519. * Returns the string "AbstractMesh"
  81520. * @returns "AbstractMesh"
  81521. */
  81522. getClassName(): string;
  81523. /**
  81524. * Gets a string representation of the current mesh
  81525. * @param fullDetails defines a boolean indicating if full details must be included
  81526. * @returns a string representation of the current mesh
  81527. */
  81528. toString(fullDetails?: boolean): string;
  81529. /** @hidden */
  81530. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81531. /** @hidden */
  81532. _rebuild(): void;
  81533. /** @hidden */
  81534. _resyncLightSources(): void;
  81535. /** @hidden */
  81536. _resyncLighSource(light: Light): void;
  81537. /** @hidden */
  81538. _unBindEffect(): void;
  81539. /** @hidden */
  81540. _removeLightSource(light: Light): void;
  81541. private _markSubMeshesAsDirty;
  81542. /** @hidden */
  81543. _markSubMeshesAsLightDirty(): void;
  81544. /** @hidden */
  81545. _markSubMeshesAsAttributesDirty(): void;
  81546. /** @hidden */
  81547. _markSubMeshesAsMiscDirty(): void;
  81548. /**
  81549. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81550. */
  81551. scaling: Vector3;
  81552. /**
  81553. * Returns true if the mesh is blocked. Implemented by child classes
  81554. */
  81555. readonly isBlocked: boolean;
  81556. /**
  81557. * Returns the mesh itself by default. Implemented by child classes
  81558. * @param camera defines the camera to use to pick the right LOD level
  81559. * @returns the currentAbstractMesh
  81560. */
  81561. getLOD(camera: Camera): Nullable<AbstractMesh>;
  81562. /**
  81563. * Returns 0 by default. Implemented by child classes
  81564. * @returns an integer
  81565. */
  81566. getTotalVertices(): number;
  81567. /**
  81568. * Returns a positive integer : the total number of indices in this mesh geometry.
  81569. * @returns the numner of indices or zero if the mesh has no geometry.
  81570. */
  81571. getTotalIndices(): number;
  81572. /**
  81573. * Returns null by default. Implemented by child classes
  81574. * @returns null
  81575. */
  81576. getIndices(): Nullable<IndicesArray>;
  81577. /**
  81578. * Returns the array of the requested vertex data kind. Implemented by child classes
  81579. * @param kind defines the vertex data kind to use
  81580. * @returns null
  81581. */
  81582. getVerticesData(kind: string): Nullable<FloatArray>;
  81583. /**
  81584. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81585. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81586. * Note that a new underlying VertexBuffer object is created each call.
  81587. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81588. * @param kind defines vertex data kind:
  81589. * * VertexBuffer.PositionKind
  81590. * * VertexBuffer.UVKind
  81591. * * VertexBuffer.UV2Kind
  81592. * * VertexBuffer.UV3Kind
  81593. * * VertexBuffer.UV4Kind
  81594. * * VertexBuffer.UV5Kind
  81595. * * VertexBuffer.UV6Kind
  81596. * * VertexBuffer.ColorKind
  81597. * * VertexBuffer.MatricesIndicesKind
  81598. * * VertexBuffer.MatricesIndicesExtraKind
  81599. * * VertexBuffer.MatricesWeightsKind
  81600. * * VertexBuffer.MatricesWeightsExtraKind
  81601. * @param data defines the data source
  81602. * @param updatable defines if the data must be flagged as updatable (or static)
  81603. * @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
  81604. * @returns the current mesh
  81605. */
  81606. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81607. /**
  81608. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81609. * If the mesh has no geometry, it is simply returned as it is.
  81610. * @param kind defines vertex data kind:
  81611. * * VertexBuffer.PositionKind
  81612. * * VertexBuffer.UVKind
  81613. * * VertexBuffer.UV2Kind
  81614. * * VertexBuffer.UV3Kind
  81615. * * VertexBuffer.UV4Kind
  81616. * * VertexBuffer.UV5Kind
  81617. * * VertexBuffer.UV6Kind
  81618. * * VertexBuffer.ColorKind
  81619. * * VertexBuffer.MatricesIndicesKind
  81620. * * VertexBuffer.MatricesIndicesExtraKind
  81621. * * VertexBuffer.MatricesWeightsKind
  81622. * * VertexBuffer.MatricesWeightsExtraKind
  81623. * @param data defines the data source
  81624. * @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
  81625. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81626. * @returns the current mesh
  81627. */
  81628. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81629. /**
  81630. * Sets the mesh indices,
  81631. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81632. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81633. * @param totalVertices Defines the total number of vertices
  81634. * @returns the current mesh
  81635. */
  81636. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81637. /**
  81638. * Gets a boolean indicating if specific vertex data is present
  81639. * @param kind defines the vertex data kind to use
  81640. * @returns true is data kind is present
  81641. */
  81642. isVerticesDataPresent(kind: string): boolean;
  81643. /**
  81644. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81645. * @returns a BoundingInfo
  81646. */
  81647. getBoundingInfo(): BoundingInfo;
  81648. /**
  81649. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81650. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81651. * @returns the current mesh
  81652. */
  81653. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81654. /**
  81655. * Overwrite the current bounding info
  81656. * @param boundingInfo defines the new bounding info
  81657. * @returns the current mesh
  81658. */
  81659. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81660. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81661. readonly useBones: boolean;
  81662. /** @hidden */
  81663. _preActivate(): void;
  81664. /** @hidden */
  81665. _preActivateForIntermediateRendering(renderId: number): void;
  81666. /** @hidden */
  81667. _activate(renderId: number): void;
  81668. /**
  81669. * Gets the current world matrix
  81670. * @returns a Matrix
  81671. */
  81672. getWorldMatrix(): Matrix;
  81673. /** @hidden */
  81674. _getWorldMatrixDeterminant(): number;
  81675. /**
  81676. * Perform relative position change from the point of view of behind the front of the mesh.
  81677. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81678. * Supports definition of mesh facing forward or backward
  81679. * @param amountRight defines the distance on the right axis
  81680. * @param amountUp defines the distance on the up axis
  81681. * @param amountForward defines the distance on the forward axis
  81682. * @returns the current mesh
  81683. */
  81684. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81685. /**
  81686. * Calculate relative position change from the point of view of behind the front of the mesh.
  81687. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81688. * Supports definition of mesh facing forward or backward
  81689. * @param amountRight defines the distance on the right axis
  81690. * @param amountUp defines the distance on the up axis
  81691. * @param amountForward defines the distance on the forward axis
  81692. * @returns the new displacement vector
  81693. */
  81694. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81695. /**
  81696. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81697. * Supports definition of mesh facing forward or backward
  81698. * @param flipBack defines the flip
  81699. * @param twirlClockwise defines the twirl
  81700. * @param tiltRight defines the tilt
  81701. * @returns the current mesh
  81702. */
  81703. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81704. /**
  81705. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81706. * Supports definition of mesh facing forward or backward.
  81707. * @param flipBack defines the flip
  81708. * @param twirlClockwise defines the twirl
  81709. * @param tiltRight defines the tilt
  81710. * @returns the new rotation vector
  81711. */
  81712. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81713. /**
  81714. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81715. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81716. * @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
  81717. * @returns the new bounding vectors
  81718. */
  81719. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81720. min: Vector3;
  81721. max: Vector3;
  81722. };
  81723. /**
  81724. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81725. * This means the mesh underlying bounding box and sphere are recomputed.
  81726. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81727. * @returns the current mesh
  81728. */
  81729. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81730. /** @hidden */
  81731. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81732. /** @hidden */
  81733. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81734. /** @hidden */
  81735. _updateBoundingInfo(): AbstractMesh;
  81736. /** @hidden */
  81737. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81738. /** @hidden */
  81739. protected _afterComputeWorldMatrix(): void;
  81740. /**
  81741. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81742. * A mesh is in the frustum if its bounding box intersects the frustum
  81743. * @param frustumPlanes defines the frustum to test
  81744. * @returns true if the mesh is in the frustum planes
  81745. */
  81746. isInFrustum(frustumPlanes: Plane[]): boolean;
  81747. /**
  81748. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81749. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81750. * @param frustumPlanes defines the frustum to test
  81751. * @returns true if the mesh is completely in the frustum planes
  81752. */
  81753. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81754. /**
  81755. * True if the mesh intersects another mesh or a SolidParticle object
  81756. * @param mesh defines a target mesh or SolidParticle to test
  81757. * @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)
  81758. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81759. * @returns true if there is an intersection
  81760. */
  81761. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81762. /**
  81763. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81764. * @param point defines the point to test
  81765. * @returns true if there is an intersection
  81766. */
  81767. intersectsPoint(point: Vector3): boolean;
  81768. /**
  81769. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81770. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81771. */
  81772. checkCollisions: boolean;
  81773. /**
  81774. * Gets Collider object used to compute collisions (not physics)
  81775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81776. */
  81777. readonly collider: Collider;
  81778. /**
  81779. * Move the mesh using collision engine
  81780. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81781. * @param displacement defines the requested displacement vector
  81782. * @returns the current mesh
  81783. */
  81784. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81785. private _onCollisionPositionChange;
  81786. /** @hidden */
  81787. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81788. /** @hidden */
  81789. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81790. /** @hidden */
  81791. _checkCollision(collider: Collider): AbstractMesh;
  81792. /** @hidden */
  81793. _generatePointsArray(): boolean;
  81794. /**
  81795. * Checks if the passed Ray intersects with the mesh
  81796. * @param ray defines the ray to use
  81797. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81798. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81799. * @returns the picking info
  81800. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81801. */
  81802. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81803. /**
  81804. * Clones the current mesh
  81805. * @param name defines the mesh name
  81806. * @param newParent defines the new mesh parent
  81807. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81808. * @returns the new mesh
  81809. */
  81810. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81811. /**
  81812. * Disposes all the submeshes of the current meshnp
  81813. * @returns the current mesh
  81814. */
  81815. releaseSubMeshes(): AbstractMesh;
  81816. /**
  81817. * Releases resources associated with this abstract mesh.
  81818. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81819. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81820. */
  81821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81822. /**
  81823. * Adds the passed mesh as a child to the current mesh
  81824. * @param mesh defines the child mesh
  81825. * @returns the current mesh
  81826. */
  81827. addChild(mesh: AbstractMesh): AbstractMesh;
  81828. /**
  81829. * Removes the passed mesh from the current mesh children list
  81830. * @param mesh defines the child mesh
  81831. * @returns the current mesh
  81832. */
  81833. removeChild(mesh: AbstractMesh): AbstractMesh;
  81834. /** @hidden */
  81835. private _initFacetData;
  81836. /**
  81837. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81838. * This method can be called within the render loop.
  81839. * 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
  81840. * @returns the current mesh
  81841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81842. */
  81843. updateFacetData(): AbstractMesh;
  81844. /**
  81845. * Returns the facetLocalNormals array.
  81846. * The normals are expressed in the mesh local spac
  81847. * @returns an array of Vector3
  81848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81849. */
  81850. getFacetLocalNormals(): Vector3[];
  81851. /**
  81852. * Returns the facetLocalPositions array.
  81853. * The facet positions are expressed in the mesh local space
  81854. * @returns an array of Vector3
  81855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81856. */
  81857. getFacetLocalPositions(): Vector3[];
  81858. /**
  81859. * Returns the facetLocalPartioning array
  81860. * @returns an array of array of numbers
  81861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81862. */
  81863. getFacetLocalPartitioning(): number[][];
  81864. /**
  81865. * Returns the i-th facet position in the world system.
  81866. * This method allocates a new Vector3 per call
  81867. * @param i defines the facet index
  81868. * @returns a new Vector3
  81869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81870. */
  81871. getFacetPosition(i: number): Vector3;
  81872. /**
  81873. * Sets the reference Vector3 with the i-th facet position in the world system
  81874. * @param i defines the facet index
  81875. * @param ref defines the target vector
  81876. * @returns the current mesh
  81877. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81878. */
  81879. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81880. /**
  81881. * Returns the i-th facet normal in the world system.
  81882. * This method allocates a new Vector3 per call
  81883. * @param i defines the facet index
  81884. * @returns a new Vector3
  81885. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81886. */
  81887. getFacetNormal(i: number): Vector3;
  81888. /**
  81889. * Sets the reference Vector3 with the i-th facet normal in the world system
  81890. * @param i defines the facet index
  81891. * @param ref defines the target vector
  81892. * @returns the current mesh
  81893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81894. */
  81895. getFacetNormalToRef(i: number, ref: Vector3): this;
  81896. /**
  81897. * 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)
  81898. * @param x defines x coordinate
  81899. * @param y defines y coordinate
  81900. * @param z defines z coordinate
  81901. * @returns the array of facet indexes
  81902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81903. */
  81904. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81905. /**
  81906. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81907. * @param projected sets as the (x,y,z) world projection on the facet
  81908. * @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
  81909. * @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
  81910. * @param x defines x coordinate
  81911. * @param y defines y coordinate
  81912. * @param z defines z coordinate
  81913. * @returns the face index if found (or null instead)
  81914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81915. */
  81916. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81917. /**
  81918. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81919. * @param projected sets as the (x,y,z) local projection on the facet
  81920. * @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
  81921. * @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
  81922. * @param x defines x coordinate
  81923. * @param y defines y coordinate
  81924. * @param z defines z coordinate
  81925. * @returns the face index if found (or null instead)
  81926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81927. */
  81928. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81929. /**
  81930. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81931. * @returns the parameters
  81932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81933. */
  81934. getFacetDataParameters(): any;
  81935. /**
  81936. * Disables the feature FacetData and frees the related memory
  81937. * @returns the current mesh
  81938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81939. */
  81940. disableFacetData(): AbstractMesh;
  81941. /**
  81942. * Updates the AbstractMesh indices array
  81943. * @param indices defines the data source
  81944. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81945. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  81946. * @returns the current mesh
  81947. */
  81948. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  81949. /**
  81950. * Creates new normals data for the mesh
  81951. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81952. * @returns the current mesh
  81953. */
  81954. createNormals(updatable: boolean): AbstractMesh;
  81955. /**
  81956. * Align the mesh with a normal
  81957. * @param normal defines the normal to use
  81958. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81959. * @returns the current mesh
  81960. */
  81961. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81962. /** @hidden */
  81963. _checkOcclusionQuery(): boolean;
  81964. }
  81965. }
  81966. declare module BABYLON {
  81967. /**
  81968. * Interface used to define ActionEvent
  81969. */
  81970. export interface IActionEvent {
  81971. /** The mesh or sprite that triggered the action */
  81972. source: any;
  81973. /** The X mouse cursor position at the time of the event */
  81974. pointerX: number;
  81975. /** The Y mouse cursor position at the time of the event */
  81976. pointerY: number;
  81977. /** The mesh that is currently pointed at (can be null) */
  81978. meshUnderPointer: Nullable<AbstractMesh>;
  81979. /** the original (browser) event that triggered the ActionEvent */
  81980. sourceEvent?: any;
  81981. /** additional data for the event */
  81982. additionalData?: any;
  81983. }
  81984. /**
  81985. * ActionEvent is the event being sent when an action is triggered.
  81986. */
  81987. export class ActionEvent implements IActionEvent {
  81988. /** The mesh or sprite that triggered the action */
  81989. source: any;
  81990. /** The X mouse cursor position at the time of the event */
  81991. pointerX: number;
  81992. /** The Y mouse cursor position at the time of the event */
  81993. pointerY: number;
  81994. /** The mesh that is currently pointed at (can be null) */
  81995. meshUnderPointer: Nullable<AbstractMesh>;
  81996. /** the original (browser) event that triggered the ActionEvent */
  81997. sourceEvent?: any;
  81998. /** additional data for the event */
  81999. additionalData?: any;
  82000. /**
  82001. * Creates a new ActionEvent
  82002. * @param source The mesh or sprite that triggered the action
  82003. * @param pointerX The X mouse cursor position at the time of the event
  82004. * @param pointerY The Y mouse cursor position at the time of the event
  82005. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  82006. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  82007. * @param additionalData additional data for the event
  82008. */
  82009. constructor(
  82010. /** The mesh or sprite that triggered the action */
  82011. source: any,
  82012. /** The X mouse cursor position at the time of the event */
  82013. pointerX: number,
  82014. /** The Y mouse cursor position at the time of the event */
  82015. pointerY: number,
  82016. /** The mesh that is currently pointed at (can be null) */
  82017. meshUnderPointer: Nullable<AbstractMesh>,
  82018. /** the original (browser) event that triggered the ActionEvent */
  82019. sourceEvent?: any,
  82020. /** additional data for the event */
  82021. additionalData?: any);
  82022. /**
  82023. * Helper function to auto-create an ActionEvent from a source mesh.
  82024. * @param source The source mesh that triggered the event
  82025. * @param evt The original (browser) event
  82026. * @param additionalData additional data for the event
  82027. * @returns the new ActionEvent
  82028. */
  82029. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  82030. /**
  82031. * Helper function to auto-create an ActionEvent from a source sprite
  82032. * @param source The source sprite that triggered the event
  82033. * @param scene Scene associated with the sprite
  82034. * @param evt The original (browser) event
  82035. * @param additionalData additional data for the event
  82036. * @returns the new ActionEvent
  82037. */
  82038. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  82039. /**
  82040. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  82041. * @param scene the scene where the event occurred
  82042. * @param evt The original (browser) event
  82043. * @returns the new ActionEvent
  82044. */
  82045. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  82046. /**
  82047. * Helper function to auto-create an ActionEvent from a primitive
  82048. * @param prim defines the target primitive
  82049. * @param pointerPos defines the pointer position
  82050. * @param evt The original (browser) event
  82051. * @param additionalData additional data for the event
  82052. * @returns the new ActionEvent
  82053. */
  82054. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  82055. }
  82056. }
  82057. declare module BABYLON {
  82058. /**
  82059. * Abstract class used to decouple action Manager from scene and meshes.
  82060. * Do not instantiate.
  82061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82062. */
  82063. export abstract class AbstractActionManager implements IDisposable {
  82064. /** Gets the list of active triggers */
  82065. static Triggers: {
  82066. [key: string]: number;
  82067. };
  82068. /** Gets the cursor to use when hovering items */
  82069. hoverCursor: string;
  82070. /** Gets the list of actions */
  82071. actions: IAction[];
  82072. /**
  82073. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  82074. */
  82075. isRecursive: boolean;
  82076. /**
  82077. * Releases all associated resources
  82078. */
  82079. abstract dispose(): void;
  82080. /**
  82081. * Does this action manager has pointer triggers
  82082. */
  82083. abstract readonly hasPointerTriggers: boolean;
  82084. /**
  82085. * Does this action manager has pick triggers
  82086. */
  82087. abstract readonly hasPickTriggers: boolean;
  82088. /**
  82089. * Process a specific trigger
  82090. * @param trigger defines the trigger to process
  82091. * @param evt defines the event details to be processed
  82092. */
  82093. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  82094. /**
  82095. * Does this action manager handles actions of any of the given triggers
  82096. * @param triggers defines the triggers to be tested
  82097. * @return a boolean indicating whether one (or more) of the triggers is handled
  82098. */
  82099. abstract hasSpecificTriggers(triggers: number[]): boolean;
  82100. /**
  82101. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  82102. * speed.
  82103. * @param triggerA defines the trigger to be tested
  82104. * @param triggerB defines the trigger to be tested
  82105. * @return a boolean indicating whether one (or more) of the triggers is handled
  82106. */
  82107. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  82108. /**
  82109. * Does this action manager handles actions of a given trigger
  82110. * @param trigger defines the trigger to be tested
  82111. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  82112. * @return whether the trigger is handled
  82113. */
  82114. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  82115. /**
  82116. * Serialize this manager to a JSON object
  82117. * @param name defines the property name to store this manager
  82118. * @returns a JSON representation of this manager
  82119. */
  82120. abstract serialize(name: string): any;
  82121. /**
  82122. * Registers an action to this action manager
  82123. * @param action defines the action to be registered
  82124. * @return the action amended (prepared) after registration
  82125. */
  82126. abstract registerAction(action: IAction): Nullable<IAction>;
  82127. /**
  82128. * Unregisters an action to this action manager
  82129. * @param action defines the action to be unregistered
  82130. * @return a boolean indicating whether the action has been unregistered
  82131. */
  82132. abstract unregisterAction(action: IAction): Boolean;
  82133. /**
  82134. * Does exist one action manager with at least one trigger
  82135. **/
  82136. static readonly HasTriggers: boolean;
  82137. /**
  82138. * Does exist one action manager with at least one pick trigger
  82139. **/
  82140. static readonly HasPickTriggers: boolean;
  82141. /**
  82142. * Does exist one action manager that handles actions of a given trigger
  82143. * @param trigger defines the trigger to be tested
  82144. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  82145. **/
  82146. static HasSpecificTrigger(trigger: number): boolean;
  82147. }
  82148. }
  82149. declare module BABYLON {
  82150. /**
  82151. * Defines how a node can be built from a string name.
  82152. */
  82153. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  82154. /**
  82155. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  82156. */
  82157. export class Node implements IBehaviorAware<Node> {
  82158. /** @hidden */
  82159. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  82160. private static _NodeConstructors;
  82161. /**
  82162. * Add a new node constructor
  82163. * @param type defines the type name of the node to construct
  82164. * @param constructorFunc defines the constructor function
  82165. */
  82166. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  82167. /**
  82168. * Returns a node constructor based on type name
  82169. * @param type defines the type name
  82170. * @param name defines the new node name
  82171. * @param scene defines the hosting scene
  82172. * @param options defines optional options to transmit to constructors
  82173. * @returns the new constructor or null
  82174. */
  82175. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  82176. /**
  82177. * Gets or sets the name of the node
  82178. */
  82179. name: string;
  82180. /**
  82181. * Gets or sets the id of the node
  82182. */
  82183. id: string;
  82184. /**
  82185. * Gets or sets the unique id of the node
  82186. */
  82187. uniqueId: number;
  82188. /**
  82189. * Gets or sets a string used to store user defined state for the node
  82190. */
  82191. state: string;
  82192. /**
  82193. * Gets or sets an object used to store user defined information for the node
  82194. */
  82195. metadata: any;
  82196. /**
  82197. * For internal use only. Please do not use.
  82198. */
  82199. reservedDataStore: any;
  82200. /**
  82201. * Gets or sets a boolean used to define if the node must be serialized
  82202. */
  82203. doNotSerialize: boolean;
  82204. /** @hidden */
  82205. _isDisposed: boolean;
  82206. /**
  82207. * Gets a list of Animations associated with the node
  82208. */
  82209. animations: Animation[];
  82210. protected _ranges: {
  82211. [name: string]: Nullable<AnimationRange>;
  82212. };
  82213. /**
  82214. * Callback raised when the node is ready to be used
  82215. */
  82216. onReady: (node: Node) => void;
  82217. private _isEnabled;
  82218. private _isParentEnabled;
  82219. private _isReady;
  82220. /** @hidden */
  82221. _currentRenderId: number;
  82222. private _parentRenderId;
  82223. protected _childRenderId: number;
  82224. /** @hidden */
  82225. _waitingParentId: Nullable<string>;
  82226. /** @hidden */
  82227. _scene: Scene;
  82228. /** @hidden */
  82229. _cache: any;
  82230. private _parentNode;
  82231. private _children;
  82232. /** @hidden */
  82233. _worldMatrix: Matrix;
  82234. /** @hidden */
  82235. _worldMatrixDeterminant: number;
  82236. /** @hidden */
  82237. private _sceneRootNodesIndex;
  82238. /**
  82239. * Gets a boolean indicating if the node has been disposed
  82240. * @returns true if the node was disposed
  82241. */
  82242. isDisposed(): boolean;
  82243. /**
  82244. * Gets or sets the parent of the node
  82245. */
  82246. parent: Nullable<Node>;
  82247. private addToSceneRootNodes;
  82248. private removeFromSceneRootNodes;
  82249. private _animationPropertiesOverride;
  82250. /**
  82251. * Gets or sets the animation properties override
  82252. */
  82253. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82254. /**
  82255. * Gets a string idenfifying the name of the class
  82256. * @returns "Node" string
  82257. */
  82258. getClassName(): string;
  82259. /** @hidden */
  82260. readonly _isNode: boolean;
  82261. /**
  82262. * An event triggered when the mesh is disposed
  82263. */
  82264. onDisposeObservable: Observable<Node>;
  82265. private _onDisposeObserver;
  82266. /**
  82267. * Sets a callback that will be raised when the node will be disposed
  82268. */
  82269. onDispose: () => void;
  82270. /**
  82271. * Creates a new Node
  82272. * @param name the name and id to be given to this node
  82273. * @param scene the scene this node will be added to
  82274. * @param addToRootNodes the node will be added to scene.rootNodes
  82275. */
  82276. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  82277. /**
  82278. * Gets the scene of the node
  82279. * @returns a scene
  82280. */
  82281. getScene(): Scene;
  82282. /**
  82283. * Gets the engine of the node
  82284. * @returns a Engine
  82285. */
  82286. getEngine(): Engine;
  82287. private _behaviors;
  82288. /**
  82289. * Attach a behavior to the node
  82290. * @see http://doc.babylonjs.com/features/behaviour
  82291. * @param behavior defines the behavior to attach
  82292. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  82293. * @returns the current Node
  82294. */
  82295. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  82296. /**
  82297. * Remove an attached behavior
  82298. * @see http://doc.babylonjs.com/features/behaviour
  82299. * @param behavior defines the behavior to attach
  82300. * @returns the current Node
  82301. */
  82302. removeBehavior(behavior: Behavior<Node>): Node;
  82303. /**
  82304. * Gets the list of attached behaviors
  82305. * @see http://doc.babylonjs.com/features/behaviour
  82306. */
  82307. readonly behaviors: Behavior<Node>[];
  82308. /**
  82309. * Gets an attached behavior by name
  82310. * @param name defines the name of the behavior to look for
  82311. * @see http://doc.babylonjs.com/features/behaviour
  82312. * @returns null if behavior was not found else the requested behavior
  82313. */
  82314. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  82315. /**
  82316. * Returns the latest update of the World matrix
  82317. * @returns a Matrix
  82318. */
  82319. getWorldMatrix(): Matrix;
  82320. /** @hidden */
  82321. _getWorldMatrixDeterminant(): number;
  82322. /**
  82323. * Returns directly the latest state of the mesh World matrix.
  82324. * A Matrix is returned.
  82325. */
  82326. readonly worldMatrixFromCache: Matrix;
  82327. /** @hidden */
  82328. _initCache(): void;
  82329. /** @hidden */
  82330. updateCache(force?: boolean): void;
  82331. /** @hidden */
  82332. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82333. /** @hidden */
  82334. _updateCache(ignoreParentClass?: boolean): void;
  82335. /** @hidden */
  82336. _isSynchronized(): boolean;
  82337. /** @hidden */
  82338. _markSyncedWithParent(): void;
  82339. /** @hidden */
  82340. isSynchronizedWithParent(): boolean;
  82341. /** @hidden */
  82342. isSynchronized(): boolean;
  82343. /**
  82344. * Is this node ready to be used/rendered
  82345. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82346. * @return true if the node is ready
  82347. */
  82348. isReady(completeCheck?: boolean): boolean;
  82349. /**
  82350. * Is this node enabled?
  82351. * 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
  82352. * @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
  82353. * @return whether this node (and its parent) is enabled
  82354. */
  82355. isEnabled(checkAncestors?: boolean): boolean;
  82356. /** @hidden */
  82357. protected _syncParentEnabledState(): void;
  82358. /**
  82359. * Set the enabled state of this node
  82360. * @param value defines the new enabled state
  82361. */
  82362. setEnabled(value: boolean): void;
  82363. /**
  82364. * Is this node a descendant of the given node?
  82365. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  82366. * @param ancestor defines the parent node to inspect
  82367. * @returns a boolean indicating if this node is a descendant of the given node
  82368. */
  82369. isDescendantOf(ancestor: Node): boolean;
  82370. /** @hidden */
  82371. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  82372. /**
  82373. * Will return all nodes that have this node as ascendant
  82374. * @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
  82375. * @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
  82376. * @return all children nodes of all types
  82377. */
  82378. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  82379. /**
  82380. * Get all child-meshes of this node
  82381. * @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)
  82382. * @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
  82383. * @returns an array of AbstractMesh
  82384. */
  82385. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  82386. /**
  82387. * Get all direct children of this node
  82388. * @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
  82389. * @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)
  82390. * @returns an array of Node
  82391. */
  82392. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  82393. /** @hidden */
  82394. _setReady(state: boolean): void;
  82395. /**
  82396. * Get an animation by name
  82397. * @param name defines the name of the animation to look for
  82398. * @returns null if not found else the requested animation
  82399. */
  82400. getAnimationByName(name: string): Nullable<Animation>;
  82401. /**
  82402. * Creates an animation range for this node
  82403. * @param name defines the name of the range
  82404. * @param from defines the starting key
  82405. * @param to defines the end key
  82406. */
  82407. createAnimationRange(name: string, from: number, to: number): void;
  82408. /**
  82409. * Delete a specific animation range
  82410. * @param name defines the name of the range to delete
  82411. * @param deleteFrames defines if animation frames from the range must be deleted as well
  82412. */
  82413. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82414. /**
  82415. * Get an animation range by name
  82416. * @param name defines the name of the animation range to look for
  82417. * @returns null if not found else the requested animation range
  82418. */
  82419. getAnimationRange(name: string): Nullable<AnimationRange>;
  82420. /**
  82421. * Gets the list of all animation ranges defined on this node
  82422. * @returns an array
  82423. */
  82424. getAnimationRanges(): Nullable<AnimationRange>[];
  82425. /**
  82426. * Will start the animation sequence
  82427. * @param name defines the range frames for animation sequence
  82428. * @param loop defines if the animation should loop (false by default)
  82429. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  82430. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  82431. * @returns the object created for this animation. If range does not exist, it will return null
  82432. */
  82433. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82434. /**
  82435. * Serialize animation ranges into a JSON compatible object
  82436. * @returns serialization object
  82437. */
  82438. serializeAnimationRanges(): any;
  82439. /**
  82440. * Computes the world matrix of the node
  82441. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82442. * @returns the world matrix
  82443. */
  82444. computeWorldMatrix(force?: boolean): Matrix;
  82445. /**
  82446. * Releases resources associated with this node.
  82447. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82448. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82449. */
  82450. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82451. /**
  82452. * Parse animation range data from a serialization object and store them into a given node
  82453. * @param node defines where to store the animation ranges
  82454. * @param parsedNode defines the serialization object to read data from
  82455. * @param scene defines the hosting scene
  82456. */
  82457. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  82458. }
  82459. }
  82460. declare module BABYLON {
  82461. /**
  82462. * Class used to store any kind of animation
  82463. */
  82464. export class Animation {
  82465. /**Name of the animation */
  82466. name: string;
  82467. /**Property to animate */
  82468. targetProperty: string;
  82469. /**The frames per second of the animation */
  82470. framePerSecond: number;
  82471. /**The data type of the animation */
  82472. dataType: number;
  82473. /**The loop mode of the animation */
  82474. loopMode?: number | undefined;
  82475. /**Specifies if blending should be enabled */
  82476. enableBlending?: boolean | undefined;
  82477. /**
  82478. * Use matrix interpolation instead of using direct key value when animating matrices
  82479. */
  82480. static AllowMatricesInterpolation: boolean;
  82481. /**
  82482. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  82483. */
  82484. static AllowMatrixDecomposeForInterpolation: boolean;
  82485. /**
  82486. * Stores the key frames of the animation
  82487. */
  82488. private _keys;
  82489. /**
  82490. * Stores the easing function of the animation
  82491. */
  82492. private _easingFunction;
  82493. /**
  82494. * @hidden Internal use only
  82495. */
  82496. _runtimeAnimations: RuntimeAnimation[];
  82497. /**
  82498. * The set of event that will be linked to this animation
  82499. */
  82500. private _events;
  82501. /**
  82502. * Stores an array of target property paths
  82503. */
  82504. targetPropertyPath: string[];
  82505. /**
  82506. * Stores the blending speed of the animation
  82507. */
  82508. blendingSpeed: number;
  82509. /**
  82510. * Stores the animation ranges for the animation
  82511. */
  82512. private _ranges;
  82513. /**
  82514. * @hidden Internal use
  82515. */
  82516. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  82517. /**
  82518. * Sets up an animation
  82519. * @param property The property to animate
  82520. * @param animationType The animation type to apply
  82521. * @param framePerSecond The frames per second of the animation
  82522. * @param easingFunction The easing function used in the animation
  82523. * @returns The created animation
  82524. */
  82525. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  82526. /**
  82527. * Create and start an animation on a node
  82528. * @param name defines the name of the global animation that will be run on all nodes
  82529. * @param node defines the root node where the animation will take place
  82530. * @param targetProperty defines property to animate
  82531. * @param framePerSecond defines the number of frame per second yo use
  82532. * @param totalFrame defines the number of frames in total
  82533. * @param from defines the initial value
  82534. * @param to defines the final value
  82535. * @param loopMode defines which loop mode you want to use (off by default)
  82536. * @param easingFunction defines the easing function to use (linear by default)
  82537. * @param onAnimationEnd defines the callback to call when animation end
  82538. * @returns the animatable created for this animation
  82539. */
  82540. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82541. /**
  82542. * Create and start an animation on a node and its descendants
  82543. * @param name defines the name of the global animation that will be run on all nodes
  82544. * @param node defines the root node where the animation will take place
  82545. * @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
  82546. * @param targetProperty defines property to animate
  82547. * @param framePerSecond defines the number of frame per second to use
  82548. * @param totalFrame defines the number of frames in total
  82549. * @param from defines the initial value
  82550. * @param to defines the final value
  82551. * @param loopMode defines which loop mode you want to use (off by default)
  82552. * @param easingFunction defines the easing function to use (linear by default)
  82553. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82554. * @returns the list of animatables created for all nodes
  82555. * @example https://www.babylonjs-playground.com/#MH0VLI
  82556. */
  82557. 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[]>;
  82558. /**
  82559. * Creates a new animation, merges it with the existing animations and starts it
  82560. * @param name Name of the animation
  82561. * @param node Node which contains the scene that begins the animations
  82562. * @param targetProperty Specifies which property to animate
  82563. * @param framePerSecond The frames per second of the animation
  82564. * @param totalFrame The total number of frames
  82565. * @param from The frame at the beginning of the animation
  82566. * @param to The frame at the end of the animation
  82567. * @param loopMode Specifies the loop mode of the animation
  82568. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  82569. * @param onAnimationEnd Callback to run once the animation is complete
  82570. * @returns Nullable animation
  82571. */
  82572. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82573. /**
  82574. * Transition property of an host to the target Value
  82575. * @param property The property to transition
  82576. * @param targetValue The target Value of the property
  82577. * @param host The object where the property to animate belongs
  82578. * @param scene Scene used to run the animation
  82579. * @param frameRate Framerate (in frame/s) to use
  82580. * @param transition The transition type we want to use
  82581. * @param duration The duration of the animation, in milliseconds
  82582. * @param onAnimationEnd Callback trigger at the end of the animation
  82583. * @returns Nullable animation
  82584. */
  82585. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82586. /**
  82587. * Return the array of runtime animations currently using this animation
  82588. */
  82589. readonly runtimeAnimations: RuntimeAnimation[];
  82590. /**
  82591. * Specifies if any of the runtime animations are currently running
  82592. */
  82593. readonly hasRunningRuntimeAnimations: boolean;
  82594. /**
  82595. * Initializes the animation
  82596. * @param name Name of the animation
  82597. * @param targetProperty Property to animate
  82598. * @param framePerSecond The frames per second of the animation
  82599. * @param dataType The data type of the animation
  82600. * @param loopMode The loop mode of the animation
  82601. * @param enableBlending Specifies if blending should be enabled
  82602. */
  82603. constructor(
  82604. /**Name of the animation */
  82605. name: string,
  82606. /**Property to animate */
  82607. targetProperty: string,
  82608. /**The frames per second of the animation */
  82609. framePerSecond: number,
  82610. /**The data type of the animation */
  82611. dataType: number,
  82612. /**The loop mode of the animation */
  82613. loopMode?: number | undefined,
  82614. /**Specifies if blending should be enabled */
  82615. enableBlending?: boolean | undefined);
  82616. /**
  82617. * Converts the animation to a string
  82618. * @param fullDetails support for multiple levels of logging within scene loading
  82619. * @returns String form of the animation
  82620. */
  82621. toString(fullDetails?: boolean): string;
  82622. /**
  82623. * Add an event to this animation
  82624. * @param event Event to add
  82625. */
  82626. addEvent(event: AnimationEvent): void;
  82627. /**
  82628. * Remove all events found at the given frame
  82629. * @param frame The frame to remove events from
  82630. */
  82631. removeEvents(frame: number): void;
  82632. /**
  82633. * Retrieves all the events from the animation
  82634. * @returns Events from the animation
  82635. */
  82636. getEvents(): AnimationEvent[];
  82637. /**
  82638. * Creates an animation range
  82639. * @param name Name of the animation range
  82640. * @param from Starting frame of the animation range
  82641. * @param to Ending frame of the animation
  82642. */
  82643. createRange(name: string, from: number, to: number): void;
  82644. /**
  82645. * Deletes an animation range by name
  82646. * @param name Name of the animation range to delete
  82647. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82648. */
  82649. deleteRange(name: string, deleteFrames?: boolean): void;
  82650. /**
  82651. * Gets the animation range by name, or null if not defined
  82652. * @param name Name of the animation range
  82653. * @returns Nullable animation range
  82654. */
  82655. getRange(name: string): Nullable<AnimationRange>;
  82656. /**
  82657. * Gets the key frames from the animation
  82658. * @returns The key frames of the animation
  82659. */
  82660. getKeys(): Array<IAnimationKey>;
  82661. /**
  82662. * Gets the highest frame rate of the animation
  82663. * @returns Highest frame rate of the animation
  82664. */
  82665. getHighestFrame(): number;
  82666. /**
  82667. * Gets the easing function of the animation
  82668. * @returns Easing function of the animation
  82669. */
  82670. getEasingFunction(): IEasingFunction;
  82671. /**
  82672. * Sets the easing function of the animation
  82673. * @param easingFunction A custom mathematical formula for animation
  82674. */
  82675. setEasingFunction(easingFunction: EasingFunction): void;
  82676. /**
  82677. * Interpolates a scalar linearly
  82678. * @param startValue Start value of the animation curve
  82679. * @param endValue End value of the animation curve
  82680. * @param gradient Scalar amount to interpolate
  82681. * @returns Interpolated scalar value
  82682. */
  82683. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82684. /**
  82685. * Interpolates a scalar cubically
  82686. * @param startValue Start value of the animation curve
  82687. * @param outTangent End tangent of the animation
  82688. * @param endValue End value of the animation curve
  82689. * @param inTangent Start tangent of the animation curve
  82690. * @param gradient Scalar amount to interpolate
  82691. * @returns Interpolated scalar value
  82692. */
  82693. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82694. /**
  82695. * Interpolates a quaternion using a spherical linear interpolation
  82696. * @param startValue Start value of the animation curve
  82697. * @param endValue End value of the animation curve
  82698. * @param gradient Scalar amount to interpolate
  82699. * @returns Interpolated quaternion value
  82700. */
  82701. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82702. /**
  82703. * Interpolates a quaternion cubically
  82704. * @param startValue Start value of the animation curve
  82705. * @param outTangent End tangent of the animation curve
  82706. * @param endValue End value of the animation curve
  82707. * @param inTangent Start tangent of the animation curve
  82708. * @param gradient Scalar amount to interpolate
  82709. * @returns Interpolated quaternion value
  82710. */
  82711. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82712. /**
  82713. * Interpolates a Vector3 linearl
  82714. * @param startValue Start value of the animation curve
  82715. * @param endValue End value of the animation curve
  82716. * @param gradient Scalar amount to interpolate
  82717. * @returns Interpolated scalar value
  82718. */
  82719. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82720. /**
  82721. * Interpolates a Vector3 cubically
  82722. * @param startValue Start value of the animation curve
  82723. * @param outTangent End tangent of the animation
  82724. * @param endValue End value of the animation curve
  82725. * @param inTangent Start tangent of the animation curve
  82726. * @param gradient Scalar amount to interpolate
  82727. * @returns InterpolatedVector3 value
  82728. */
  82729. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82730. /**
  82731. * Interpolates a Vector2 linearly
  82732. * @param startValue Start value of the animation curve
  82733. * @param endValue End value of the animation curve
  82734. * @param gradient Scalar amount to interpolate
  82735. * @returns Interpolated Vector2 value
  82736. */
  82737. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82738. /**
  82739. * Interpolates a Vector2 cubically
  82740. * @param startValue Start value of the animation curve
  82741. * @param outTangent End tangent of the animation
  82742. * @param endValue End value of the animation curve
  82743. * @param inTangent Start tangent of the animation curve
  82744. * @param gradient Scalar amount to interpolate
  82745. * @returns Interpolated Vector2 value
  82746. */
  82747. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82748. /**
  82749. * Interpolates a size linearly
  82750. * @param startValue Start value of the animation curve
  82751. * @param endValue End value of the animation curve
  82752. * @param gradient Scalar amount to interpolate
  82753. * @returns Interpolated Size value
  82754. */
  82755. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82756. /**
  82757. * Interpolates a Color3 linearly
  82758. * @param startValue Start value of the animation curve
  82759. * @param endValue End value of the animation curve
  82760. * @param gradient Scalar amount to interpolate
  82761. * @returns Interpolated Color3 value
  82762. */
  82763. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82764. /**
  82765. * @hidden Internal use only
  82766. */
  82767. _getKeyValue(value: any): any;
  82768. /**
  82769. * @hidden Internal use only
  82770. */
  82771. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82772. /**
  82773. * Defines the function to use to interpolate matrices
  82774. * @param startValue defines the start matrix
  82775. * @param endValue defines the end matrix
  82776. * @param gradient defines the gradient between both matrices
  82777. * @param result defines an optional target matrix where to store the interpolation
  82778. * @returns the interpolated matrix
  82779. */
  82780. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82781. /**
  82782. * Makes a copy of the animation
  82783. * @returns Cloned animation
  82784. */
  82785. clone(): Animation;
  82786. /**
  82787. * Sets the key frames of the animation
  82788. * @param values The animation key frames to set
  82789. */
  82790. setKeys(values: Array<IAnimationKey>): void;
  82791. /**
  82792. * Serializes the animation to an object
  82793. * @returns Serialized object
  82794. */
  82795. serialize(): any;
  82796. /**
  82797. * Float animation type
  82798. */
  82799. private static _ANIMATIONTYPE_FLOAT;
  82800. /**
  82801. * Vector3 animation type
  82802. */
  82803. private static _ANIMATIONTYPE_VECTOR3;
  82804. /**
  82805. * Quaternion animation type
  82806. */
  82807. private static _ANIMATIONTYPE_QUATERNION;
  82808. /**
  82809. * Matrix animation type
  82810. */
  82811. private static _ANIMATIONTYPE_MATRIX;
  82812. /**
  82813. * Color3 animation type
  82814. */
  82815. private static _ANIMATIONTYPE_COLOR3;
  82816. /**
  82817. * Vector2 animation type
  82818. */
  82819. private static _ANIMATIONTYPE_VECTOR2;
  82820. /**
  82821. * Size animation type
  82822. */
  82823. private static _ANIMATIONTYPE_SIZE;
  82824. /**
  82825. * Relative Loop Mode
  82826. */
  82827. private static _ANIMATIONLOOPMODE_RELATIVE;
  82828. /**
  82829. * Cycle Loop Mode
  82830. */
  82831. private static _ANIMATIONLOOPMODE_CYCLE;
  82832. /**
  82833. * Constant Loop Mode
  82834. */
  82835. private static _ANIMATIONLOOPMODE_CONSTANT;
  82836. /**
  82837. * Get the float animation type
  82838. */
  82839. static readonly ANIMATIONTYPE_FLOAT: number;
  82840. /**
  82841. * Get the Vector3 animation type
  82842. */
  82843. static readonly ANIMATIONTYPE_VECTOR3: number;
  82844. /**
  82845. * Get the Vector2 animation type
  82846. */
  82847. static readonly ANIMATIONTYPE_VECTOR2: number;
  82848. /**
  82849. * Get the Size animation type
  82850. */
  82851. static readonly ANIMATIONTYPE_SIZE: number;
  82852. /**
  82853. * Get the Quaternion animation type
  82854. */
  82855. static readonly ANIMATIONTYPE_QUATERNION: number;
  82856. /**
  82857. * Get the Matrix animation type
  82858. */
  82859. static readonly ANIMATIONTYPE_MATRIX: number;
  82860. /**
  82861. * Get the Color3 animation type
  82862. */
  82863. static readonly ANIMATIONTYPE_COLOR3: number;
  82864. /**
  82865. * Get the Relative Loop Mode
  82866. */
  82867. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82868. /**
  82869. * Get the Cycle Loop Mode
  82870. */
  82871. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82872. /**
  82873. * Get the Constant Loop Mode
  82874. */
  82875. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82876. /** @hidden */
  82877. static _UniversalLerp(left: any, right: any, amount: number): any;
  82878. /**
  82879. * Parses an animation object and creates an animation
  82880. * @param parsedAnimation Parsed animation object
  82881. * @returns Animation object
  82882. */
  82883. static Parse(parsedAnimation: any): Animation;
  82884. /**
  82885. * Appends the serialized animations from the source animations
  82886. * @param source Source containing the animations
  82887. * @param destination Target to store the animations
  82888. */
  82889. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82890. }
  82891. }
  82892. declare module BABYLON {
  82893. /**
  82894. * Base class of all the textures in babylon.
  82895. * It groups all the common properties the materials, post process, lights... might need
  82896. * in order to make a correct use of the texture.
  82897. */
  82898. export class BaseTexture implements IAnimatable {
  82899. /**
  82900. * Default anisotropic filtering level for the application.
  82901. * It is set to 4 as a good tradeoff between perf and quality.
  82902. */
  82903. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82904. /**
  82905. * Gets or sets the unique id of the texture
  82906. */
  82907. uniqueId: number;
  82908. /**
  82909. * Define the name of the texture.
  82910. */
  82911. name: string;
  82912. /**
  82913. * Gets or sets an object used to store user defined information.
  82914. */
  82915. metadata: any;
  82916. /**
  82917. * For internal use only. Please do not use.
  82918. */
  82919. reservedDataStore: any;
  82920. private _hasAlpha;
  82921. /**
  82922. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82923. */
  82924. hasAlpha: boolean;
  82925. /**
  82926. * Defines if the alpha value should be determined via the rgb values.
  82927. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82928. */
  82929. getAlphaFromRGB: boolean;
  82930. /**
  82931. * Intensity or strength of the texture.
  82932. * It is commonly used by materials to fine tune the intensity of the texture
  82933. */
  82934. level: number;
  82935. /**
  82936. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82937. * This is part of the texture as textures usually maps to one uv set.
  82938. */
  82939. coordinatesIndex: number;
  82940. private _coordinatesMode;
  82941. /**
  82942. * How a texture is mapped.
  82943. *
  82944. * | Value | Type | Description |
  82945. * | ----- | ----------------------------------- | ----------- |
  82946. * | 0 | EXPLICIT_MODE | |
  82947. * | 1 | SPHERICAL_MODE | |
  82948. * | 2 | PLANAR_MODE | |
  82949. * | 3 | CUBIC_MODE | |
  82950. * | 4 | PROJECTION_MODE | |
  82951. * | 5 | SKYBOX_MODE | |
  82952. * | 6 | INVCUBIC_MODE | |
  82953. * | 7 | EQUIRECTANGULAR_MODE | |
  82954. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82955. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82956. */
  82957. coordinatesMode: number;
  82958. /**
  82959. * | Value | Type | Description |
  82960. * | ----- | ------------------ | ----------- |
  82961. * | 0 | CLAMP_ADDRESSMODE | |
  82962. * | 1 | WRAP_ADDRESSMODE | |
  82963. * | 2 | MIRROR_ADDRESSMODE | |
  82964. */
  82965. wrapU: number;
  82966. /**
  82967. * | Value | Type | Description |
  82968. * | ----- | ------------------ | ----------- |
  82969. * | 0 | CLAMP_ADDRESSMODE | |
  82970. * | 1 | WRAP_ADDRESSMODE | |
  82971. * | 2 | MIRROR_ADDRESSMODE | |
  82972. */
  82973. wrapV: number;
  82974. /**
  82975. * | Value | Type | Description |
  82976. * | ----- | ------------------ | ----------- |
  82977. * | 0 | CLAMP_ADDRESSMODE | |
  82978. * | 1 | WRAP_ADDRESSMODE | |
  82979. * | 2 | MIRROR_ADDRESSMODE | |
  82980. */
  82981. wrapR: number;
  82982. /**
  82983. * With compliant hardware and browser (supporting anisotropic filtering)
  82984. * this defines the level of anisotropic filtering in the texture.
  82985. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82986. */
  82987. anisotropicFilteringLevel: number;
  82988. /**
  82989. * Define if the texture is a cube texture or if false a 2d texture.
  82990. */
  82991. isCube: boolean;
  82992. /**
  82993. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82994. */
  82995. is3D: boolean;
  82996. /**
  82997. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82998. * HDR texture are usually stored in linear space.
  82999. * This only impacts the PBR and Background materials
  83000. */
  83001. gammaSpace: boolean;
  83002. /**
  83003. * Gets whether or not the texture contains RGBD data.
  83004. */
  83005. readonly isRGBD: boolean;
  83006. /**
  83007. * Is Z inverted in the texture (useful in a cube texture).
  83008. */
  83009. invertZ: boolean;
  83010. /**
  83011. * Are mip maps generated for this texture or not.
  83012. */
  83013. readonly noMipmap: boolean;
  83014. /**
  83015. * @hidden
  83016. */
  83017. lodLevelInAlpha: boolean;
  83018. /**
  83019. * With prefiltered texture, defined the offset used during the prefiltering steps.
  83020. */
  83021. lodGenerationOffset: number;
  83022. /**
  83023. * With prefiltered texture, defined the scale used during the prefiltering steps.
  83024. */
  83025. lodGenerationScale: number;
  83026. /**
  83027. * Define if the texture is a render target.
  83028. */
  83029. isRenderTarget: boolean;
  83030. /**
  83031. * Define the unique id of the texture in the scene.
  83032. */
  83033. readonly uid: string;
  83034. /**
  83035. * Return a string representation of the texture.
  83036. * @returns the texture as a string
  83037. */
  83038. toString(): string;
  83039. /**
  83040. * Get the class name of the texture.
  83041. * @returns "BaseTexture"
  83042. */
  83043. getClassName(): string;
  83044. /**
  83045. * Define the list of animation attached to the texture.
  83046. */
  83047. animations: Animation[];
  83048. /**
  83049. * An event triggered when the texture is disposed.
  83050. */
  83051. onDisposeObservable: Observable<BaseTexture>;
  83052. private _onDisposeObserver;
  83053. /**
  83054. * Callback triggered when the texture has been disposed.
  83055. * Kept for back compatibility, you can use the onDisposeObservable instead.
  83056. */
  83057. onDispose: () => void;
  83058. /**
  83059. * Define the current state of the loading sequence when in delayed load mode.
  83060. */
  83061. delayLoadState: number;
  83062. private _scene;
  83063. /** @hidden */
  83064. _texture: Nullable<InternalTexture>;
  83065. private _uid;
  83066. /**
  83067. * Define if the texture is preventinga material to render or not.
  83068. * If not and the texture is not ready, the engine will use a default black texture instead.
  83069. */
  83070. readonly isBlocking: boolean;
  83071. /**
  83072. * Instantiates a new BaseTexture.
  83073. * Base class of all the textures in babylon.
  83074. * It groups all the common properties the materials, post process, lights... might need
  83075. * in order to make a correct use of the texture.
  83076. * @param scene Define the scene the texture blongs to
  83077. */
  83078. constructor(scene: Nullable<Scene>);
  83079. /**
  83080. * Get the scene the texture belongs to.
  83081. * @returns the scene or null if undefined
  83082. */
  83083. getScene(): Nullable<Scene>;
  83084. /**
  83085. * Get the texture transform matrix used to offset tile the texture for istance.
  83086. * @returns the transformation matrix
  83087. */
  83088. getTextureMatrix(): Matrix;
  83089. /**
  83090. * Get the texture reflection matrix used to rotate/transform the reflection.
  83091. * @returns the reflection matrix
  83092. */
  83093. getReflectionTextureMatrix(): Matrix;
  83094. /**
  83095. * Get the underlying lower level texture from Babylon.
  83096. * @returns the insternal texture
  83097. */
  83098. getInternalTexture(): Nullable<InternalTexture>;
  83099. /**
  83100. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  83101. * @returns true if ready or not blocking
  83102. */
  83103. isReadyOrNotBlocking(): boolean;
  83104. /**
  83105. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83106. * @returns true if fully ready
  83107. */
  83108. isReady(): boolean;
  83109. private _cachedSize;
  83110. /**
  83111. * Get the size of the texture.
  83112. * @returns the texture size.
  83113. */
  83114. getSize(): ISize;
  83115. /**
  83116. * Get the base size of the texture.
  83117. * It can be different from the size if the texture has been resized for POT for instance
  83118. * @returns the base size
  83119. */
  83120. getBaseSize(): ISize;
  83121. /**
  83122. * Update the sampling mode of the texture.
  83123. * Default is Trilinear mode.
  83124. *
  83125. * | Value | Type | Description |
  83126. * | ----- | ------------------ | ----------- |
  83127. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83128. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83129. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83130. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83131. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83132. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83133. * | 7 | NEAREST_LINEAR | |
  83134. * | 8 | NEAREST_NEAREST | |
  83135. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83136. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83137. * | 11 | LINEAR_LINEAR | |
  83138. * | 12 | LINEAR_NEAREST | |
  83139. *
  83140. * > _mag_: magnification filter (close to the viewer)
  83141. * > _min_: minification filter (far from the viewer)
  83142. * > _mip_: filter used between mip map levels
  83143. *@param samplingMode Define the new sampling mode of the texture
  83144. */
  83145. updateSamplingMode(samplingMode: number): void;
  83146. /**
  83147. * Scales the texture if is `canRescale()`
  83148. * @param ratio the resize factor we want to use to rescale
  83149. */
  83150. scale(ratio: number): void;
  83151. /**
  83152. * Get if the texture can rescale.
  83153. */
  83154. readonly canRescale: boolean;
  83155. /** @hidden */
  83156. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  83157. /** @hidden */
  83158. _rebuild(): void;
  83159. /**
  83160. * Triggers the load sequence in delayed load mode.
  83161. */
  83162. delayLoad(): void;
  83163. /**
  83164. * Clones the texture.
  83165. * @returns the cloned texture
  83166. */
  83167. clone(): Nullable<BaseTexture>;
  83168. /**
  83169. * Get the texture underlying type (INT, FLOAT...)
  83170. */
  83171. readonly textureType: number;
  83172. /**
  83173. * Get the texture underlying format (RGB, RGBA...)
  83174. */
  83175. readonly textureFormat: number;
  83176. /**
  83177. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  83178. * This will returns an RGBA array buffer containing either in values (0-255) or
  83179. * float values (0-1) depending of the underlying buffer type.
  83180. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  83181. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  83182. * @param buffer defines a user defined buffer to fill with data (can be null)
  83183. * @returns The Array buffer containing the pixels data.
  83184. */
  83185. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  83186. /**
  83187. * Release and destroy the underlying lower level texture aka internalTexture.
  83188. */
  83189. releaseInternalTexture(): void;
  83190. /**
  83191. * Get the polynomial representation of the texture data.
  83192. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  83193. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  83194. */
  83195. sphericalPolynomial: Nullable<SphericalPolynomial>;
  83196. /** @hidden */
  83197. readonly _lodTextureHigh: Nullable<BaseTexture>;
  83198. /** @hidden */
  83199. readonly _lodTextureMid: Nullable<BaseTexture>;
  83200. /** @hidden */
  83201. readonly _lodTextureLow: Nullable<BaseTexture>;
  83202. /**
  83203. * Dispose the texture and release its associated resources.
  83204. */
  83205. dispose(): void;
  83206. /**
  83207. * Serialize the texture into a JSON representation that can be parsed later on.
  83208. * @returns the JSON representation of the texture
  83209. */
  83210. serialize(): any;
  83211. /**
  83212. * Helper function to be called back once a list of texture contains only ready textures.
  83213. * @param textures Define the list of textures to wait for
  83214. * @param callback Define the callback triggered once the entire list will be ready
  83215. */
  83216. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  83217. }
  83218. }
  83219. declare module BABYLON {
  83220. /**
  83221. * Uniform buffer objects.
  83222. *
  83223. * Handles blocks of uniform on the GPU.
  83224. *
  83225. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83226. *
  83227. * For more information, please refer to :
  83228. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83229. */
  83230. export class UniformBuffer {
  83231. private _engine;
  83232. private _buffer;
  83233. private _data;
  83234. private _bufferData;
  83235. private _dynamic?;
  83236. private _uniformLocations;
  83237. private _uniformSizes;
  83238. private _uniformLocationPointer;
  83239. private _needSync;
  83240. private _noUBO;
  83241. private _currentEffect;
  83242. private static _MAX_UNIFORM_SIZE;
  83243. private static _tempBuffer;
  83244. /**
  83245. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83246. * This is dynamic to allow compat with webgl 1 and 2.
  83247. * You will need to pass the name of the uniform as well as the value.
  83248. */
  83249. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83250. /**
  83251. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83252. * This is dynamic to allow compat with webgl 1 and 2.
  83253. * You will need to pass the name of the uniform as well as the value.
  83254. */
  83255. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83256. /**
  83257. * Lambda to Update a single float in a uniform buffer.
  83258. * This is dynamic to allow compat with webgl 1 and 2.
  83259. * You will need to pass the name of the uniform as well as the value.
  83260. */
  83261. updateFloat: (name: string, x: number) => void;
  83262. /**
  83263. * Lambda to Update a vec2 of float in a uniform buffer.
  83264. * This is dynamic to allow compat with webgl 1 and 2.
  83265. * You will need to pass the name of the uniform as well as the value.
  83266. */
  83267. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  83268. /**
  83269. * Lambda to Update a vec3 of float in a uniform buffer.
  83270. * This is dynamic to allow compat with webgl 1 and 2.
  83271. * You will need to pass the name of the uniform as well as the value.
  83272. */
  83273. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  83274. /**
  83275. * Lambda to Update a vec4 of float in a uniform buffer.
  83276. * This is dynamic to allow compat with webgl 1 and 2.
  83277. * You will need to pass the name of the uniform as well as the value.
  83278. */
  83279. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  83280. /**
  83281. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  83282. * This is dynamic to allow compat with webgl 1 and 2.
  83283. * You will need to pass the name of the uniform as well as the value.
  83284. */
  83285. updateMatrix: (name: string, mat: Matrix) => void;
  83286. /**
  83287. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  83288. * This is dynamic to allow compat with webgl 1 and 2.
  83289. * You will need to pass the name of the uniform as well as the value.
  83290. */
  83291. updateVector3: (name: string, vector: Vector3) => void;
  83292. /**
  83293. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  83294. * This is dynamic to allow compat with webgl 1 and 2.
  83295. * You will need to pass the name of the uniform as well as the value.
  83296. */
  83297. updateVector4: (name: string, vector: Vector4) => void;
  83298. /**
  83299. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  83300. * This is dynamic to allow compat with webgl 1 and 2.
  83301. * You will need to pass the name of the uniform as well as the value.
  83302. */
  83303. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  83304. /**
  83305. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  83306. * This is dynamic to allow compat with webgl 1 and 2.
  83307. * You will need to pass the name of the uniform as well as the value.
  83308. */
  83309. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  83310. /**
  83311. * Instantiates a new Uniform buffer objects.
  83312. *
  83313. * Handles blocks of uniform on the GPU.
  83314. *
  83315. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83316. *
  83317. * For more information, please refer to :
  83318. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83319. * @param engine Define the engine the buffer is associated with
  83320. * @param data Define the data contained in the buffer
  83321. * @param dynamic Define if the buffer is updatable
  83322. */
  83323. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  83324. /**
  83325. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83326. * or just falling back on setUniformXXX calls.
  83327. */
  83328. readonly useUbo: boolean;
  83329. /**
  83330. * Indicates if the WebGL underlying uniform buffer is in sync
  83331. * with the javascript cache data.
  83332. */
  83333. readonly isSync: boolean;
  83334. /**
  83335. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83336. * Also, a dynamic UniformBuffer will disable cache verification and always
  83337. * update the underlying WebGL uniform buffer to the GPU.
  83338. * @returns if Dynamic, otherwise false
  83339. */
  83340. isDynamic(): boolean;
  83341. /**
  83342. * The data cache on JS side.
  83343. * @returns the underlying data as a float array
  83344. */
  83345. getData(): Float32Array;
  83346. /**
  83347. * The underlying WebGL Uniform buffer.
  83348. * @returns the webgl buffer
  83349. */
  83350. getBuffer(): Nullable<WebGLBuffer>;
  83351. /**
  83352. * std140 layout specifies how to align data within an UBO structure.
  83353. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83354. * for specs.
  83355. */
  83356. private _fillAlignment;
  83357. /**
  83358. * Adds an uniform in the buffer.
  83359. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83360. * for the layout to be correct !
  83361. * @param name Name of the uniform, as used in the uniform block in the shader.
  83362. * @param size Data size, or data directly.
  83363. */
  83364. addUniform(name: string, size: number | number[]): void;
  83365. /**
  83366. * Adds a Matrix 4x4 to the uniform buffer.
  83367. * @param name Name of the uniform, as used in the uniform block in the shader.
  83368. * @param mat A 4x4 matrix.
  83369. */
  83370. addMatrix(name: string, mat: Matrix): void;
  83371. /**
  83372. * Adds a vec2 to the uniform buffer.
  83373. * @param name Name of the uniform, as used in the uniform block in the shader.
  83374. * @param x Define the x component value of the vec2
  83375. * @param y Define the y component value of the vec2
  83376. */
  83377. addFloat2(name: string, x: number, y: number): void;
  83378. /**
  83379. * Adds a vec3 to the uniform buffer.
  83380. * @param name Name of the uniform, as used in the uniform block in the shader.
  83381. * @param x Define the x component value of the vec3
  83382. * @param y Define the y component value of the vec3
  83383. * @param z Define the z component value of the vec3
  83384. */
  83385. addFloat3(name: string, x: number, y: number, z: number): void;
  83386. /**
  83387. * Adds a vec3 to the uniform buffer.
  83388. * @param name Name of the uniform, as used in the uniform block in the shader.
  83389. * @param color Define the vec3 from a Color
  83390. */
  83391. addColor3(name: string, color: Color3): void;
  83392. /**
  83393. * Adds a vec4 to the uniform buffer.
  83394. * @param name Name of the uniform, as used in the uniform block in the shader.
  83395. * @param color Define the rgb components from a Color
  83396. * @param alpha Define the a component of the vec4
  83397. */
  83398. addColor4(name: string, color: Color3, alpha: number): void;
  83399. /**
  83400. * Adds a vec3 to the uniform buffer.
  83401. * @param name Name of the uniform, as used in the uniform block in the shader.
  83402. * @param vector Define the vec3 components from a Vector
  83403. */
  83404. addVector3(name: string, vector: Vector3): void;
  83405. /**
  83406. * Adds a Matrix 3x3 to the uniform buffer.
  83407. * @param name Name of the uniform, as used in the uniform block in the shader.
  83408. */
  83409. addMatrix3x3(name: string): void;
  83410. /**
  83411. * Adds a Matrix 2x2 to the uniform buffer.
  83412. * @param name Name of the uniform, as used in the uniform block in the shader.
  83413. */
  83414. addMatrix2x2(name: string): void;
  83415. /**
  83416. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83417. */
  83418. create(): void;
  83419. /** @hidden */
  83420. _rebuild(): void;
  83421. /**
  83422. * Updates the WebGL Uniform Buffer on the GPU.
  83423. * If the `dynamic` flag is set to true, no cache comparison is done.
  83424. * Otherwise, the buffer will be updated only if the cache differs.
  83425. */
  83426. update(): void;
  83427. /**
  83428. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83429. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83430. * @param data Define the flattened data
  83431. * @param size Define the size of the data.
  83432. */
  83433. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83434. private _updateMatrix3x3ForUniform;
  83435. private _updateMatrix3x3ForEffect;
  83436. private _updateMatrix2x2ForEffect;
  83437. private _updateMatrix2x2ForUniform;
  83438. private _updateFloatForEffect;
  83439. private _updateFloatForUniform;
  83440. private _updateFloat2ForEffect;
  83441. private _updateFloat2ForUniform;
  83442. private _updateFloat3ForEffect;
  83443. private _updateFloat3ForUniform;
  83444. private _updateFloat4ForEffect;
  83445. private _updateFloat4ForUniform;
  83446. private _updateMatrixForEffect;
  83447. private _updateMatrixForUniform;
  83448. private _updateVector3ForEffect;
  83449. private _updateVector3ForUniform;
  83450. private _updateVector4ForEffect;
  83451. private _updateVector4ForUniform;
  83452. private _updateColor3ForEffect;
  83453. private _updateColor3ForUniform;
  83454. private _updateColor4ForEffect;
  83455. private _updateColor4ForUniform;
  83456. /**
  83457. * Sets a sampler uniform on the effect.
  83458. * @param name Define the name of the sampler.
  83459. * @param texture Define the texture to set in the sampler
  83460. */
  83461. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83462. /**
  83463. * Directly updates the value of the uniform in the cache AND on the GPU.
  83464. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83465. * @param data Define the flattened data
  83466. */
  83467. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83468. /**
  83469. * Binds this uniform buffer to an effect.
  83470. * @param effect Define the effect to bind the buffer to
  83471. * @param name Name of the uniform block in the shader.
  83472. */
  83473. bindToEffect(effect: Effect, name: string): void;
  83474. /**
  83475. * Disposes the uniform buffer.
  83476. */
  83477. dispose(): void;
  83478. }
  83479. }
  83480. declare module BABYLON {
  83481. /**
  83482. * This represents the required contract to create a new type of texture loader.
  83483. */
  83484. export interface IInternalTextureLoader {
  83485. /**
  83486. * Defines wether the loader supports cascade loading the different faces.
  83487. */
  83488. supportCascades: boolean;
  83489. /**
  83490. * This returns if the loader support the current file information.
  83491. * @param extension defines the file extension of the file being loaded
  83492. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83493. * @param fallback defines the fallback internal texture if any
  83494. * @param isBase64 defines whether the texture is encoded as a base64
  83495. * @param isBuffer defines whether the texture data are stored as a buffer
  83496. * @returns true if the loader can load the specified file
  83497. */
  83498. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  83499. /**
  83500. * Transform the url before loading if required.
  83501. * @param rootUrl the url of the texture
  83502. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83503. * @returns the transformed texture
  83504. */
  83505. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  83506. /**
  83507. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  83508. * @param rootUrl the url of the texture
  83509. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83510. * @returns the fallback texture
  83511. */
  83512. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  83513. /**
  83514. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  83515. * @param data contains the texture data
  83516. * @param texture defines the BabylonJS internal texture
  83517. * @param createPolynomials will be true if polynomials have been requested
  83518. * @param onLoad defines the callback to trigger once the texture is ready
  83519. * @param onError defines the callback to trigger in case of error
  83520. */
  83521. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  83522. /**
  83523. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  83524. * @param data contains the texture data
  83525. * @param texture defines the BabylonJS internal texture
  83526. * @param callback defines the method to call once ready to upload
  83527. */
  83528. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  83529. }
  83530. }
  83531. declare module BABYLON {
  83532. /**
  83533. * Creation options of the multi render target texture.
  83534. */
  83535. export interface IMultiRenderTargetOptions {
  83536. /**
  83537. * Define if the texture needs to create mip maps after render.
  83538. */
  83539. generateMipMaps?: boolean;
  83540. /**
  83541. * Define the types of all the draw buffers we want to create
  83542. */
  83543. types?: number[];
  83544. /**
  83545. * Define the sampling modes of all the draw buffers we want to create
  83546. */
  83547. samplingModes?: number[];
  83548. /**
  83549. * Define if a depth buffer is required
  83550. */
  83551. generateDepthBuffer?: boolean;
  83552. /**
  83553. * Define if a stencil buffer is required
  83554. */
  83555. generateStencilBuffer?: boolean;
  83556. /**
  83557. * Define if a depth texture is required instead of a depth buffer
  83558. */
  83559. generateDepthTexture?: boolean;
  83560. /**
  83561. * Define the number of desired draw buffers
  83562. */
  83563. textureCount?: number;
  83564. /**
  83565. * Define if aspect ratio should be adapted to the texture or stay the scene one
  83566. */
  83567. doNotChangeAspectRatio?: boolean;
  83568. /**
  83569. * Define the default type of the buffers we are creating
  83570. */
  83571. defaultType?: number;
  83572. }
  83573. /**
  83574. * A multi render target, like a render target provides the ability to render to a texture.
  83575. * Unlike the render target, it can render to several draw buffers in one draw.
  83576. * This is specially interesting in deferred rendering or for any effects requiring more than
  83577. * just one color from a single pass.
  83578. */
  83579. export class MultiRenderTarget extends RenderTargetTexture {
  83580. private _internalTextures;
  83581. private _textures;
  83582. private _multiRenderTargetOptions;
  83583. /**
  83584. * Get if draw buffers are currently supported by the used hardware and browser.
  83585. */
  83586. readonly isSupported: boolean;
  83587. /**
  83588. * Get the list of textures generated by the multi render target.
  83589. */
  83590. readonly textures: Texture[];
  83591. /**
  83592. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83593. */
  83594. readonly depthTexture: Texture;
  83595. /**
  83596. * Set the wrapping mode on U of all the textures we are rendering to.
  83597. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83598. */
  83599. wrapU: number;
  83600. /**
  83601. * Set the wrapping mode on V of all the textures we are rendering to.
  83602. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83603. */
  83604. wrapV: number;
  83605. /**
  83606. * Instantiate a new multi render target texture.
  83607. * A multi render target, like a render target provides the ability to render to a texture.
  83608. * Unlike the render target, it can render to several draw buffers in one draw.
  83609. * This is specially interesting in deferred rendering or for any effects requiring more than
  83610. * just one color from a single pass.
  83611. * @param name Define the name of the texture
  83612. * @param size Define the size of the buffers to render to
  83613. * @param count Define the number of target we are rendering into
  83614. * @param scene Define the scene the texture belongs to
  83615. * @param options Define the options used to create the multi render target
  83616. */
  83617. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83618. /** @hidden */
  83619. _rebuild(): void;
  83620. private _createInternalTextures;
  83621. private _createTextures;
  83622. /**
  83623. * Define the number of samples used if MSAA is enabled.
  83624. */
  83625. samples: number;
  83626. /**
  83627. * Resize all the textures in the multi render target.
  83628. * Be carrefull as it will recreate all the data in the new texture.
  83629. * @param size Define the new size
  83630. */
  83631. resize(size: any): void;
  83632. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83633. /**
  83634. * Dispose the render targets and their associated resources
  83635. */
  83636. dispose(): void;
  83637. /**
  83638. * Release all the underlying texture used as draw buffers.
  83639. */
  83640. releaseInternalTextures(): void;
  83641. }
  83642. }
  83643. declare module BABYLON {
  83644. /**
  83645. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83647. */
  83648. export class Analyser {
  83649. /**
  83650. * Gets or sets the smoothing
  83651. * @ignorenaming
  83652. */
  83653. SMOOTHING: number;
  83654. /**
  83655. * Gets or sets the FFT table size
  83656. * @ignorenaming
  83657. */
  83658. FFT_SIZE: number;
  83659. /**
  83660. * Gets or sets the bar graph amplitude
  83661. * @ignorenaming
  83662. */
  83663. BARGRAPHAMPLITUDE: number;
  83664. /**
  83665. * Gets or sets the position of the debug canvas
  83666. * @ignorenaming
  83667. */
  83668. DEBUGCANVASPOS: {
  83669. x: number;
  83670. y: number;
  83671. };
  83672. /**
  83673. * Gets or sets the debug canvas size
  83674. * @ignorenaming
  83675. */
  83676. DEBUGCANVASSIZE: {
  83677. width: number;
  83678. height: number;
  83679. };
  83680. private _byteFreqs;
  83681. private _byteTime;
  83682. private _floatFreqs;
  83683. private _webAudioAnalyser;
  83684. private _debugCanvas;
  83685. private _debugCanvasContext;
  83686. private _scene;
  83687. private _registerFunc;
  83688. private _audioEngine;
  83689. /**
  83690. * Creates a new analyser
  83691. * @param scene defines hosting scene
  83692. */
  83693. constructor(scene: Scene);
  83694. /**
  83695. * Get the number of data values you will have to play with for the visualization
  83696. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83697. * @returns a number
  83698. */
  83699. getFrequencyBinCount(): number;
  83700. /**
  83701. * Gets the current frequency data as a byte array
  83702. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83703. * @returns a Uint8Array
  83704. */
  83705. getByteFrequencyData(): Uint8Array;
  83706. /**
  83707. * Gets the current waveform as a byte array
  83708. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83709. * @returns a Uint8Array
  83710. */
  83711. getByteTimeDomainData(): Uint8Array;
  83712. /**
  83713. * Gets the current frequency data as a float array
  83714. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83715. * @returns a Float32Array
  83716. */
  83717. getFloatFrequencyData(): Float32Array;
  83718. /**
  83719. * Renders the debug canvas
  83720. */
  83721. drawDebugCanvas(): void;
  83722. /**
  83723. * Stops rendering the debug canvas and removes it
  83724. */
  83725. stopDebugCanvas(): void;
  83726. /**
  83727. * Connects two audio nodes
  83728. * @param inputAudioNode defines first node to connect
  83729. * @param outputAudioNode defines second node to connect
  83730. */
  83731. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83732. /**
  83733. * Releases all associated resources
  83734. */
  83735. dispose(): void;
  83736. }
  83737. }
  83738. declare module BABYLON {
  83739. /**
  83740. * This represents an audio engine and it is responsible
  83741. * to play, synchronize and analyse sounds throughout the application.
  83742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83743. */
  83744. export interface IAudioEngine extends IDisposable {
  83745. /**
  83746. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83747. */
  83748. readonly canUseWebAudio: boolean;
  83749. /**
  83750. * Gets the current AudioContext if available.
  83751. */
  83752. readonly audioContext: Nullable<AudioContext>;
  83753. /**
  83754. * The master gain node defines the global audio volume of your audio engine.
  83755. */
  83756. readonly masterGain: GainNode;
  83757. /**
  83758. * Gets whether or not mp3 are supported by your browser.
  83759. */
  83760. readonly isMP3supported: boolean;
  83761. /**
  83762. * Gets whether or not ogg are supported by your browser.
  83763. */
  83764. readonly isOGGsupported: boolean;
  83765. /**
  83766. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83767. * @ignoreNaming
  83768. */
  83769. WarnedWebAudioUnsupported: boolean;
  83770. /**
  83771. * Defines if the audio engine relies on a custom unlocked button.
  83772. * In this case, the embedded button will not be displayed.
  83773. */
  83774. useCustomUnlockedButton: boolean;
  83775. /**
  83776. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83777. */
  83778. readonly unlocked: boolean;
  83779. /**
  83780. * Event raised when audio has been unlocked on the browser.
  83781. */
  83782. onAudioUnlockedObservable: Observable<AudioEngine>;
  83783. /**
  83784. * Event raised when audio has been locked on the browser.
  83785. */
  83786. onAudioLockedObservable: Observable<AudioEngine>;
  83787. /**
  83788. * Flags the audio engine in Locked state.
  83789. * This happens due to new browser policies preventing audio to autoplay.
  83790. */
  83791. lock(): void;
  83792. /**
  83793. * Unlocks the audio engine once a user action has been done on the dom.
  83794. * This is helpful to resume play once browser policies have been satisfied.
  83795. */
  83796. unlock(): void;
  83797. }
  83798. /**
  83799. * This represents the default audio engine used in babylon.
  83800. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83802. */
  83803. export class AudioEngine implements IAudioEngine {
  83804. private _audioContext;
  83805. private _audioContextInitialized;
  83806. private _muteButton;
  83807. private _hostElement;
  83808. /**
  83809. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83810. */
  83811. canUseWebAudio: boolean;
  83812. /**
  83813. * The master gain node defines the global audio volume of your audio engine.
  83814. */
  83815. masterGain: GainNode;
  83816. /**
  83817. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83818. * @ignoreNaming
  83819. */
  83820. WarnedWebAudioUnsupported: boolean;
  83821. /**
  83822. * Gets whether or not mp3 are supported by your browser.
  83823. */
  83824. isMP3supported: boolean;
  83825. /**
  83826. * Gets whether or not ogg are supported by your browser.
  83827. */
  83828. isOGGsupported: boolean;
  83829. /**
  83830. * Gets whether audio has been unlocked on the device.
  83831. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83832. * a user interaction has happened.
  83833. */
  83834. unlocked: boolean;
  83835. /**
  83836. * Defines if the audio engine relies on a custom unlocked button.
  83837. * In this case, the embedded button will not be displayed.
  83838. */
  83839. useCustomUnlockedButton: boolean;
  83840. /**
  83841. * Event raised when audio has been unlocked on the browser.
  83842. */
  83843. onAudioUnlockedObservable: Observable<AudioEngine>;
  83844. /**
  83845. * Event raised when audio has been locked on the browser.
  83846. */
  83847. onAudioLockedObservable: Observable<AudioEngine>;
  83848. /**
  83849. * Gets the current AudioContext if available.
  83850. */
  83851. readonly audioContext: Nullable<AudioContext>;
  83852. private _connectedAnalyser;
  83853. /**
  83854. * Instantiates a new audio engine.
  83855. *
  83856. * There should be only one per page as some browsers restrict the number
  83857. * of audio contexts you can create.
  83858. * @param hostElement defines the host element where to display the mute icon if necessary
  83859. */
  83860. constructor(hostElement?: Nullable<HTMLElement>);
  83861. /**
  83862. * Flags the audio engine in Locked state.
  83863. * This happens due to new browser policies preventing audio to autoplay.
  83864. */
  83865. lock(): void;
  83866. /**
  83867. * Unlocks the audio engine once a user action has been done on the dom.
  83868. * This is helpful to resume play once browser policies have been satisfied.
  83869. */
  83870. unlock(): void;
  83871. private _resumeAudioContext;
  83872. private _initializeAudioContext;
  83873. private _tryToRun;
  83874. private _triggerRunningState;
  83875. private _triggerSuspendedState;
  83876. private _displayMuteButton;
  83877. private _moveButtonToTopLeft;
  83878. private _onResize;
  83879. private _hideMuteButton;
  83880. /**
  83881. * Destroy and release the resources associated with the audio ccontext.
  83882. */
  83883. dispose(): void;
  83884. /**
  83885. * Gets the global volume sets on the master gain.
  83886. * @returns the global volume if set or -1 otherwise
  83887. */
  83888. getGlobalVolume(): number;
  83889. /**
  83890. * Sets the global volume of your experience (sets on the master gain).
  83891. * @param newVolume Defines the new global volume of the application
  83892. */
  83893. setGlobalVolume(newVolume: number): void;
  83894. /**
  83895. * Connect the audio engine to an audio analyser allowing some amazing
  83896. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83898. * @param analyser The analyser to connect to the engine
  83899. */
  83900. connectToAnalyser(analyser: Analyser): void;
  83901. }
  83902. }
  83903. declare module BABYLON {
  83904. /**
  83905. * Interface used to present a loading screen while loading a scene
  83906. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83907. */
  83908. export interface ILoadingScreen {
  83909. /**
  83910. * Function called to display the loading screen
  83911. */
  83912. displayLoadingUI: () => void;
  83913. /**
  83914. * Function called to hide the loading screen
  83915. */
  83916. hideLoadingUI: () => void;
  83917. /**
  83918. * Gets or sets the color to use for the background
  83919. */
  83920. loadingUIBackgroundColor: string;
  83921. /**
  83922. * Gets or sets the text to display while loading
  83923. */
  83924. loadingUIText: string;
  83925. }
  83926. /**
  83927. * Class used for the default loading screen
  83928. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83929. */
  83930. export class DefaultLoadingScreen implements ILoadingScreen {
  83931. private _renderingCanvas;
  83932. private _loadingText;
  83933. private _loadingDivBackgroundColor;
  83934. private _loadingDiv;
  83935. private _loadingTextDiv;
  83936. /**
  83937. * Creates a new default loading screen
  83938. * @param _renderingCanvas defines the canvas used to render the scene
  83939. * @param _loadingText defines the default text to display
  83940. * @param _loadingDivBackgroundColor defines the default background color
  83941. */
  83942. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83943. /**
  83944. * Function called to display the loading screen
  83945. */
  83946. displayLoadingUI(): void;
  83947. /**
  83948. * Function called to hide the loading screen
  83949. */
  83950. hideLoadingUI(): void;
  83951. /**
  83952. * Gets or sets the text to display while loading
  83953. */
  83954. loadingUIText: string;
  83955. /**
  83956. * Gets or sets the color to use for the background
  83957. */
  83958. loadingUIBackgroundColor: string;
  83959. private _resizeLoadingUI;
  83960. }
  83961. }
  83962. declare module BABYLON {
  83963. /**
  83964. * Settings for finer control over video usage
  83965. */
  83966. export interface VideoTextureSettings {
  83967. /**
  83968. * Applies `autoplay` to video, if specified
  83969. */
  83970. autoPlay?: boolean;
  83971. /**
  83972. * Applies `loop` to video, if specified
  83973. */
  83974. loop?: boolean;
  83975. /**
  83976. * Automatically updates internal texture from video at every frame in the render loop
  83977. */
  83978. autoUpdateTexture: boolean;
  83979. /**
  83980. * Image src displayed during the video loading or until the user interacts with the video.
  83981. */
  83982. poster?: string;
  83983. }
  83984. /**
  83985. * If you want to display a video in your scene, this is the special texture for that.
  83986. * This special texture works similar to other textures, with the exception of a few parameters.
  83987. * @see https://doc.babylonjs.com/how_to/video_texture
  83988. */
  83989. export class VideoTexture extends Texture {
  83990. /**
  83991. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83992. */
  83993. readonly autoUpdateTexture: boolean;
  83994. /**
  83995. * The video instance used by the texture internally
  83996. */
  83997. readonly video: HTMLVideoElement;
  83998. private _onUserActionRequestedObservable;
  83999. /**
  84000. * Event triggerd when a dom action is required by the user to play the video.
  84001. * This happens due to recent changes in browser policies preventing video to auto start.
  84002. */
  84003. readonly onUserActionRequestedObservable: Observable<Texture>;
  84004. private _generateMipMaps;
  84005. private _engine;
  84006. private _stillImageCaptured;
  84007. private _displayingPosterTexture;
  84008. private _settings;
  84009. private _createInternalTextureOnEvent;
  84010. /**
  84011. * Creates a video texture.
  84012. * If you want to display a video in your scene, this is the special texture for that.
  84013. * This special texture works similar to other textures, with the exception of a few parameters.
  84014. * @see https://doc.babylonjs.com/how_to/video_texture
  84015. * @param name optional name, will detect from video source, if not defined
  84016. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  84017. * @param scene is obviously the current scene.
  84018. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  84019. * @param invertY is false by default but can be used to invert video on Y axis
  84020. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  84021. * @param settings allows finer control over video usage
  84022. */
  84023. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  84024. private _getName;
  84025. private _getVideo;
  84026. private _createInternalTexture;
  84027. private reset;
  84028. /**
  84029. * @hidden Internal method to initiate `update`.
  84030. */
  84031. _rebuild(): void;
  84032. /**
  84033. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  84034. */
  84035. update(): void;
  84036. /**
  84037. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  84038. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  84039. */
  84040. updateTexture(isVisible: boolean): void;
  84041. protected _updateInternalTexture: () => void;
  84042. /**
  84043. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  84044. * @param url New url.
  84045. */
  84046. updateURL(url: string): void;
  84047. /**
  84048. * Dispose the texture and release its associated resources.
  84049. */
  84050. dispose(): void;
  84051. /**
  84052. * Creates a video texture straight from a stream.
  84053. * @param scene Define the scene the texture should be created in
  84054. * @param stream Define the stream the texture should be created from
  84055. * @returns The created video texture as a promise
  84056. */
  84057. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  84058. /**
  84059. * Creates a video texture straight from your WebCam video feed.
  84060. * @param scene Define the scene the texture should be created in
  84061. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84062. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84063. * @returns The created video texture as a promise
  84064. */
  84065. static CreateFromWebCamAsync(scene: Scene, constraints: {
  84066. minWidth: number;
  84067. maxWidth: number;
  84068. minHeight: number;
  84069. maxHeight: number;
  84070. deviceId: string;
  84071. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  84072. /**
  84073. * Creates a video texture straight from your WebCam video feed.
  84074. * @param scene Define the scene the texture should be created in
  84075. * @param onReady Define a callback to triggered once the texture will be ready
  84076. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84077. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84078. */
  84079. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  84080. minWidth: number;
  84081. maxWidth: number;
  84082. minHeight: number;
  84083. maxHeight: number;
  84084. deviceId: string;
  84085. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  84086. }
  84087. }
  84088. declare module BABYLON {
  84089. /**
  84090. * Interface for attribute information associated with buffer instanciation
  84091. */
  84092. export class InstancingAttributeInfo {
  84093. /**
  84094. * Index/offset of the attribute in the vertex shader
  84095. */
  84096. index: number;
  84097. /**
  84098. * size of the attribute, 1, 2, 3 or 4
  84099. */
  84100. attributeSize: number;
  84101. /**
  84102. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  84103. * default is FLOAT
  84104. */
  84105. attribyteType: number;
  84106. /**
  84107. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  84108. */
  84109. normalized: boolean;
  84110. /**
  84111. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  84112. */
  84113. offset: number;
  84114. /**
  84115. * Name of the GLSL attribute, for debugging purpose only
  84116. */
  84117. attributeName: string;
  84118. }
  84119. /**
  84120. * Define options used to create a depth texture
  84121. */
  84122. export class DepthTextureCreationOptions {
  84123. /** Specifies whether or not a stencil should be allocated in the texture */
  84124. generateStencil?: boolean;
  84125. /** Specifies whether or not bilinear filtering is enable on the texture */
  84126. bilinearFiltering?: boolean;
  84127. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84128. comparisonFunction?: number;
  84129. /** Specifies if the created texture is a cube texture */
  84130. isCube?: boolean;
  84131. }
  84132. /**
  84133. * Class used to describe the capabilities of the engine relatively to the current browser
  84134. */
  84135. export class EngineCapabilities {
  84136. /** Maximum textures units per fragment shader */
  84137. maxTexturesImageUnits: number;
  84138. /** Maximum texture units per vertex shader */
  84139. maxVertexTextureImageUnits: number;
  84140. /** Maximum textures units in the entire pipeline */
  84141. maxCombinedTexturesImageUnits: number;
  84142. /** Maximum texture size */
  84143. maxTextureSize: number;
  84144. /** Maximum cube texture size */
  84145. maxCubemapTextureSize: number;
  84146. /** Maximum render texture size */
  84147. maxRenderTextureSize: number;
  84148. /** Maximum number of vertex attributes */
  84149. maxVertexAttribs: number;
  84150. /** Maximum number of varyings */
  84151. maxVaryingVectors: number;
  84152. /** Maximum number of uniforms per vertex shader */
  84153. maxVertexUniformVectors: number;
  84154. /** Maximum number of uniforms per fragment shader */
  84155. maxFragmentUniformVectors: number;
  84156. /** Defines if standard derivates (dx/dy) are supported */
  84157. standardDerivatives: boolean;
  84158. /** Defines if s3tc texture compression is supported */
  84159. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  84160. /** Defines if pvrtc texture compression is supported */
  84161. pvrtc: any;
  84162. /** Defines if etc1 texture compression is supported */
  84163. etc1: any;
  84164. /** Defines if etc2 texture compression is supported */
  84165. etc2: any;
  84166. /** Defines if astc texture compression is supported */
  84167. astc: any;
  84168. /** Defines if float textures are supported */
  84169. textureFloat: boolean;
  84170. /** Defines if vertex array objects are supported */
  84171. vertexArrayObject: boolean;
  84172. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  84173. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  84174. /** Gets the maximum level of anisotropy supported */
  84175. maxAnisotropy: number;
  84176. /** Defines if instancing is supported */
  84177. instancedArrays: boolean;
  84178. /** Defines if 32 bits indices are supported */
  84179. uintIndices: boolean;
  84180. /** Defines if high precision shaders are supported */
  84181. highPrecisionShaderSupported: boolean;
  84182. /** Defines if depth reading in the fragment shader is supported */
  84183. fragmentDepthSupported: boolean;
  84184. /** Defines if float texture linear filtering is supported*/
  84185. textureFloatLinearFiltering: boolean;
  84186. /** Defines if rendering to float textures is supported */
  84187. textureFloatRender: boolean;
  84188. /** Defines if half float textures are supported*/
  84189. textureHalfFloat: boolean;
  84190. /** Defines if half float texture linear filtering is supported*/
  84191. textureHalfFloatLinearFiltering: boolean;
  84192. /** Defines if rendering to half float textures is supported */
  84193. textureHalfFloatRender: boolean;
  84194. /** Defines if textureLOD shader command is supported */
  84195. textureLOD: boolean;
  84196. /** Defines if draw buffers extension is supported */
  84197. drawBuffersExtension: boolean;
  84198. /** Defines if depth textures are supported */
  84199. depthTextureExtension: boolean;
  84200. /** Defines if float color buffer are supported */
  84201. colorBufferFloat: boolean;
  84202. /** Gets disjoint timer query extension (null if not supported) */
  84203. timerQuery: EXT_disjoint_timer_query;
  84204. /** Defines if timestamp can be used with timer query */
  84205. canUseTimestampForTimerQuery: boolean;
  84206. /** Function used to let the system compiles shaders in background */
  84207. parallelShaderCompile: {
  84208. MAX_SHADER_COMPILER_THREADS_KHR: number;
  84209. maxShaderCompilerThreadsKHR: (thread: number) => void;
  84210. COMPLETION_STATUS_KHR: number;
  84211. };
  84212. }
  84213. /** Interface defining initialization parameters for Engine class */
  84214. export interface EngineOptions extends WebGLContextAttributes {
  84215. /**
  84216. * Defines if the engine should no exceed a specified device ratio
  84217. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  84218. */
  84219. limitDeviceRatio?: number;
  84220. /**
  84221. * Defines if webvr should be enabled automatically
  84222. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84223. */
  84224. autoEnableWebVR?: boolean;
  84225. /**
  84226. * Defines if webgl2 should be turned off even if supported
  84227. * @see http://doc.babylonjs.com/features/webgl2
  84228. */
  84229. disableWebGL2Support?: boolean;
  84230. /**
  84231. * Defines if webaudio should be initialized as well
  84232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84233. */
  84234. audioEngine?: boolean;
  84235. /**
  84236. * Defines if animations should run using a deterministic lock step
  84237. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84238. */
  84239. deterministicLockstep?: boolean;
  84240. /** Defines the maximum steps to use with deterministic lock step mode */
  84241. lockstepMaxSteps?: number;
  84242. /**
  84243. * Defines that engine should ignore context lost events
  84244. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  84245. */
  84246. doNotHandleContextLost?: boolean;
  84247. /**
  84248. * Defines that engine should ignore modifying touch action attribute and style
  84249. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  84250. */
  84251. doNotHandleTouchAction?: boolean;
  84252. /**
  84253. * Defines that engine should compile shaders with high precision floats (if supported). False by default
  84254. */
  84255. useHighPrecisionFloats?: boolean;
  84256. }
  84257. /**
  84258. * Defines the interface used by display changed events
  84259. */
  84260. export interface IDisplayChangedEventArgs {
  84261. /** Gets the vrDisplay object (if any) */
  84262. vrDisplay: Nullable<any>;
  84263. /** Gets a boolean indicating if webVR is supported */
  84264. vrSupported: boolean;
  84265. }
  84266. /**
  84267. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  84268. */
  84269. export class Engine {
  84270. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  84271. static ExceptionList: ({
  84272. key: string;
  84273. capture: string;
  84274. captureConstraint: number;
  84275. targets: string[];
  84276. } | {
  84277. key: string;
  84278. capture: null;
  84279. captureConstraint: null;
  84280. targets: string[];
  84281. })[];
  84282. /** Gets the list of created engines */
  84283. static readonly Instances: Engine[];
  84284. /**
  84285. * Gets the latest created engine
  84286. */
  84287. static readonly LastCreatedEngine: Nullable<Engine>;
  84288. /**
  84289. * Gets the latest created scene
  84290. */
  84291. static readonly LastCreatedScene: Nullable<Scene>;
  84292. /**
  84293. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  84294. * @param flag defines which part of the materials must be marked as dirty
  84295. * @param predicate defines a predicate used to filter which materials should be affected
  84296. */
  84297. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  84298. /**
  84299. * Hidden
  84300. */
  84301. static _TextureLoaders: IInternalTextureLoader[];
  84302. /** Defines that alpha blending is disabled */
  84303. static readonly ALPHA_DISABLE: number;
  84304. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  84305. static readonly ALPHA_ADD: number;
  84306. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  84307. static readonly ALPHA_COMBINE: number;
  84308. /** Defines that alpha blending to DEST - SRC * DEST */
  84309. static readonly ALPHA_SUBTRACT: number;
  84310. /** Defines that alpha blending to SRC * DEST */
  84311. static readonly ALPHA_MULTIPLY: number;
  84312. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  84313. static readonly ALPHA_MAXIMIZED: number;
  84314. /** Defines that alpha blending to SRC + DEST */
  84315. static readonly ALPHA_ONEONE: number;
  84316. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  84317. static readonly ALPHA_PREMULTIPLIED: number;
  84318. /**
  84319. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  84320. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  84321. */
  84322. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  84323. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  84324. static readonly ALPHA_INTERPOLATE: number;
  84325. /**
  84326. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  84327. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  84328. */
  84329. static readonly ALPHA_SCREENMODE: number;
  84330. /** Defines that the ressource is not delayed*/
  84331. static readonly DELAYLOADSTATE_NONE: number;
  84332. /** Defines that the ressource was successfully delay loaded */
  84333. static readonly DELAYLOADSTATE_LOADED: number;
  84334. /** Defines that the ressource is currently delay loading */
  84335. static readonly DELAYLOADSTATE_LOADING: number;
  84336. /** Defines that the ressource is delayed and has not started loading */
  84337. static readonly DELAYLOADSTATE_NOTLOADED: number;
  84338. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  84339. static readonly NEVER: number;
  84340. /** 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 */
  84341. static readonly ALWAYS: number;
  84342. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  84343. static readonly LESS: number;
  84344. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  84345. static readonly EQUAL: number;
  84346. /** 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 */
  84347. static readonly LEQUAL: number;
  84348. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  84349. static readonly GREATER: number;
  84350. /** 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 */
  84351. static readonly GEQUAL: number;
  84352. /** 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 */
  84353. static readonly NOTEQUAL: number;
  84354. /** Passed to stencilOperation to specify that stencil value must be kept */
  84355. static readonly KEEP: number;
  84356. /** Passed to stencilOperation to specify that stencil value must be replaced */
  84357. static readonly REPLACE: number;
  84358. /** Passed to stencilOperation to specify that stencil value must be incremented */
  84359. static readonly INCR: number;
  84360. /** Passed to stencilOperation to specify that stencil value must be decremented */
  84361. static readonly DECR: number;
  84362. /** Passed to stencilOperation to specify that stencil value must be inverted */
  84363. static readonly INVERT: number;
  84364. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  84365. static readonly INCR_WRAP: number;
  84366. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  84367. static readonly DECR_WRAP: number;
  84368. /** Texture is not repeating outside of 0..1 UVs */
  84369. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  84370. /** Texture is repeating outside of 0..1 UVs */
  84371. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  84372. /** Texture is repeating and mirrored */
  84373. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  84374. /** ALPHA */
  84375. static readonly TEXTUREFORMAT_ALPHA: number;
  84376. /** LUMINANCE */
  84377. static readonly TEXTUREFORMAT_LUMINANCE: number;
  84378. /** LUMINANCE_ALPHA */
  84379. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  84380. /** RGB */
  84381. static readonly TEXTUREFORMAT_RGB: number;
  84382. /** RGBA */
  84383. static readonly TEXTUREFORMAT_RGBA: number;
  84384. /** RED */
  84385. static readonly TEXTUREFORMAT_RED: number;
  84386. /** RED (2nd reference) */
  84387. static readonly TEXTUREFORMAT_R: number;
  84388. /** RG */
  84389. static readonly TEXTUREFORMAT_RG: number;
  84390. /** RED_INTEGER */
  84391. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  84392. /** RED_INTEGER (2nd reference) */
  84393. static readonly TEXTUREFORMAT_R_INTEGER: number;
  84394. /** RG_INTEGER */
  84395. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  84396. /** RGB_INTEGER */
  84397. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  84398. /** RGBA_INTEGER */
  84399. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  84400. /** UNSIGNED_BYTE */
  84401. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  84402. /** UNSIGNED_BYTE (2nd reference) */
  84403. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  84404. /** FLOAT */
  84405. static readonly TEXTURETYPE_FLOAT: number;
  84406. /** HALF_FLOAT */
  84407. static readonly TEXTURETYPE_HALF_FLOAT: number;
  84408. /** BYTE */
  84409. static readonly TEXTURETYPE_BYTE: number;
  84410. /** SHORT */
  84411. static readonly TEXTURETYPE_SHORT: number;
  84412. /** UNSIGNED_SHORT */
  84413. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  84414. /** INT */
  84415. static readonly TEXTURETYPE_INT: number;
  84416. /** UNSIGNED_INT */
  84417. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  84418. /** UNSIGNED_SHORT_4_4_4_4 */
  84419. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  84420. /** UNSIGNED_SHORT_5_5_5_1 */
  84421. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  84422. /** UNSIGNED_SHORT_5_6_5 */
  84423. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  84424. /** UNSIGNED_INT_2_10_10_10_REV */
  84425. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  84426. /** UNSIGNED_INT_24_8 */
  84427. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  84428. /** UNSIGNED_INT_10F_11F_11F_REV */
  84429. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  84430. /** UNSIGNED_INT_5_9_9_9_REV */
  84431. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  84432. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  84433. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  84434. /** nearest is mag = nearest and min = nearest and mip = linear */
  84435. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  84436. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84437. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  84438. /** Trilinear is mag = linear and min = linear and mip = linear */
  84439. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  84440. /** nearest is mag = nearest and min = nearest and mip = linear */
  84441. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  84442. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84443. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  84444. /** Trilinear is mag = linear and min = linear and mip = linear */
  84445. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  84446. /** mag = nearest and min = nearest and mip = nearest */
  84447. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  84448. /** mag = nearest and min = linear and mip = nearest */
  84449. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  84450. /** mag = nearest and min = linear and mip = linear */
  84451. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  84452. /** mag = nearest and min = linear and mip = none */
  84453. static readonly TEXTURE_NEAREST_LINEAR: number;
  84454. /** mag = nearest and min = nearest and mip = none */
  84455. static readonly TEXTURE_NEAREST_NEAREST: number;
  84456. /** mag = linear and min = nearest and mip = nearest */
  84457. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  84458. /** mag = linear and min = nearest and mip = linear */
  84459. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  84460. /** mag = linear and min = linear and mip = none */
  84461. static readonly TEXTURE_LINEAR_LINEAR: number;
  84462. /** mag = linear and min = nearest and mip = none */
  84463. static readonly TEXTURE_LINEAR_NEAREST: number;
  84464. /** Explicit coordinates mode */
  84465. static readonly TEXTURE_EXPLICIT_MODE: number;
  84466. /** Spherical coordinates mode */
  84467. static readonly TEXTURE_SPHERICAL_MODE: number;
  84468. /** Planar coordinates mode */
  84469. static readonly TEXTURE_PLANAR_MODE: number;
  84470. /** Cubic coordinates mode */
  84471. static readonly TEXTURE_CUBIC_MODE: number;
  84472. /** Projection coordinates mode */
  84473. static readonly TEXTURE_PROJECTION_MODE: number;
  84474. /** Skybox coordinates mode */
  84475. static readonly TEXTURE_SKYBOX_MODE: number;
  84476. /** Inverse Cubic coordinates mode */
  84477. static readonly TEXTURE_INVCUBIC_MODE: number;
  84478. /** Equirectangular coordinates mode */
  84479. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  84480. /** Equirectangular Fixed coordinates mode */
  84481. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  84482. /** Equirectangular Fixed Mirrored coordinates mode */
  84483. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84484. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  84485. static readonly SCALEMODE_FLOOR: number;
  84486. /** Defines that texture rescaling will look for the nearest power of 2 size */
  84487. static readonly SCALEMODE_NEAREST: number;
  84488. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  84489. static readonly SCALEMODE_CEILING: number;
  84490. /**
  84491. * Returns the current version of the framework
  84492. */
  84493. static readonly Version: string;
  84494. /**
  84495. * Returns a string describing the current engine
  84496. */
  84497. readonly description: string;
  84498. /**
  84499. * Gets or sets the epsilon value used by collision engine
  84500. */
  84501. static CollisionsEpsilon: number;
  84502. /**
  84503. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84504. */
  84505. static ShadersRepository: string;
  84506. /**
  84507. * Method called to create the default loading screen.
  84508. * This can be overriden in your own app.
  84509. * @param canvas The rendering canvas element
  84510. * @returns The loading screen
  84511. */
  84512. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  84513. /**
  84514. * Method called to create the default rescale post process on each engine.
  84515. */
  84516. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  84517. /**
  84518. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  84519. */
  84520. forcePOTTextures: boolean;
  84521. /**
  84522. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  84523. */
  84524. isFullscreen: boolean;
  84525. /**
  84526. * Gets a boolean indicating if the pointer is currently locked
  84527. */
  84528. isPointerLock: boolean;
  84529. /**
  84530. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  84531. */
  84532. cullBackFaces: boolean;
  84533. /**
  84534. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  84535. */
  84536. renderEvenInBackground: boolean;
  84537. /**
  84538. * Gets or sets a boolean indicating that cache can be kept between frames
  84539. */
  84540. preventCacheWipeBetweenFrames: boolean;
  84541. /**
  84542. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  84543. **/
  84544. enableOfflineSupport: boolean;
  84545. /**
  84546. * 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)
  84547. **/
  84548. disableManifestCheck: boolean;
  84549. /**
  84550. * Gets the list of created scenes
  84551. */
  84552. scenes: Scene[];
  84553. /**
  84554. * Event raised when a new scene is created
  84555. */
  84556. onNewSceneAddedObservable: Observable<Scene>;
  84557. /**
  84558. * Gets the list of created postprocesses
  84559. */
  84560. postProcesses: PostProcess[];
  84561. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  84562. validateShaderPrograms: boolean;
  84563. /**
  84564. * Observable event triggered each time the rendering canvas is resized
  84565. */
  84566. onResizeObservable: Observable<Engine>;
  84567. /**
  84568. * Observable event triggered each time the canvas loses focus
  84569. */
  84570. onCanvasBlurObservable: Observable<Engine>;
  84571. /**
  84572. * Observable event triggered each time the canvas gains focus
  84573. */
  84574. onCanvasFocusObservable: Observable<Engine>;
  84575. /**
  84576. * Observable event triggered each time the canvas receives pointerout event
  84577. */
  84578. onCanvasPointerOutObservable: Observable<PointerEvent>;
  84579. /**
  84580. * Observable event triggered before each texture is initialized
  84581. */
  84582. onBeforeTextureInitObservable: Observable<Texture>;
  84583. private _vrDisplay;
  84584. private _vrSupported;
  84585. private _oldSize;
  84586. private _oldHardwareScaleFactor;
  84587. private _vrExclusivePointerMode;
  84588. private _webVRInitPromise;
  84589. /**
  84590. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84591. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84592. */
  84593. readonly isInVRExclusivePointerMode: boolean;
  84594. /**
  84595. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84596. */
  84597. disableUniformBuffers: boolean;
  84598. /** @hidden */
  84599. _uniformBuffers: UniformBuffer[];
  84600. /**
  84601. * Gets a boolean indicating that the engine supports uniform buffers
  84602. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84603. */
  84604. readonly supportsUniformBuffers: boolean;
  84605. /**
  84606. * Observable raised when the engine begins a new frame
  84607. */
  84608. onBeginFrameObservable: Observable<Engine>;
  84609. /**
  84610. * If set, will be used to request the next animation frame for the render loop
  84611. */
  84612. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84613. /**
  84614. * Observable raised when the engine ends the current frame
  84615. */
  84616. onEndFrameObservable: Observable<Engine>;
  84617. /**
  84618. * Observable raised when the engine is about to compile a shader
  84619. */
  84620. onBeforeShaderCompilationObservable: Observable<Engine>;
  84621. /**
  84622. * Observable raised when the engine has jsut compiled a shader
  84623. */
  84624. onAfterShaderCompilationObservable: Observable<Engine>;
  84625. /** @hidden */
  84626. _gl: WebGLRenderingContext;
  84627. private _renderingCanvas;
  84628. private _windowIsBackground;
  84629. private _webGLVersion;
  84630. private _highPrecisionShadersAllowed;
  84631. /** @hidden */
  84632. readonly _shouldUseHighPrecisionShader: boolean;
  84633. /**
  84634. * Gets a boolean indicating that only power of 2 textures are supported
  84635. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84636. */
  84637. readonly needPOTTextures: boolean;
  84638. /** @hidden */
  84639. _badOS: boolean;
  84640. /** @hidden */
  84641. _badDesktopOS: boolean;
  84642. /**
  84643. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84644. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84645. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84646. */
  84647. disableTextureBindingOptimization: boolean;
  84648. /**
  84649. * Gets the audio engine
  84650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84651. * @ignorenaming
  84652. */
  84653. static audioEngine: IAudioEngine;
  84654. /**
  84655. * Default AudioEngine factory responsible of creating the Audio Engine.
  84656. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84657. */
  84658. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84659. /**
  84660. * Default offline support factory responsible of creating a tool used to store data locally.
  84661. * By default, this will create a Database object if the workload has been embedded.
  84662. */
  84663. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84664. private _onFocus;
  84665. private _onBlur;
  84666. private _onCanvasPointerOut;
  84667. private _onCanvasBlur;
  84668. private _onCanvasFocus;
  84669. private _onFullscreenChange;
  84670. private _onPointerLockChange;
  84671. private _onVRDisplayPointerRestricted;
  84672. private _onVRDisplayPointerUnrestricted;
  84673. private _onVrDisplayConnect;
  84674. private _onVrDisplayDisconnect;
  84675. private _onVrDisplayPresentChange;
  84676. /**
  84677. * Observable signaled when VR display mode changes
  84678. */
  84679. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84680. /**
  84681. * Observable signaled when VR request present is complete
  84682. */
  84683. onVRRequestPresentComplete: Observable<boolean>;
  84684. /**
  84685. * Observable signaled when VR request present starts
  84686. */
  84687. onVRRequestPresentStart: Observable<Engine>;
  84688. private _hardwareScalingLevel;
  84689. /** @hidden */
  84690. protected _caps: EngineCapabilities;
  84691. private _pointerLockRequested;
  84692. private _isStencilEnable;
  84693. private _colorWrite;
  84694. private _loadingScreen;
  84695. /** @hidden */
  84696. _drawCalls: PerfCounter;
  84697. /** @hidden */
  84698. _textureCollisions: PerfCounter;
  84699. private _glVersion;
  84700. private _glRenderer;
  84701. private _glVendor;
  84702. private _videoTextureSupported;
  84703. private _renderingQueueLaunched;
  84704. private _activeRenderLoops;
  84705. private _deterministicLockstep;
  84706. private _lockstepMaxSteps;
  84707. /**
  84708. * Observable signaled when a context lost event is raised
  84709. */
  84710. onContextLostObservable: Observable<Engine>;
  84711. /**
  84712. * Observable signaled when a context restored event is raised
  84713. */
  84714. onContextRestoredObservable: Observable<Engine>;
  84715. private _onContextLost;
  84716. private _onContextRestored;
  84717. private _contextWasLost;
  84718. private _doNotHandleContextLost;
  84719. /**
  84720. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84721. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84722. */
  84723. doNotHandleContextLost: boolean;
  84724. private _performanceMonitor;
  84725. private _fps;
  84726. private _deltaTime;
  84727. /**
  84728. * Turn this value on if you want to pause FPS computation when in background
  84729. */
  84730. disablePerformanceMonitorInBackground: boolean;
  84731. /**
  84732. * Gets the performance monitor attached to this engine
  84733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84734. */
  84735. readonly performanceMonitor: PerformanceMonitor;
  84736. /** @hidden */
  84737. protected _depthCullingState: _DepthCullingState;
  84738. /** @hidden */
  84739. protected _stencilState: _StencilState;
  84740. /** @hidden */
  84741. protected _alphaState: _AlphaState;
  84742. /** @hidden */
  84743. protected _alphaMode: number;
  84744. protected _internalTexturesCache: InternalTexture[];
  84745. /** @hidden */
  84746. protected _activeChannel: number;
  84747. private _currentTextureChannel;
  84748. /** @hidden */
  84749. protected _boundTexturesCache: {
  84750. [key: string]: Nullable<InternalTexture>;
  84751. };
  84752. /** @hidden */
  84753. protected _currentEffect: Nullable<Effect>;
  84754. /** @hidden */
  84755. protected _currentProgram: Nullable<WebGLProgram>;
  84756. private _compiledEffects;
  84757. private _vertexAttribArraysEnabled;
  84758. /** @hidden */
  84759. protected _cachedViewport: Nullable<Viewport>;
  84760. private _cachedVertexArrayObject;
  84761. /** @hidden */
  84762. protected _cachedVertexBuffers: any;
  84763. /** @hidden */
  84764. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84765. /** @hidden */
  84766. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84767. /** @hidden */
  84768. protected _currentRenderTarget: Nullable<InternalTexture>;
  84769. private _uintIndicesCurrentlySet;
  84770. private _currentBoundBuffer;
  84771. /** @hidden */
  84772. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84773. private _currentBufferPointers;
  84774. private _currentInstanceLocations;
  84775. private _currentInstanceBuffers;
  84776. private _textureUnits;
  84777. private _firstBoundInternalTextureTracker;
  84778. private _lastBoundInternalTextureTracker;
  84779. private _workingCanvas;
  84780. private _workingContext;
  84781. private _rescalePostProcess;
  84782. private _dummyFramebuffer;
  84783. private _externalData;
  84784. private _bindedRenderFunction;
  84785. private _vaoRecordInProgress;
  84786. private _mustWipeVertexAttributes;
  84787. private _emptyTexture;
  84788. private _emptyCubeTexture;
  84789. private _emptyTexture3D;
  84790. /** @hidden */
  84791. _frameHandler: number;
  84792. private _nextFreeTextureSlots;
  84793. private _maxSimultaneousTextures;
  84794. private _activeRequests;
  84795. private _texturesSupported;
  84796. private _textureFormatInUse;
  84797. /**
  84798. * Gets the list of texture formats supported
  84799. */
  84800. readonly texturesSupported: Array<string>;
  84801. /**
  84802. * Gets the list of texture formats in use
  84803. */
  84804. readonly textureFormatInUse: Nullable<string>;
  84805. /**
  84806. * Gets the current viewport
  84807. */
  84808. readonly currentViewport: Nullable<Viewport>;
  84809. /**
  84810. * Gets the default empty texture
  84811. */
  84812. readonly emptyTexture: InternalTexture;
  84813. /**
  84814. * Gets the default empty 3D texture
  84815. */
  84816. readonly emptyTexture3D: InternalTexture;
  84817. /**
  84818. * Gets the default empty cube texture
  84819. */
  84820. readonly emptyCubeTexture: InternalTexture;
  84821. /**
  84822. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84823. */
  84824. readonly premultipliedAlpha: boolean;
  84825. /**
  84826. * Creates a new engine
  84827. * @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
  84828. * @param antialias defines enable antialiasing (default: false)
  84829. * @param options defines further options to be sent to the getContext() function
  84830. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84831. */
  84832. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84833. private _disableTouchAction;
  84834. private _rebuildInternalTextures;
  84835. private _rebuildEffects;
  84836. /**
  84837. * Gets a boolean indicating if all created effects are ready
  84838. * @returns true if all effects are ready
  84839. */
  84840. areAllEffectsReady(): boolean;
  84841. private _rebuildBuffers;
  84842. private _initGLContext;
  84843. /**
  84844. * Gets version of the current webGL context
  84845. */
  84846. readonly webGLVersion: number;
  84847. /**
  84848. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84849. */
  84850. readonly isStencilEnable: boolean;
  84851. private _prepareWorkingCanvas;
  84852. /**
  84853. * Reset the texture cache to empty state
  84854. */
  84855. resetTextureCache(): void;
  84856. /**
  84857. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84858. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84859. * @returns true if engine is in deterministic lock step mode
  84860. */
  84861. isDeterministicLockStep(): boolean;
  84862. /**
  84863. * Gets the max steps when engine is running in deterministic lock step
  84864. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84865. * @returns the max steps
  84866. */
  84867. getLockstepMaxSteps(): number;
  84868. /**
  84869. * Gets an object containing information about the current webGL context
  84870. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84871. */
  84872. getGlInfo(): {
  84873. vendor: string;
  84874. renderer: string;
  84875. version: string;
  84876. };
  84877. /**
  84878. * Gets current aspect ratio
  84879. * @param camera defines the camera to use to get the aspect ratio
  84880. * @param useScreen defines if screen size must be used (or the current render target if any)
  84881. * @returns a number defining the aspect ratio
  84882. */
  84883. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84884. /**
  84885. * Gets current screen aspect ratio
  84886. * @returns a number defining the aspect ratio
  84887. */
  84888. getScreenAspectRatio(): number;
  84889. /**
  84890. * Gets the current render width
  84891. * @param useScreen defines if screen size must be used (or the current render target if any)
  84892. * @returns a number defining the current render width
  84893. */
  84894. getRenderWidth(useScreen?: boolean): number;
  84895. /**
  84896. * Gets the current render height
  84897. * @param useScreen defines if screen size must be used (or the current render target if any)
  84898. * @returns a number defining the current render height
  84899. */
  84900. getRenderHeight(useScreen?: boolean): number;
  84901. /**
  84902. * Gets the HTML canvas attached with the current webGL context
  84903. * @returns a HTML canvas
  84904. */
  84905. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84906. /**
  84907. * Gets the client rect of the HTML canvas attached with the current webGL context
  84908. * @returns a client rectanglee
  84909. */
  84910. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84911. /**
  84912. * Defines the hardware scaling level.
  84913. * By default the hardware scaling level is computed from the window device ratio.
  84914. * 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.
  84915. * @param level defines the level to use
  84916. */
  84917. setHardwareScalingLevel(level: number): void;
  84918. /**
  84919. * Gets the current hardware scaling level.
  84920. * By default the hardware scaling level is computed from the window device ratio.
  84921. * 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.
  84922. * @returns a number indicating the current hardware scaling level
  84923. */
  84924. getHardwareScalingLevel(): number;
  84925. /**
  84926. * Gets the list of loaded textures
  84927. * @returns an array containing all loaded textures
  84928. */
  84929. getLoadedTexturesCache(): InternalTexture[];
  84930. /**
  84931. * Gets the object containing all engine capabilities
  84932. * @returns the EngineCapabilities object
  84933. */
  84934. getCaps(): EngineCapabilities;
  84935. /**
  84936. * Gets the current depth function
  84937. * @returns a number defining the depth function
  84938. */
  84939. getDepthFunction(): Nullable<number>;
  84940. /**
  84941. * Sets the current depth function
  84942. * @param depthFunc defines the function to use
  84943. */
  84944. setDepthFunction(depthFunc: number): void;
  84945. /**
  84946. * Sets the current depth function to GREATER
  84947. */
  84948. setDepthFunctionToGreater(): void;
  84949. /**
  84950. * Sets the current depth function to GEQUAL
  84951. */
  84952. setDepthFunctionToGreaterOrEqual(): void;
  84953. /**
  84954. * Sets the current depth function to LESS
  84955. */
  84956. setDepthFunctionToLess(): void;
  84957. /**
  84958. * Sets the current depth function to LEQUAL
  84959. */
  84960. setDepthFunctionToLessOrEqual(): void;
  84961. /**
  84962. * Gets a boolean indicating if stencil buffer is enabled
  84963. * @returns the current stencil buffer state
  84964. */
  84965. getStencilBuffer(): boolean;
  84966. /**
  84967. * Enable or disable the stencil buffer
  84968. * @param enable defines if the stencil buffer must be enabled or disabled
  84969. */
  84970. setStencilBuffer(enable: boolean): void;
  84971. /**
  84972. * Gets the current stencil mask
  84973. * @returns a number defining the new stencil mask to use
  84974. */
  84975. getStencilMask(): number;
  84976. /**
  84977. * Sets the current stencil mask
  84978. * @param mask defines the new stencil mask to use
  84979. */
  84980. setStencilMask(mask: number): void;
  84981. /**
  84982. * Gets the current stencil function
  84983. * @returns a number defining the stencil function to use
  84984. */
  84985. getStencilFunction(): number;
  84986. /**
  84987. * Gets the current stencil reference value
  84988. * @returns a number defining the stencil reference value to use
  84989. */
  84990. getStencilFunctionReference(): number;
  84991. /**
  84992. * Gets the current stencil mask
  84993. * @returns a number defining the stencil mask to use
  84994. */
  84995. getStencilFunctionMask(): number;
  84996. /**
  84997. * Sets the current stencil function
  84998. * @param stencilFunc defines the new stencil function to use
  84999. */
  85000. setStencilFunction(stencilFunc: number): void;
  85001. /**
  85002. * Sets the current stencil reference
  85003. * @param reference defines the new stencil reference to use
  85004. */
  85005. setStencilFunctionReference(reference: number): void;
  85006. /**
  85007. * Sets the current stencil mask
  85008. * @param mask defines the new stencil mask to use
  85009. */
  85010. setStencilFunctionMask(mask: number): void;
  85011. /**
  85012. * Gets the current stencil operation when stencil fails
  85013. * @returns a number defining stencil operation to use when stencil fails
  85014. */
  85015. getStencilOperationFail(): number;
  85016. /**
  85017. * Gets the current stencil operation when depth fails
  85018. * @returns a number defining stencil operation to use when depth fails
  85019. */
  85020. getStencilOperationDepthFail(): number;
  85021. /**
  85022. * Gets the current stencil operation when stencil passes
  85023. * @returns a number defining stencil operation to use when stencil passes
  85024. */
  85025. getStencilOperationPass(): number;
  85026. /**
  85027. * Sets the stencil operation to use when stencil fails
  85028. * @param operation defines the stencil operation to use when stencil fails
  85029. */
  85030. setStencilOperationFail(operation: number): void;
  85031. /**
  85032. * Sets the stencil operation to use when depth fails
  85033. * @param operation defines the stencil operation to use when depth fails
  85034. */
  85035. setStencilOperationDepthFail(operation: number): void;
  85036. /**
  85037. * Sets the stencil operation to use when stencil passes
  85038. * @param operation defines the stencil operation to use when stencil passes
  85039. */
  85040. setStencilOperationPass(operation: number): void;
  85041. /**
  85042. * Sets a boolean indicating if the dithering state is enabled or disabled
  85043. * @param value defines the dithering state
  85044. */
  85045. setDitheringState(value: boolean): void;
  85046. /**
  85047. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  85048. * @param value defines the rasterizer state
  85049. */
  85050. setRasterizerState(value: boolean): void;
  85051. /**
  85052. * stop executing a render loop function and remove it from the execution array
  85053. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  85054. */
  85055. stopRenderLoop(renderFunction?: () => void): void;
  85056. /** @hidden */
  85057. _renderLoop(): void;
  85058. /**
  85059. * Register and execute a render loop. The engine can have more than one render function
  85060. * @param renderFunction defines the function to continuously execute
  85061. */
  85062. runRenderLoop(renderFunction: () => void): void;
  85063. /**
  85064. * Toggle full screen mode
  85065. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85066. */
  85067. switchFullscreen(requestPointerLock: boolean): void;
  85068. /**
  85069. * Enters full screen mode
  85070. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85071. */
  85072. enterFullscreen(requestPointerLock: boolean): void;
  85073. /**
  85074. * Exits full screen mode
  85075. */
  85076. exitFullscreen(): void;
  85077. /**
  85078. * Clear the current render buffer or the current render target (if any is set up)
  85079. * @param color defines the color to use
  85080. * @param backBuffer defines if the back buffer must be cleared
  85081. * @param depth defines if the depth buffer must be cleared
  85082. * @param stencil defines if the stencil buffer must be cleared
  85083. */
  85084. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  85085. /**
  85086. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  85087. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85088. * @param y defines the y-coordinate of the corner of the clear rectangle
  85089. * @param width defines the width of the clear rectangle
  85090. * @param height defines the height of the clear rectangle
  85091. * @param clearColor defines the clear color
  85092. */
  85093. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  85094. /**
  85095. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  85096. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85097. * @param y defines the y-coordinate of the corner of the clear rectangle
  85098. * @param width defines the width of the clear rectangle
  85099. * @param height defines the height of the clear rectangle
  85100. */
  85101. enableScissor(x: number, y: number, width: number, height: number): void;
  85102. /**
  85103. * Disable previously set scissor test rectangle
  85104. */
  85105. disableScissor(): void;
  85106. private _viewportCached;
  85107. /** @hidden */
  85108. _viewport(x: number, y: number, width: number, height: number): void;
  85109. /**
  85110. * Set the WebGL's viewport
  85111. * @param viewport defines the viewport element to be used
  85112. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  85113. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  85114. */
  85115. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  85116. /**
  85117. * Directly set the WebGL Viewport
  85118. * @param x defines the x coordinate of the viewport (in screen space)
  85119. * @param y defines the y coordinate of the viewport (in screen space)
  85120. * @param width defines the width of the viewport (in screen space)
  85121. * @param height defines the height of the viewport (in screen space)
  85122. * @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
  85123. */
  85124. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  85125. /**
  85126. * Begin a new frame
  85127. */
  85128. beginFrame(): void;
  85129. /**
  85130. * Enf the current frame
  85131. */
  85132. endFrame(): void;
  85133. /**
  85134. * Resize the view according to the canvas' size
  85135. */
  85136. resize(): void;
  85137. /**
  85138. * Force a specific size of the canvas
  85139. * @param width defines the new canvas' width
  85140. * @param height defines the new canvas' height
  85141. */
  85142. setSize(width: number, height: number): void;
  85143. /**
  85144. * Gets a boolean indicating if a webVR device was detected
  85145. * @returns true if a webVR device was detected
  85146. */
  85147. isVRDevicePresent(): boolean;
  85148. /**
  85149. * Gets the current webVR device
  85150. * @returns the current webVR device (or null)
  85151. */
  85152. getVRDevice(): any;
  85153. /**
  85154. * Initializes a webVR display and starts listening to display change events
  85155. * The onVRDisplayChangedObservable will be notified upon these changes
  85156. * @returns The onVRDisplayChangedObservable
  85157. */
  85158. initWebVR(): Observable<IDisplayChangedEventArgs>;
  85159. /**
  85160. * Initializes a webVR display and starts listening to display change events
  85161. * The onVRDisplayChangedObservable will be notified upon these changes
  85162. * @returns A promise containing a VRDisplay and if vr is supported
  85163. */
  85164. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85165. /**
  85166. * Call this function to switch to webVR mode
  85167. * Will do nothing if webVR is not supported or if there is no webVR device
  85168. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85169. */
  85170. enableVR(): void;
  85171. /**
  85172. * Call this function to leave webVR mode
  85173. * Will do nothing if webVR is not supported or if there is no webVR device
  85174. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85175. */
  85176. disableVR(): void;
  85177. private _onVRFullScreenTriggered;
  85178. private _getVRDisplaysAsync;
  85179. /**
  85180. * Binds the frame buffer to the specified texture.
  85181. * @param texture The texture to render to or null for the default canvas
  85182. * @param faceIndex The face of the texture to render to in case of cube texture
  85183. * @param requiredWidth The width of the target to render to
  85184. * @param requiredHeight The height of the target to render to
  85185. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  85186. * @param depthStencilTexture The depth stencil texture to use to render
  85187. * @param lodLevel defines le lod level to bind to the frame buffer
  85188. */
  85189. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  85190. private bindUnboundFramebuffer;
  85191. /**
  85192. * Unbind the current render target texture from the webGL context
  85193. * @param texture defines the render target texture to unbind
  85194. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85195. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85196. */
  85197. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85198. /**
  85199. * Unbind a list of render target textures from the webGL context
  85200. * This is used only when drawBuffer extension or webGL2 are active
  85201. * @param textures defines the render target textures to unbind
  85202. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85203. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85204. */
  85205. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85206. /**
  85207. * Force the mipmap generation for the given render target texture
  85208. * @param texture defines the render target texture to use
  85209. */
  85210. generateMipMapsForCubemap(texture: InternalTexture): void;
  85211. /**
  85212. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  85213. */
  85214. flushFramebuffer(): void;
  85215. /**
  85216. * Unbind the current render target and bind the default framebuffer
  85217. */
  85218. restoreDefaultFramebuffer(): void;
  85219. /**
  85220. * Create an uniform buffer
  85221. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85222. * @param elements defines the content of the uniform buffer
  85223. * @returns the webGL uniform buffer
  85224. */
  85225. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  85226. /**
  85227. * Create a dynamic uniform buffer
  85228. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85229. * @param elements defines the content of the uniform buffer
  85230. * @returns the webGL uniform buffer
  85231. */
  85232. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  85233. /**
  85234. * Update an existing uniform buffer
  85235. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85236. * @param uniformBuffer defines the target uniform buffer
  85237. * @param elements defines the content to update
  85238. * @param offset defines the offset in the uniform buffer where update should start
  85239. * @param count defines the size of the data to update
  85240. */
  85241. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85242. private _resetVertexBufferBinding;
  85243. /**
  85244. * Creates a vertex buffer
  85245. * @param data the data for the vertex buffer
  85246. * @returns the new WebGL static buffer
  85247. */
  85248. createVertexBuffer(data: DataArray): WebGLBuffer;
  85249. /**
  85250. * Creates a dynamic vertex buffer
  85251. * @param data the data for the dynamic vertex buffer
  85252. * @returns the new WebGL dynamic buffer
  85253. */
  85254. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  85255. /**
  85256. * Update a dynamic index buffer
  85257. * @param indexBuffer defines the target index buffer
  85258. * @param indices defines the data to update
  85259. * @param offset defines the offset in the target index buffer where update should start
  85260. */
  85261. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  85262. /**
  85263. * Updates a dynamic vertex buffer.
  85264. * @param vertexBuffer the vertex buffer to update
  85265. * @param data the data used to update the vertex buffer
  85266. * @param byteOffset the byte offset of the data
  85267. * @param byteLength the byte length of the data
  85268. */
  85269. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  85270. private _resetIndexBufferBinding;
  85271. /**
  85272. * Creates a new index buffer
  85273. * @param indices defines the content of the index buffer
  85274. * @param updatable defines if the index buffer must be updatable
  85275. * @returns a new webGL buffer
  85276. */
  85277. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  85278. /**
  85279. * Bind a webGL buffer to the webGL context
  85280. * @param buffer defines the buffer to bind
  85281. */
  85282. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  85283. /**
  85284. * Bind an uniform buffer to the current webGL context
  85285. * @param buffer defines the buffer to bind
  85286. */
  85287. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  85288. /**
  85289. * Bind a buffer to the current webGL context at a given location
  85290. * @param buffer defines the buffer to bind
  85291. * @param location defines the index where to bind the buffer
  85292. */
  85293. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  85294. /**
  85295. * Bind a specific block at a given index in a specific shader program
  85296. * @param shaderProgram defines the shader program
  85297. * @param blockName defines the block name
  85298. * @param index defines the index where to bind the block
  85299. */
  85300. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  85301. private bindIndexBuffer;
  85302. private bindBuffer;
  85303. /**
  85304. * update the bound buffer with the given data
  85305. * @param data defines the data to update
  85306. */
  85307. updateArrayBuffer(data: Float32Array): void;
  85308. private _vertexAttribPointer;
  85309. private _bindIndexBufferWithCache;
  85310. private _bindVertexBuffersAttributes;
  85311. /**
  85312. * Records a vertex array object
  85313. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  85314. * @param vertexBuffers defines the list of vertex buffers to store
  85315. * @param indexBuffer defines the index buffer to store
  85316. * @param effect defines the effect to store
  85317. * @returns the new vertex array object
  85318. */
  85319. recordVertexArrayObject(vertexBuffers: {
  85320. [key: string]: VertexBuffer;
  85321. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  85322. /**
  85323. * Bind a specific vertex array object
  85324. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  85325. * @param vertexArrayObject defines the vertex array object to bind
  85326. * @param indexBuffer defines the index buffer to bind
  85327. */
  85328. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  85329. /**
  85330. * Bind webGl buffers directly to the webGL context
  85331. * @param vertexBuffer defines the vertex buffer to bind
  85332. * @param indexBuffer defines the index buffer to bind
  85333. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  85334. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  85335. * @param effect defines the effect associated with the vertex buffer
  85336. */
  85337. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  85338. private _unbindVertexArrayObject;
  85339. /**
  85340. * Bind a list of vertex buffers to the webGL context
  85341. * @param vertexBuffers defines the list of vertex buffers to bind
  85342. * @param indexBuffer defines the index buffer to bind
  85343. * @param effect defines the effect associated with the vertex buffers
  85344. */
  85345. bindBuffers(vertexBuffers: {
  85346. [key: string]: Nullable<VertexBuffer>;
  85347. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  85348. /**
  85349. * Unbind all instance attributes
  85350. */
  85351. unbindInstanceAttributes(): void;
  85352. /**
  85353. * Release and free the memory of a vertex array object
  85354. * @param vao defines the vertex array object to delete
  85355. */
  85356. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  85357. /** @hidden */
  85358. _releaseBuffer(buffer: WebGLBuffer): boolean;
  85359. /**
  85360. * Creates a webGL buffer to use with instanciation
  85361. * @param capacity defines the size of the buffer
  85362. * @returns the webGL buffer
  85363. */
  85364. createInstancesBuffer(capacity: number): WebGLBuffer;
  85365. /**
  85366. * Delete a webGL buffer used with instanciation
  85367. * @param buffer defines the webGL buffer to delete
  85368. */
  85369. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  85370. /**
  85371. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  85372. * @param instancesBuffer defines the webGL buffer to update and bind
  85373. * @param data defines the data to store in the buffer
  85374. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  85375. */
  85376. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  85377. /**
  85378. * Apply all cached states (depth, culling, stencil and alpha)
  85379. */
  85380. applyStates(): void;
  85381. /**
  85382. * Send a draw order
  85383. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85384. * @param indexStart defines the starting index
  85385. * @param indexCount defines the number of index to draw
  85386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85387. */
  85388. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  85389. /**
  85390. * Draw a list of points
  85391. * @param verticesStart defines the index of first vertex to draw
  85392. * @param verticesCount defines the count of vertices to draw
  85393. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85394. */
  85395. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85396. /**
  85397. * Draw a list of unindexed primitives
  85398. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85399. * @param verticesStart defines the index of first vertex to draw
  85400. * @param verticesCount defines the count of vertices to draw
  85401. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85402. */
  85403. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85404. /**
  85405. * Draw a list of indexed primitives
  85406. * @param fillMode defines the primitive to use
  85407. * @param indexStart defines the starting index
  85408. * @param indexCount defines the number of index to draw
  85409. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85410. */
  85411. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  85412. /**
  85413. * Draw a list of unindexed primitives
  85414. * @param fillMode defines the primitive to use
  85415. * @param verticesStart defines the index of first vertex to draw
  85416. * @param verticesCount defines the count of vertices to draw
  85417. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85418. */
  85419. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85420. private _drawMode;
  85421. /** @hidden */
  85422. _releaseEffect(effect: Effect): void;
  85423. /** @hidden */
  85424. _deleteProgram(program: WebGLProgram): void;
  85425. /**
  85426. * Create a new effect (used to store vertex/fragment shaders)
  85427. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  85428. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  85429. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  85430. * @param samplers defines an array of string used to represent textures
  85431. * @param defines defines the string containing the defines to use to compile the shaders
  85432. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  85433. * @param onCompiled defines a function to call when the effect creation is successful
  85434. * @param onError defines a function to call when the effect creation has failed
  85435. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  85436. * @returns the new Effect
  85437. */
  85438. 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;
  85439. private _compileShader;
  85440. private _compileRawShader;
  85441. /**
  85442. * Directly creates a webGL program
  85443. * @param vertexCode defines the vertex shader code to use
  85444. * @param fragmentCode defines the fragment shader code to use
  85445. * @param context defines the webGL context to use (if not set, the current one will be used)
  85446. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85447. * @returns the new webGL program
  85448. */
  85449. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85450. /**
  85451. * Creates a webGL program
  85452. * @param vertexCode defines the vertex shader code to use
  85453. * @param fragmentCode defines the fragment shader code to use
  85454. * @param defines defines the string containing the defines to use to compile the shaders
  85455. * @param context defines the webGL context to use (if not set, the current one will be used)
  85456. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85457. * @returns the new webGL program
  85458. */
  85459. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85460. private _createShaderProgram;
  85461. private _finalizeProgram;
  85462. /** @hidden */
  85463. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  85464. /** @hidden */
  85465. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  85466. /**
  85467. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  85468. * @param shaderProgram defines the webGL program to use
  85469. * @param uniformsNames defines the list of uniform names
  85470. * @returns an array of webGL uniform locations
  85471. */
  85472. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  85473. /**
  85474. * Gets the lsit of active attributes for a given webGL program
  85475. * @param shaderProgram defines the webGL program to use
  85476. * @param attributesNames defines the list of attribute names to get
  85477. * @returns an array of indices indicating the offset of each attribute
  85478. */
  85479. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  85480. /**
  85481. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  85482. * @param effect defines the effect to activate
  85483. */
  85484. enableEffect(effect: Nullable<Effect>): void;
  85485. /**
  85486. * Set the value of an uniform to an array of int32
  85487. * @param uniform defines the webGL uniform location where to store the value
  85488. * @param array defines the array of int32 to store
  85489. */
  85490. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85491. /**
  85492. * Set the value of an uniform to an array of int32 (stored as vec2)
  85493. * @param uniform defines the webGL uniform location where to store the value
  85494. * @param array defines the array of int32 to store
  85495. */
  85496. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85497. /**
  85498. * Set the value of an uniform to an array of int32 (stored as vec3)
  85499. * @param uniform defines the webGL uniform location where to store the value
  85500. * @param array defines the array of int32 to store
  85501. */
  85502. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85503. /**
  85504. * Set the value of an uniform to an array of int32 (stored as vec4)
  85505. * @param uniform defines the webGL uniform location where to store the value
  85506. * @param array defines the array of int32 to store
  85507. */
  85508. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85509. /**
  85510. * Set the value of an uniform to an array of float32
  85511. * @param uniform defines the webGL uniform location where to store the value
  85512. * @param array defines the array of float32 to store
  85513. */
  85514. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85515. /**
  85516. * Set the value of an uniform to an array of float32 (stored as vec2)
  85517. * @param uniform defines the webGL uniform location where to store the value
  85518. * @param array defines the array of float32 to store
  85519. */
  85520. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85521. /**
  85522. * Set the value of an uniform to an array of float32 (stored as vec3)
  85523. * @param uniform defines the webGL uniform location where to store the value
  85524. * @param array defines the array of float32 to store
  85525. */
  85526. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85527. /**
  85528. * Set the value of an uniform to an array of float32 (stored as vec4)
  85529. * @param uniform defines the webGL uniform location where to store the value
  85530. * @param array defines the array of float32 to store
  85531. */
  85532. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85533. /**
  85534. * Set the value of an uniform to an array of number
  85535. * @param uniform defines the webGL uniform location where to store the value
  85536. * @param array defines the array of number to store
  85537. */
  85538. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85539. /**
  85540. * Set the value of an uniform to an array of number (stored as vec2)
  85541. * @param uniform defines the webGL uniform location where to store the value
  85542. * @param array defines the array of number to store
  85543. */
  85544. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85545. /**
  85546. * Set the value of an uniform to an array of number (stored as vec3)
  85547. * @param uniform defines the webGL uniform location where to store the value
  85548. * @param array defines the array of number to store
  85549. */
  85550. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85551. /**
  85552. * Set the value of an uniform to an array of number (stored as vec4)
  85553. * @param uniform defines the webGL uniform location where to store the value
  85554. * @param array defines the array of number to store
  85555. */
  85556. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85557. /**
  85558. * Set the value of an uniform to an array of float32 (stored as matrices)
  85559. * @param uniform defines the webGL uniform location where to store the value
  85560. * @param matrices defines the array of float32 to store
  85561. */
  85562. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  85563. /**
  85564. * Set the value of an uniform to a matrix
  85565. * @param uniform defines the webGL uniform location where to store the value
  85566. * @param matrix defines the matrix to store
  85567. */
  85568. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  85569. /**
  85570. * Set the value of an uniform to a matrix (3x3)
  85571. * @param uniform defines the webGL uniform location where to store the value
  85572. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  85573. */
  85574. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85575. /**
  85576. * Set the value of an uniform to a matrix (2x2)
  85577. * @param uniform defines the webGL uniform location where to store the value
  85578. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  85579. */
  85580. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85581. /**
  85582. * Set the value of an uniform to a number (int)
  85583. * @param uniform defines the webGL uniform location where to store the value
  85584. * @param value defines the int number to store
  85585. */
  85586. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85587. /**
  85588. * Set the value of an uniform to a number (float)
  85589. * @param uniform defines the webGL uniform location where to store the value
  85590. * @param value defines the float number to store
  85591. */
  85592. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85593. /**
  85594. * Set the value of an uniform to a vec2
  85595. * @param uniform defines the webGL uniform location where to store the value
  85596. * @param x defines the 1st component of the value
  85597. * @param y defines the 2nd component of the value
  85598. */
  85599. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85600. /**
  85601. * Set the value of an uniform to a vec3
  85602. * @param uniform defines the webGL uniform location where to store the value
  85603. * @param x defines the 1st component of the value
  85604. * @param y defines the 2nd component of the value
  85605. * @param z defines the 3rd component of the value
  85606. */
  85607. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85608. /**
  85609. * Set the value of an uniform to a boolean
  85610. * @param uniform defines the webGL uniform location where to store the value
  85611. * @param bool defines the boolean to store
  85612. */
  85613. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85614. /**
  85615. * Set the value of an uniform to a vec4
  85616. * @param uniform defines the webGL uniform location where to store the value
  85617. * @param x defines the 1st component of the value
  85618. * @param y defines the 2nd component of the value
  85619. * @param z defines the 3rd component of the value
  85620. * @param w defines the 4th component of the value
  85621. */
  85622. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85623. /**
  85624. * Set the value of an uniform to a Color3
  85625. * @param uniform defines the webGL uniform location where to store the value
  85626. * @param color3 defines the color to store
  85627. */
  85628. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85629. /**
  85630. * Set the value of an uniform to a Color3 and an alpha value
  85631. * @param uniform defines the webGL uniform location where to store the value
  85632. * @param color3 defines the color to store
  85633. * @param alpha defines the alpha component to store
  85634. */
  85635. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85636. /**
  85637. * Sets a Color4 on a uniform variable
  85638. * @param uniform defines the uniform location
  85639. * @param color4 defines the value to be set
  85640. */
  85641. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85642. /**
  85643. * Set various states to the webGL context
  85644. * @param culling defines backface culling state
  85645. * @param zOffset defines the value to apply to zOffset (0 by default)
  85646. * @param force defines if states must be applied even if cache is up to date
  85647. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85648. */
  85649. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85650. /**
  85651. * Set the z offset to apply to current rendering
  85652. * @param value defines the offset to apply
  85653. */
  85654. setZOffset(value: number): void;
  85655. /**
  85656. * Gets the current value of the zOffset
  85657. * @returns the current zOffset state
  85658. */
  85659. getZOffset(): number;
  85660. /**
  85661. * Enable or disable depth buffering
  85662. * @param enable defines the state to set
  85663. */
  85664. setDepthBuffer(enable: boolean): void;
  85665. /**
  85666. * Gets a boolean indicating if depth writing is enabled
  85667. * @returns the current depth writing state
  85668. */
  85669. getDepthWrite(): boolean;
  85670. /**
  85671. * Enable or disable depth writing
  85672. * @param enable defines the state to set
  85673. */
  85674. setDepthWrite(enable: boolean): void;
  85675. /**
  85676. * Enable or disable color writing
  85677. * @param enable defines the state to set
  85678. */
  85679. setColorWrite(enable: boolean): void;
  85680. /**
  85681. * Gets a boolean indicating if color writing is enabled
  85682. * @returns the current color writing state
  85683. */
  85684. getColorWrite(): boolean;
  85685. /**
  85686. * Sets alpha constants used by some alpha blending modes
  85687. * @param r defines the red component
  85688. * @param g defines the green component
  85689. * @param b defines the blue component
  85690. * @param a defines the alpha component
  85691. */
  85692. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85693. /**
  85694. * Sets the current alpha mode
  85695. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85696. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85697. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85698. */
  85699. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85700. /**
  85701. * Gets the current alpha mode
  85702. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85703. * @returns the current alpha mode
  85704. */
  85705. getAlphaMode(): number;
  85706. /**
  85707. * Clears the list of texture accessible through engine.
  85708. * This can help preventing texture load conflict due to name collision.
  85709. */
  85710. clearInternalTexturesCache(): void;
  85711. /**
  85712. * Force the entire cache to be cleared
  85713. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85714. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85715. */
  85716. wipeCaches(bruteForce?: boolean): void;
  85717. /**
  85718. * Set the compressed texture format to use, based on the formats you have, and the formats
  85719. * supported by the hardware / browser.
  85720. *
  85721. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85722. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85723. * to API arguments needed to compressed textures. This puts the burden on the container
  85724. * generator to house the arcane code for determining these for current & future formats.
  85725. *
  85726. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85727. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85728. *
  85729. * Note: The result of this call is not taken into account when a texture is base64.
  85730. *
  85731. * @param formatsAvailable defines the list of those format families you have created
  85732. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85733. *
  85734. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85735. * @returns The extension selected.
  85736. */
  85737. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85738. private _getSamplingParameters;
  85739. private _partialLoadImg;
  85740. private _cascadeLoadImgs;
  85741. /** @hidden */
  85742. _createTexture(): WebGLTexture;
  85743. /**
  85744. * Usually called from Texture.ts.
  85745. * Passed information to create a WebGLTexture
  85746. * @param urlArg defines a value which contains one of the following:
  85747. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85748. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85749. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85750. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85751. * @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)
  85752. * @param scene needed for loading to the correct scene
  85753. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85754. * @param onLoad optional callback to be called upon successful completion
  85755. * @param onError optional callback to be called upon failure
  85756. * @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
  85757. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85758. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85759. * @param forcedExtension defines the extension to use to pick the right loader
  85760. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85761. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85762. */
  85763. 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;
  85764. private _rescaleTexture;
  85765. /**
  85766. * Update a raw texture
  85767. * @param texture defines the texture to update
  85768. * @param data defines the data to store in the texture
  85769. * @param format defines the format of the data
  85770. * @param invertY defines if data must be stored with Y axis inverted
  85771. * @param compression defines the compression used (null by default)
  85772. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85773. */
  85774. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85775. /**
  85776. * Creates a raw texture
  85777. * @param data defines the data to store in the texture
  85778. * @param width defines the width of the texture
  85779. * @param height defines the height of the texture
  85780. * @param format defines the format of the data
  85781. * @param generateMipMaps defines if the engine should generate the mip levels
  85782. * @param invertY defines if data must be stored with Y axis inverted
  85783. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85784. * @param compression defines the compression used (null by default)
  85785. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85786. * @returns the raw texture inside an InternalTexture
  85787. */
  85788. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85789. private _unpackFlipYCached;
  85790. /**
  85791. * In case you are sharing the context with other applications, it might
  85792. * be interested to not cache the unpack flip y state to ensure a consistent
  85793. * value would be set.
  85794. */
  85795. enableUnpackFlipYCached: boolean;
  85796. /** @hidden */
  85797. _unpackFlipY(value: boolean): void;
  85798. /** @hidden */
  85799. _getUnpackAlignement(): number;
  85800. /**
  85801. * Creates a dynamic texture
  85802. * @param width defines the width of the texture
  85803. * @param height defines the height of the texture
  85804. * @param generateMipMaps defines if the engine should generate the mip levels
  85805. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85806. * @returns the dynamic texture inside an InternalTexture
  85807. */
  85808. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85809. /**
  85810. * Update the sampling mode of a given texture
  85811. * @param samplingMode defines the required sampling mode
  85812. * @param texture defines the texture to update
  85813. */
  85814. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85815. /**
  85816. * Update the content of a dynamic texture
  85817. * @param texture defines the texture to update
  85818. * @param canvas defines the canvas containing the source
  85819. * @param invertY defines if data must be stored with Y axis inverted
  85820. * @param premulAlpha defines if alpha is stored as premultiplied
  85821. * @param format defines the format of the data
  85822. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85823. */
  85824. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85825. /**
  85826. * Update a video texture
  85827. * @param texture defines the texture to update
  85828. * @param video defines the video element to use
  85829. * @param invertY defines if data must be stored with Y axis inverted
  85830. */
  85831. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85832. /**
  85833. * Updates a depth texture Comparison Mode and Function.
  85834. * If the comparison Function is equal to 0, the mode will be set to none.
  85835. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85836. * @param texture The texture to set the comparison function for
  85837. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85838. */
  85839. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85840. private _setupDepthStencilTexture;
  85841. /**
  85842. * Creates a depth stencil texture.
  85843. * This is only available in WebGL 2 or with the depth texture extension available.
  85844. * @param size The size of face edge in the texture.
  85845. * @param options The options defining the texture.
  85846. * @returns The texture
  85847. */
  85848. createDepthStencilTexture(size: number | {
  85849. width: number;
  85850. height: number;
  85851. }, options: DepthTextureCreationOptions): InternalTexture;
  85852. /**
  85853. * Creates a depth stencil texture.
  85854. * This is only available in WebGL 2 or with the depth texture extension available.
  85855. * @param size The size of face edge in the texture.
  85856. * @param options The options defining the texture.
  85857. * @returns The texture
  85858. */
  85859. private _createDepthStencilTexture;
  85860. /**
  85861. * Creates a depth stencil cube texture.
  85862. * This is only available in WebGL 2.
  85863. * @param size The size of face edge in the cube texture.
  85864. * @param options The options defining the cube texture.
  85865. * @returns The cube texture
  85866. */
  85867. private _createDepthStencilCubeTexture;
  85868. /**
  85869. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85870. * @param renderTarget The render target to set the frame buffer for
  85871. */
  85872. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85873. /**
  85874. * Creates a new render target texture
  85875. * @param size defines the size of the texture
  85876. * @param options defines the options used to create the texture
  85877. * @returns a new render target texture stored in an InternalTexture
  85878. */
  85879. createRenderTargetTexture(size: number | {
  85880. width: number;
  85881. height: number;
  85882. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85883. /**
  85884. * Create a multi render target texture
  85885. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85886. * @param size defines the size of the texture
  85887. * @param options defines the creation options
  85888. * @returns the cube texture as an InternalTexture
  85889. */
  85890. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85891. private _setupFramebufferDepthAttachments;
  85892. /**
  85893. * Updates the sample count of a render target texture
  85894. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85895. * @param texture defines the texture to update
  85896. * @param samples defines the sample count to set
  85897. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85898. */
  85899. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85900. /**
  85901. * Update the sample count for a given multiple render target texture
  85902. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85903. * @param textures defines the textures to update
  85904. * @param samples defines the sample count to set
  85905. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85906. */
  85907. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85908. /** @hidden */
  85909. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85910. /** @hidden */
  85911. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85912. /** @hidden */
  85913. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85914. /** @hidden */
  85915. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85916. /**
  85917. * Creates a new render target cube texture
  85918. * @param size defines the size of the texture
  85919. * @param options defines the options used to create the texture
  85920. * @returns a new render target cube texture stored in an InternalTexture
  85921. */
  85922. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85923. /**
  85924. * Creates a cube texture
  85925. * @param rootUrl defines the url where the files to load is located
  85926. * @param scene defines the current scene
  85927. * @param files defines the list of files to load (1 per face)
  85928. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85929. * @param onLoad defines an optional callback raised when the texture is loaded
  85930. * @param onError defines an optional callback raised if there is an issue to load the texture
  85931. * @param format defines the format of the data
  85932. * @param forcedExtension defines the extension to use to pick the right loader
  85933. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85934. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85935. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85936. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85937. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85938. * @returns the cube texture as an InternalTexture
  85939. */
  85940. 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;
  85941. /**
  85942. * @hidden
  85943. */
  85944. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85945. /**
  85946. * Update a raw cube texture
  85947. * @param texture defines the texture to udpdate
  85948. * @param data defines the data to store
  85949. * @param format defines the data format
  85950. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85951. * @param invertY defines if data must be stored with Y axis inverted
  85952. * @param compression defines the compression used (null by default)
  85953. * @param level defines which level of the texture to update
  85954. */
  85955. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85956. /**
  85957. * Creates a new raw cube texture
  85958. * @param data defines the array of data to use to create each face
  85959. * @param size defines the size of the textures
  85960. * @param format defines the format of the data
  85961. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85962. * @param generateMipMaps defines if the engine should generate the mip levels
  85963. * @param invertY defines if data must be stored with Y axis inverted
  85964. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85965. * @param compression defines the compression used (null by default)
  85966. * @returns the cube texture as an InternalTexture
  85967. */
  85968. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85969. /**
  85970. * Creates a new raw cube texture from a specified url
  85971. * @param url defines the url where the data is located
  85972. * @param scene defines the current scene
  85973. * @param size defines the size of the textures
  85974. * @param format defines the format of the data
  85975. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85976. * @param noMipmap defines if the engine should avoid generating the mip levels
  85977. * @param callback defines a callback used to extract texture data from loaded data
  85978. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85979. * @param onLoad defines a callback called when texture is loaded
  85980. * @param onError defines a callback called if there is an error
  85981. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85982. * @param invertY defines if data must be stored with Y axis inverted
  85983. * @returns the cube texture as an InternalTexture
  85984. */
  85985. 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;
  85986. /**
  85987. * Update a raw 3D texture
  85988. * @param texture defines the texture to update
  85989. * @param data defines the data to store
  85990. * @param format defines the data format
  85991. * @param invertY defines if data must be stored with Y axis inverted
  85992. * @param compression defines the used compression (can be null)
  85993. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85994. */
  85995. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85996. /**
  85997. * Creates a new raw 3D texture
  85998. * @param data defines the data used to create the texture
  85999. * @param width defines the width of the texture
  86000. * @param height defines the height of the texture
  86001. * @param depth defines the depth of the texture
  86002. * @param format defines the format of the texture
  86003. * @param generateMipMaps defines if the engine must generate mip levels
  86004. * @param invertY defines if data must be stored with Y axis inverted
  86005. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86006. * @param compression defines the compressed used (can be null)
  86007. * @param textureType defines the compressed used (can be null)
  86008. * @returns a new raw 3D texture (stored in an InternalTexture)
  86009. */
  86010. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  86011. private _prepareWebGLTextureContinuation;
  86012. private _prepareWebGLTexture;
  86013. private _convertRGBtoRGBATextureData;
  86014. /** @hidden */
  86015. _releaseFramebufferObjects(texture: InternalTexture): void;
  86016. /** @hidden */
  86017. _releaseTexture(texture: InternalTexture): void;
  86018. private setProgram;
  86019. private _boundUniforms;
  86020. /**
  86021. * Binds an effect to the webGL context
  86022. * @param effect defines the effect to bind
  86023. */
  86024. bindSamplers(effect: Effect): void;
  86025. private _moveBoundTextureOnTop;
  86026. private _getCorrectTextureChannel;
  86027. private _linkTrackers;
  86028. private _removeDesignatedSlot;
  86029. private _activateCurrentTexture;
  86030. /** @hidden */
  86031. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  86032. /** @hidden */
  86033. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  86034. /**
  86035. * Sets a texture to the webGL context from a postprocess
  86036. * @param channel defines the channel to use
  86037. * @param postProcess defines the source postprocess
  86038. */
  86039. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  86040. /**
  86041. * Binds the output of the passed in post process to the texture channel specified
  86042. * @param channel The channel the texture should be bound to
  86043. * @param postProcess The post process which's output should be bound
  86044. */
  86045. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  86046. /**
  86047. * Unbind all textures from the webGL context
  86048. */
  86049. unbindAllTextures(): void;
  86050. /**
  86051. * Sets a texture to the according uniform.
  86052. * @param channel The texture channel
  86053. * @param uniform The uniform to set
  86054. * @param texture The texture to apply
  86055. */
  86056. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  86057. /**
  86058. * Sets a depth stencil texture from a render target to the according uniform.
  86059. * @param channel The texture channel
  86060. * @param uniform The uniform to set
  86061. * @param texture The render target texture containing the depth stencil texture to apply
  86062. */
  86063. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  86064. private _bindSamplerUniformToChannel;
  86065. private _getTextureWrapMode;
  86066. private _setTexture;
  86067. /**
  86068. * Sets an array of texture to the webGL context
  86069. * @param channel defines the channel where the texture array must be set
  86070. * @param uniform defines the associated uniform location
  86071. * @param textures defines the array of textures to bind
  86072. */
  86073. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  86074. /** @hidden */
  86075. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  86076. private _setTextureParameterFloat;
  86077. private _setTextureParameterInteger;
  86078. /**
  86079. * Reads pixels from the current frame buffer. Please note that this function can be slow
  86080. * @param x defines the x coordinate of the rectangle where pixels must be read
  86081. * @param y defines the y coordinate of the rectangle where pixels must be read
  86082. * @param width defines the width of the rectangle where pixels must be read
  86083. * @param height defines the height of the rectangle where pixels must be read
  86084. * @returns a Uint8Array containing RGBA colors
  86085. */
  86086. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  86087. /**
  86088. * Add an externaly attached data from its key.
  86089. * This method call will fail and return false, if such key already exists.
  86090. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  86091. * @param key the unique key that identifies the data
  86092. * @param data the data object to associate to the key for this Engine instance
  86093. * @return true if no such key were already present and the data was added successfully, false otherwise
  86094. */
  86095. addExternalData<T>(key: string, data: T): boolean;
  86096. /**
  86097. * Get an externaly attached data from its key
  86098. * @param key the unique key that identifies the data
  86099. * @return the associated data, if present (can be null), or undefined if not present
  86100. */
  86101. getExternalData<T>(key: string): T;
  86102. /**
  86103. * Get an externaly attached data from its key, create it using a factory if it's not already present
  86104. * @param key the unique key that identifies the data
  86105. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  86106. * @return the associated data, can be null if the factory returned null.
  86107. */
  86108. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  86109. /**
  86110. * Remove an externaly attached data from the Engine instance
  86111. * @param key the unique key that identifies the data
  86112. * @return true if the data was successfully removed, false if it doesn't exist
  86113. */
  86114. removeExternalData(key: string): boolean;
  86115. /**
  86116. * Unbind all vertex attributes from the webGL context
  86117. */
  86118. unbindAllAttributes(): void;
  86119. /**
  86120. * 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
  86121. */
  86122. releaseEffects(): void;
  86123. /**
  86124. * Dispose and release all associated resources
  86125. */
  86126. dispose(): void;
  86127. /**
  86128. * Display the loading screen
  86129. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86130. */
  86131. displayLoadingUI(): void;
  86132. /**
  86133. * Hide the loading screen
  86134. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86135. */
  86136. hideLoadingUI(): void;
  86137. /**
  86138. * Gets the current loading screen object
  86139. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86140. */
  86141. /**
  86142. * Sets the current loading screen object
  86143. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86144. */
  86145. loadingScreen: ILoadingScreen;
  86146. /**
  86147. * Sets the current loading screen text
  86148. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86149. */
  86150. loadingUIText: string;
  86151. /**
  86152. * Sets the current loading screen background color
  86153. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86154. */
  86155. loadingUIBackgroundColor: string;
  86156. /**
  86157. * Attach a new callback raised when context lost event is fired
  86158. * @param callback defines the callback to call
  86159. */
  86160. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86161. /**
  86162. * Attach a new callback raised when context restored event is fired
  86163. * @param callback defines the callback to call
  86164. */
  86165. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86166. /**
  86167. * Gets the source code of the vertex shader associated with a specific webGL program
  86168. * @param program defines the program to use
  86169. * @returns a string containing the source code of the vertex shader associated with the program
  86170. */
  86171. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  86172. /**
  86173. * Gets the source code of the fragment shader associated with a specific webGL program
  86174. * @param program defines the program to use
  86175. * @returns a string containing the source code of the fragment shader associated with the program
  86176. */
  86177. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  86178. /**
  86179. * Get the current error code of the webGL context
  86180. * @returns the error code
  86181. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  86182. */
  86183. getError(): number;
  86184. /**
  86185. * Gets the current framerate
  86186. * @returns a number representing the framerate
  86187. */
  86188. getFps(): number;
  86189. /**
  86190. * Gets the time spent between current and previous frame
  86191. * @returns a number representing the delta time in ms
  86192. */
  86193. getDeltaTime(): number;
  86194. private _measureFps;
  86195. /** @hidden */
  86196. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  86197. private _canRenderToFloatFramebuffer;
  86198. private _canRenderToHalfFloatFramebuffer;
  86199. private _canRenderToFramebuffer;
  86200. /** @hidden */
  86201. _getWebGLTextureType(type: number): number;
  86202. private _getInternalFormat;
  86203. /** @hidden */
  86204. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  86205. /** @hidden */
  86206. _getRGBAMultiSampleBufferFormat(type: number): number;
  86207. /** @hidden */
  86208. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  86209. /** @hidden */
  86210. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  86211. private _partialLoadFile;
  86212. private _cascadeLoadFiles;
  86213. /**
  86214. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  86215. * @returns true if the engine can be created
  86216. * @ignorenaming
  86217. */
  86218. static isSupported(): boolean;
  86219. }
  86220. }
  86221. declare module BABYLON {
  86222. /**
  86223. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86224. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86225. */
  86226. export class EffectFallbacks {
  86227. private _defines;
  86228. private _currentRank;
  86229. private _maxRank;
  86230. private _mesh;
  86231. /**
  86232. * Removes the fallback from the bound mesh.
  86233. */
  86234. unBindMesh(): void;
  86235. /**
  86236. * Adds a fallback on the specified property.
  86237. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86238. * @param define The name of the define in the shader
  86239. */
  86240. addFallback(rank: number, define: string): void;
  86241. /**
  86242. * Sets the mesh to use CPU skinning when needing to fallback.
  86243. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86244. * @param mesh The mesh to use the fallbacks.
  86245. */
  86246. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86247. /**
  86248. * Checks to see if more fallbacks are still availible.
  86249. */
  86250. readonly isMoreFallbacks: boolean;
  86251. /**
  86252. * Removes the defines that shoould be removed when falling back.
  86253. * @param currentDefines defines the current define statements for the shader.
  86254. * @param effect defines the current effect we try to compile
  86255. * @returns The resulting defines with defines of the current rank removed.
  86256. */
  86257. reduce(currentDefines: string, effect: Effect): string;
  86258. }
  86259. /**
  86260. * Options to be used when creating an effect.
  86261. */
  86262. export class EffectCreationOptions {
  86263. /**
  86264. * Atrributes that will be used in the shader.
  86265. */
  86266. attributes: string[];
  86267. /**
  86268. * Uniform varible names that will be set in the shader.
  86269. */
  86270. uniformsNames: string[];
  86271. /**
  86272. * Uniform buffer varible names that will be set in the shader.
  86273. */
  86274. uniformBuffersNames: string[];
  86275. /**
  86276. * Sampler texture variable names that will be set in the shader.
  86277. */
  86278. samplers: string[];
  86279. /**
  86280. * Define statements that will be set in the shader.
  86281. */
  86282. defines: any;
  86283. /**
  86284. * Possible fallbacks for this effect to improve performance when needed.
  86285. */
  86286. fallbacks: Nullable<EffectFallbacks>;
  86287. /**
  86288. * Callback that will be called when the shader is compiled.
  86289. */
  86290. onCompiled: Nullable<(effect: Effect) => void>;
  86291. /**
  86292. * Callback that will be called if an error occurs during shader compilation.
  86293. */
  86294. onError: Nullable<(effect: Effect, errors: string) => void>;
  86295. /**
  86296. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86297. */
  86298. indexParameters: any;
  86299. /**
  86300. * Max number of lights that can be used in the shader.
  86301. */
  86302. maxSimultaneousLights: number;
  86303. /**
  86304. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  86305. */
  86306. transformFeedbackVaryings: Nullable<string[]>;
  86307. }
  86308. /**
  86309. * Effect containing vertex and fragment shader that can be executed on an object.
  86310. */
  86311. export class Effect {
  86312. /**
  86313. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86314. */
  86315. static ShadersRepository: string;
  86316. /**
  86317. * Name of the effect.
  86318. */
  86319. name: any;
  86320. /**
  86321. * String container all the define statements that should be set on the shader.
  86322. */
  86323. defines: string;
  86324. /**
  86325. * Callback that will be called when the shader is compiled.
  86326. */
  86327. onCompiled: Nullable<(effect: Effect) => void>;
  86328. /**
  86329. * Callback that will be called if an error occurs during shader compilation.
  86330. */
  86331. onError: Nullable<(effect: Effect, errors: string) => void>;
  86332. /**
  86333. * Callback that will be called when effect is bound.
  86334. */
  86335. onBind: Nullable<(effect: Effect) => void>;
  86336. /**
  86337. * Unique ID of the effect.
  86338. */
  86339. uniqueId: number;
  86340. /**
  86341. * Observable that will be called when the shader is compiled.
  86342. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  86343. */
  86344. onCompileObservable: Observable<Effect>;
  86345. /**
  86346. * Observable that will be called if an error occurs during shader compilation.
  86347. */
  86348. onErrorObservable: Observable<Effect>;
  86349. /** @hidden */
  86350. _onBindObservable: Nullable<Observable<Effect>>;
  86351. /**
  86352. * Observable that will be called when effect is bound.
  86353. */
  86354. readonly onBindObservable: Observable<Effect>;
  86355. /** @hidden */
  86356. _bonesComputationForcedToCPU: boolean;
  86357. private static _uniqueIdSeed;
  86358. private _engine;
  86359. private _uniformBuffersNames;
  86360. private _uniformsNames;
  86361. private _samplers;
  86362. private _isReady;
  86363. private _compilationError;
  86364. private _attributesNames;
  86365. private _attributes;
  86366. private _uniforms;
  86367. /**
  86368. * Key for the effect.
  86369. * @hidden
  86370. */
  86371. _key: string;
  86372. private _indexParameters;
  86373. private _fallbacks;
  86374. private _vertexSourceCode;
  86375. private _fragmentSourceCode;
  86376. private _vertexSourceCodeOverride;
  86377. private _fragmentSourceCodeOverride;
  86378. private _transformFeedbackVaryings;
  86379. /**
  86380. * Compiled shader to webGL program.
  86381. * @hidden
  86382. */
  86383. _program: WebGLProgram;
  86384. private _valueCache;
  86385. private static _baseCache;
  86386. /**
  86387. * Instantiates an effect.
  86388. * An effect can be used to create/manage/execute vertex and fragment shaders.
  86389. * @param baseName Name of the effect.
  86390. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  86391. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  86392. * @param samplers List of sampler variables that will be passed to the shader.
  86393. * @param engine Engine to be used to render the effect
  86394. * @param defines Define statements to be added to the shader.
  86395. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  86396. * @param onCompiled Callback that will be called when the shader is compiled.
  86397. * @param onError Callback that will be called if an error occurs during shader compilation.
  86398. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86399. */
  86400. 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);
  86401. /**
  86402. * Unique key for this effect
  86403. */
  86404. readonly key: string;
  86405. /**
  86406. * If the effect has been compiled and prepared.
  86407. * @returns if the effect is compiled and prepared.
  86408. */
  86409. isReady(): boolean;
  86410. /**
  86411. * The engine the effect was initialized with.
  86412. * @returns the engine.
  86413. */
  86414. getEngine(): Engine;
  86415. /**
  86416. * The compiled webGL program for the effect
  86417. * @returns the webGL program.
  86418. */
  86419. getProgram(): WebGLProgram;
  86420. /**
  86421. * The set of names of attribute variables for the shader.
  86422. * @returns An array of attribute names.
  86423. */
  86424. getAttributesNames(): string[];
  86425. /**
  86426. * Returns the attribute at the given index.
  86427. * @param index The index of the attribute.
  86428. * @returns The location of the attribute.
  86429. */
  86430. getAttributeLocation(index: number): number;
  86431. /**
  86432. * Returns the attribute based on the name of the variable.
  86433. * @param name of the attribute to look up.
  86434. * @returns the attribute location.
  86435. */
  86436. getAttributeLocationByName(name: string): number;
  86437. /**
  86438. * The number of attributes.
  86439. * @returns the numnber of attributes.
  86440. */
  86441. getAttributesCount(): number;
  86442. /**
  86443. * Gets the index of a uniform variable.
  86444. * @param uniformName of the uniform to look up.
  86445. * @returns the index.
  86446. */
  86447. getUniformIndex(uniformName: string): number;
  86448. /**
  86449. * Returns the attribute based on the name of the variable.
  86450. * @param uniformName of the uniform to look up.
  86451. * @returns the location of the uniform.
  86452. */
  86453. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  86454. /**
  86455. * Returns an array of sampler variable names
  86456. * @returns The array of sampler variable neames.
  86457. */
  86458. getSamplers(): string[];
  86459. /**
  86460. * The error from the last compilation.
  86461. * @returns the error string.
  86462. */
  86463. getCompilationError(): string;
  86464. /**
  86465. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  86466. * @param func The callback to be used.
  86467. */
  86468. executeWhenCompiled(func: (effect: Effect) => void): void;
  86469. private _checkIsReady;
  86470. /** @hidden */
  86471. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  86472. /** @hidden */
  86473. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  86474. /** @hidden */
  86475. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  86476. private _processShaderConversion;
  86477. private _processIncludes;
  86478. private _processPrecision;
  86479. /**
  86480. * Recompiles the webGL program
  86481. * @param vertexSourceCode The source code for the vertex shader.
  86482. * @param fragmentSourceCode The source code for the fragment shader.
  86483. * @param onCompiled Callback called when completed.
  86484. * @param onError Callback called on error.
  86485. * @hidden
  86486. */
  86487. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  86488. /**
  86489. * Gets the uniform locations of the the specified variable names
  86490. * @param names THe names of the variables to lookup.
  86491. * @returns Array of locations in the same order as variable names.
  86492. */
  86493. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  86494. /**
  86495. * Prepares the effect
  86496. * @hidden
  86497. */
  86498. _prepareEffect(): void;
  86499. /**
  86500. * Checks if the effect is supported. (Must be called after compilation)
  86501. */
  86502. readonly isSupported: boolean;
  86503. /**
  86504. * Binds a texture to the engine to be used as output of the shader.
  86505. * @param channel Name of the output variable.
  86506. * @param texture Texture to bind.
  86507. * @hidden
  86508. */
  86509. _bindTexture(channel: string, texture: InternalTexture): void;
  86510. /**
  86511. * Sets a texture on the engine to be used in the shader.
  86512. * @param channel Name of the sampler variable.
  86513. * @param texture Texture to set.
  86514. */
  86515. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  86516. /**
  86517. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  86518. * @param channel Name of the sampler variable.
  86519. * @param texture Texture to set.
  86520. */
  86521. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  86522. /**
  86523. * Sets an array of textures on the engine to be used in the shader.
  86524. * @param channel Name of the variable.
  86525. * @param textures Textures to set.
  86526. */
  86527. setTextureArray(channel: string, textures: BaseTexture[]): void;
  86528. /**
  86529. * 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)
  86530. * @param channel Name of the sampler variable.
  86531. * @param postProcess Post process to get the input texture from.
  86532. */
  86533. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  86534. /**
  86535. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  86536. * 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)
  86537. * @param channel Name of the sampler variable.
  86538. * @param postProcess Post process to get the output texture from.
  86539. */
  86540. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  86541. /** @hidden */
  86542. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  86543. /** @hidden */
  86544. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  86545. /** @hidden */
  86546. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  86547. /** @hidden */
  86548. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  86549. /**
  86550. * Binds a buffer to a uniform.
  86551. * @param buffer Buffer to bind.
  86552. * @param name Name of the uniform variable to bind to.
  86553. */
  86554. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  86555. /**
  86556. * Binds block to a uniform.
  86557. * @param blockName Name of the block to bind.
  86558. * @param index Index to bind.
  86559. */
  86560. bindUniformBlock(blockName: string, index: number): void;
  86561. /**
  86562. * Sets an interger value on a uniform variable.
  86563. * @param uniformName Name of the variable.
  86564. * @param value Value to be set.
  86565. * @returns this effect.
  86566. */
  86567. setInt(uniformName: string, value: number): Effect;
  86568. /**
  86569. * Sets an int array on a uniform variable.
  86570. * @param uniformName Name of the variable.
  86571. * @param array array to be set.
  86572. * @returns this effect.
  86573. */
  86574. setIntArray(uniformName: string, array: Int32Array): Effect;
  86575. /**
  86576. * 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)
  86577. * @param uniformName Name of the variable.
  86578. * @param array array to be set.
  86579. * @returns this effect.
  86580. */
  86581. setIntArray2(uniformName: string, array: Int32Array): Effect;
  86582. /**
  86583. * 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)
  86584. * @param uniformName Name of the variable.
  86585. * @param array array to be set.
  86586. * @returns this effect.
  86587. */
  86588. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86589. /**
  86590. * 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)
  86591. * @param uniformName Name of the variable.
  86592. * @param array array to be set.
  86593. * @returns this effect.
  86594. */
  86595. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86596. /**
  86597. * Sets an float array on a uniform variable.
  86598. * @param uniformName Name of the variable.
  86599. * @param array array to be set.
  86600. * @returns this effect.
  86601. */
  86602. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86603. /**
  86604. * 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)
  86605. * @param uniformName Name of the variable.
  86606. * @param array array to be set.
  86607. * @returns this effect.
  86608. */
  86609. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86610. /**
  86611. * 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)
  86612. * @param uniformName Name of the variable.
  86613. * @param array array to be set.
  86614. * @returns this effect.
  86615. */
  86616. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86617. /**
  86618. * 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)
  86619. * @param uniformName Name of the variable.
  86620. * @param array array to be set.
  86621. * @returns this effect.
  86622. */
  86623. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86624. /**
  86625. * Sets an array on a uniform variable.
  86626. * @param uniformName Name of the variable.
  86627. * @param array array to be set.
  86628. * @returns this effect.
  86629. */
  86630. setArray(uniformName: string, array: number[]): Effect;
  86631. /**
  86632. * 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)
  86633. * @param uniformName Name of the variable.
  86634. * @param array array to be set.
  86635. * @returns this effect.
  86636. */
  86637. setArray2(uniformName: string, array: number[]): Effect;
  86638. /**
  86639. * 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)
  86640. * @param uniformName Name of the variable.
  86641. * @param array array to be set.
  86642. * @returns this effect.
  86643. */
  86644. setArray3(uniformName: string, array: number[]): Effect;
  86645. /**
  86646. * 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)
  86647. * @param uniformName Name of the variable.
  86648. * @param array array to be set.
  86649. * @returns this effect.
  86650. */
  86651. setArray4(uniformName: string, array: number[]): Effect;
  86652. /**
  86653. * Sets matrices on a uniform variable.
  86654. * @param uniformName Name of the variable.
  86655. * @param matrices matrices to be set.
  86656. * @returns this effect.
  86657. */
  86658. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86659. /**
  86660. * Sets matrix on a uniform variable.
  86661. * @param uniformName Name of the variable.
  86662. * @param matrix matrix to be set.
  86663. * @returns this effect.
  86664. */
  86665. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86666. /**
  86667. * 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)
  86668. * @param uniformName Name of the variable.
  86669. * @param matrix matrix to be set.
  86670. * @returns this effect.
  86671. */
  86672. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86673. /**
  86674. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86675. * @param uniformName Name of the variable.
  86676. * @param matrix matrix to be set.
  86677. * @returns this effect.
  86678. */
  86679. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86680. /**
  86681. * Sets a float on a uniform variable.
  86682. * @param uniformName Name of the variable.
  86683. * @param value value to be set.
  86684. * @returns this effect.
  86685. */
  86686. setFloat(uniformName: string, value: number): Effect;
  86687. /**
  86688. * Sets a boolean on a uniform variable.
  86689. * @param uniformName Name of the variable.
  86690. * @param bool value to be set.
  86691. * @returns this effect.
  86692. */
  86693. setBool(uniformName: string, bool: boolean): Effect;
  86694. /**
  86695. * Sets a Vector2 on a uniform variable.
  86696. * @param uniformName Name of the variable.
  86697. * @param vector2 vector2 to be set.
  86698. * @returns this effect.
  86699. */
  86700. setVector2(uniformName: string, vector2: Vector2): Effect;
  86701. /**
  86702. * Sets a float2 on a uniform variable.
  86703. * @param uniformName Name of the variable.
  86704. * @param x First float in float2.
  86705. * @param y Second float in float2.
  86706. * @returns this effect.
  86707. */
  86708. setFloat2(uniformName: string, x: number, y: number): Effect;
  86709. /**
  86710. * Sets a Vector3 on a uniform variable.
  86711. * @param uniformName Name of the variable.
  86712. * @param vector3 Value to be set.
  86713. * @returns this effect.
  86714. */
  86715. setVector3(uniformName: string, vector3: Vector3): Effect;
  86716. /**
  86717. * Sets a float3 on a uniform variable.
  86718. * @param uniformName Name of the variable.
  86719. * @param x First float in float3.
  86720. * @param y Second float in float3.
  86721. * @param z Third float in float3.
  86722. * @returns this effect.
  86723. */
  86724. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86725. /**
  86726. * Sets a Vector4 on a uniform variable.
  86727. * @param uniformName Name of the variable.
  86728. * @param vector4 Value to be set.
  86729. * @returns this effect.
  86730. */
  86731. setVector4(uniformName: string, vector4: Vector4): Effect;
  86732. /**
  86733. * Sets a float4 on a uniform variable.
  86734. * @param uniformName Name of the variable.
  86735. * @param x First float in float4.
  86736. * @param y Second float in float4.
  86737. * @param z Third float in float4.
  86738. * @param w Fourth float in float4.
  86739. * @returns this effect.
  86740. */
  86741. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86742. /**
  86743. * Sets a Color3 on a uniform variable.
  86744. * @param uniformName Name of the variable.
  86745. * @param color3 Value to be set.
  86746. * @returns this effect.
  86747. */
  86748. setColor3(uniformName: string, color3: Color3): Effect;
  86749. /**
  86750. * Sets a Color4 on a uniform variable.
  86751. * @param uniformName Name of the variable.
  86752. * @param color3 Value to be set.
  86753. * @param alpha Alpha value to be set.
  86754. * @returns this effect.
  86755. */
  86756. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86757. /**
  86758. * Sets a Color4 on a uniform variable
  86759. * @param uniformName defines the name of the variable
  86760. * @param color4 defines the value to be set
  86761. * @returns this effect.
  86762. */
  86763. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86764. /**
  86765. * This function will add a new shader to the shader store
  86766. * @param name the name of the shader
  86767. * @param pixelShader optional pixel shader content
  86768. * @param vertexShader optional vertex shader content
  86769. */
  86770. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86771. /**
  86772. * Store of each shader (The can be looked up using effect.key)
  86773. */
  86774. static ShadersStore: {
  86775. [key: string]: string;
  86776. };
  86777. /**
  86778. * Store of each included file for a shader (The can be looked up using effect.key)
  86779. */
  86780. static IncludesShadersStore: {
  86781. [key: string]: string;
  86782. };
  86783. /**
  86784. * Resets the cache of effects.
  86785. */
  86786. static ResetCache(): void;
  86787. }
  86788. }
  86789. declare module BABYLON {
  86790. /**
  86791. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86792. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86793. * 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;
  86794. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86795. */
  86796. export class ColorCurves {
  86797. private _dirty;
  86798. private _tempColor;
  86799. private _globalCurve;
  86800. private _highlightsCurve;
  86801. private _midtonesCurve;
  86802. private _shadowsCurve;
  86803. private _positiveCurve;
  86804. private _negativeCurve;
  86805. private _globalHue;
  86806. private _globalDensity;
  86807. private _globalSaturation;
  86808. private _globalExposure;
  86809. /**
  86810. * Gets the global Hue value.
  86811. * 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).
  86812. */
  86813. /**
  86814. * Sets the global Hue value.
  86815. * 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).
  86816. */
  86817. globalHue: number;
  86818. /**
  86819. * Gets the global Density value.
  86820. * 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.
  86821. * Values less than zero provide a filter of opposite hue.
  86822. */
  86823. /**
  86824. * Sets the global Density value.
  86825. * 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.
  86826. * Values less than zero provide a filter of opposite hue.
  86827. */
  86828. globalDensity: number;
  86829. /**
  86830. * Gets the global Saturation value.
  86831. * 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.
  86832. */
  86833. /**
  86834. * Sets the global Saturation value.
  86835. * 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.
  86836. */
  86837. globalSaturation: number;
  86838. /**
  86839. * Gets the global Exposure value.
  86840. * 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.
  86841. */
  86842. /**
  86843. * Sets the global Exposure value.
  86844. * 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.
  86845. */
  86846. globalExposure: number;
  86847. private _highlightsHue;
  86848. private _highlightsDensity;
  86849. private _highlightsSaturation;
  86850. private _highlightsExposure;
  86851. /**
  86852. * Gets the highlights Hue value.
  86853. * 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).
  86854. */
  86855. /**
  86856. * Sets the highlights Hue value.
  86857. * 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).
  86858. */
  86859. highlightsHue: number;
  86860. /**
  86861. * Gets the highlights Density value.
  86862. * 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.
  86863. * Values less than zero provide a filter of opposite hue.
  86864. */
  86865. /**
  86866. * Sets the highlights Density value.
  86867. * 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.
  86868. * Values less than zero provide a filter of opposite hue.
  86869. */
  86870. highlightsDensity: number;
  86871. /**
  86872. * Gets the highlights Saturation value.
  86873. * 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.
  86874. */
  86875. /**
  86876. * Sets the highlights Saturation value.
  86877. * 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.
  86878. */
  86879. highlightsSaturation: number;
  86880. /**
  86881. * Gets the highlights Exposure value.
  86882. * 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.
  86883. */
  86884. /**
  86885. * Sets the highlights Exposure value.
  86886. * 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.
  86887. */
  86888. highlightsExposure: number;
  86889. private _midtonesHue;
  86890. private _midtonesDensity;
  86891. private _midtonesSaturation;
  86892. private _midtonesExposure;
  86893. /**
  86894. * Gets the midtones Hue value.
  86895. * 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).
  86896. */
  86897. /**
  86898. * Sets the midtones Hue value.
  86899. * 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).
  86900. */
  86901. midtonesHue: number;
  86902. /**
  86903. * Gets the midtones Density value.
  86904. * 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.
  86905. * Values less than zero provide a filter of opposite hue.
  86906. */
  86907. /**
  86908. * Sets the midtones Density value.
  86909. * 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.
  86910. * Values less than zero provide a filter of opposite hue.
  86911. */
  86912. midtonesDensity: number;
  86913. /**
  86914. * Gets the midtones Saturation value.
  86915. * 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.
  86916. */
  86917. /**
  86918. * Sets the midtones Saturation value.
  86919. * 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.
  86920. */
  86921. midtonesSaturation: number;
  86922. /**
  86923. * Gets the midtones Exposure value.
  86924. * 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.
  86925. */
  86926. /**
  86927. * Sets the midtones Exposure value.
  86928. * 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.
  86929. */
  86930. midtonesExposure: number;
  86931. private _shadowsHue;
  86932. private _shadowsDensity;
  86933. private _shadowsSaturation;
  86934. private _shadowsExposure;
  86935. /**
  86936. * Gets the shadows Hue value.
  86937. * 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).
  86938. */
  86939. /**
  86940. * Sets the shadows Hue value.
  86941. * 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).
  86942. */
  86943. shadowsHue: number;
  86944. /**
  86945. * Gets the shadows Density value.
  86946. * 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.
  86947. * Values less than zero provide a filter of opposite hue.
  86948. */
  86949. /**
  86950. * Sets the shadows Density value.
  86951. * 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.
  86952. * Values less than zero provide a filter of opposite hue.
  86953. */
  86954. shadowsDensity: number;
  86955. /**
  86956. * Gets the shadows Saturation value.
  86957. * 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.
  86958. */
  86959. /**
  86960. * Sets the shadows Saturation value.
  86961. * 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.
  86962. */
  86963. shadowsSaturation: number;
  86964. /**
  86965. * Gets the shadows Exposure value.
  86966. * 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.
  86967. */
  86968. /**
  86969. * Sets the shadows Exposure value.
  86970. * 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.
  86971. */
  86972. shadowsExposure: number;
  86973. /**
  86974. * Returns the class name
  86975. * @returns The class name
  86976. */
  86977. getClassName(): string;
  86978. /**
  86979. * Binds the color curves to the shader.
  86980. * @param colorCurves The color curve to bind
  86981. * @param effect The effect to bind to
  86982. * @param positiveUniform The positive uniform shader parameter
  86983. * @param neutralUniform The neutral uniform shader parameter
  86984. * @param negativeUniform The negative uniform shader parameter
  86985. */
  86986. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86987. /**
  86988. * Prepare the list of uniforms associated with the ColorCurves effects.
  86989. * @param uniformsList The list of uniforms used in the effect
  86990. */
  86991. static PrepareUniforms(uniformsList: string[]): void;
  86992. /**
  86993. * Returns color grading data based on a hue, density, saturation and exposure value.
  86994. * @param filterHue The hue of the color filter.
  86995. * @param filterDensity The density of the color filter.
  86996. * @param saturation The saturation.
  86997. * @param exposure The exposure.
  86998. * @param result The result data container.
  86999. */
  87000. private getColorGradingDataToRef;
  87001. /**
  87002. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87003. * @param value The input slider value in range [-100,100].
  87004. * @returns Adjusted value.
  87005. */
  87006. private static applyColorGradingSliderNonlinear;
  87007. /**
  87008. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87009. * @param hue The hue (H) input.
  87010. * @param saturation The saturation (S) input.
  87011. * @param brightness The brightness (B) input.
  87012. * @result An RGBA color represented as Vector4.
  87013. */
  87014. private static fromHSBToRef;
  87015. /**
  87016. * Returns a value clamped between min and max
  87017. * @param value The value to clamp
  87018. * @param min The minimum of value
  87019. * @param max The maximum of value
  87020. * @returns The clamped value.
  87021. */
  87022. private static clamp;
  87023. /**
  87024. * Clones the current color curve instance.
  87025. * @return The cloned curves
  87026. */
  87027. clone(): ColorCurves;
  87028. /**
  87029. * Serializes the current color curve instance to a json representation.
  87030. * @return a JSON representation
  87031. */
  87032. serialize(): any;
  87033. /**
  87034. * Parses the color curve from a json representation.
  87035. * @param source the JSON source to parse
  87036. * @return The parsed curves
  87037. */
  87038. static Parse(source: any): ColorCurves;
  87039. }
  87040. }
  87041. declare module BABYLON {
  87042. /**
  87043. * Interface to follow in your material defines to integrate easily the
  87044. * Image proccessing functions.
  87045. * @hidden
  87046. */
  87047. export interface IImageProcessingConfigurationDefines {
  87048. IMAGEPROCESSING: boolean;
  87049. VIGNETTE: boolean;
  87050. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87051. VIGNETTEBLENDMODEOPAQUE: boolean;
  87052. TONEMAPPING: boolean;
  87053. TONEMAPPING_ACES: boolean;
  87054. CONTRAST: boolean;
  87055. EXPOSURE: boolean;
  87056. COLORCURVES: boolean;
  87057. COLORGRADING: boolean;
  87058. COLORGRADING3D: boolean;
  87059. SAMPLER3DGREENDEPTH: boolean;
  87060. SAMPLER3DBGRMAP: boolean;
  87061. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87062. }
  87063. /**
  87064. * @hidden
  87065. */
  87066. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87067. IMAGEPROCESSING: boolean;
  87068. VIGNETTE: boolean;
  87069. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87070. VIGNETTEBLENDMODEOPAQUE: boolean;
  87071. TONEMAPPING: boolean;
  87072. TONEMAPPING_ACES: boolean;
  87073. CONTRAST: boolean;
  87074. COLORCURVES: boolean;
  87075. COLORGRADING: boolean;
  87076. COLORGRADING3D: boolean;
  87077. SAMPLER3DGREENDEPTH: boolean;
  87078. SAMPLER3DBGRMAP: boolean;
  87079. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87080. EXPOSURE: boolean;
  87081. constructor();
  87082. }
  87083. /**
  87084. * This groups together the common properties used for image processing either in direct forward pass
  87085. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87086. * or not.
  87087. */
  87088. export class ImageProcessingConfiguration {
  87089. /**
  87090. * Default tone mapping applied in BabylonJS.
  87091. */
  87092. static readonly TONEMAPPING_STANDARD: number;
  87093. /**
  87094. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87095. * to other engines rendering to increase portability.
  87096. */
  87097. static readonly TONEMAPPING_ACES: number;
  87098. /**
  87099. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87100. */
  87101. colorCurves: Nullable<ColorCurves>;
  87102. private _colorCurvesEnabled;
  87103. /**
  87104. * Gets wether the color curves effect is enabled.
  87105. */
  87106. /**
  87107. * Sets wether the color curves effect is enabled.
  87108. */
  87109. colorCurvesEnabled: boolean;
  87110. private _colorGradingTexture;
  87111. /**
  87112. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87113. */
  87114. /**
  87115. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87116. */
  87117. colorGradingTexture: Nullable<BaseTexture>;
  87118. private _colorGradingEnabled;
  87119. /**
  87120. * Gets wether the color grading effect is enabled.
  87121. */
  87122. /**
  87123. * Sets wether the color grading effect is enabled.
  87124. */
  87125. colorGradingEnabled: boolean;
  87126. private _colorGradingWithGreenDepth;
  87127. /**
  87128. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87129. */
  87130. /**
  87131. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87132. */
  87133. colorGradingWithGreenDepth: boolean;
  87134. private _colorGradingBGR;
  87135. /**
  87136. * Gets wether the color grading texture contains BGR values.
  87137. */
  87138. /**
  87139. * Sets wether the color grading texture contains BGR values.
  87140. */
  87141. colorGradingBGR: boolean;
  87142. /** @hidden */
  87143. _exposure: number;
  87144. /**
  87145. * Gets the Exposure used in the effect.
  87146. */
  87147. /**
  87148. * Sets the Exposure used in the effect.
  87149. */
  87150. exposure: number;
  87151. private _toneMappingEnabled;
  87152. /**
  87153. * Gets wether the tone mapping effect is enabled.
  87154. */
  87155. /**
  87156. * Sets wether the tone mapping effect is enabled.
  87157. */
  87158. toneMappingEnabled: boolean;
  87159. private _toneMappingType;
  87160. /**
  87161. * Gets the type of tone mapping effect.
  87162. */
  87163. /**
  87164. * Sets the type of tone mapping effect used in BabylonJS.
  87165. */
  87166. toneMappingType: number;
  87167. protected _contrast: number;
  87168. /**
  87169. * Gets the contrast used in the effect.
  87170. */
  87171. /**
  87172. * Sets the contrast used in the effect.
  87173. */
  87174. contrast: number;
  87175. /**
  87176. * Vignette stretch size.
  87177. */
  87178. vignetteStretch: number;
  87179. /**
  87180. * Vignette centre X Offset.
  87181. */
  87182. vignetteCentreX: number;
  87183. /**
  87184. * Vignette centre Y Offset.
  87185. */
  87186. vignetteCentreY: number;
  87187. /**
  87188. * Vignette weight or intensity of the vignette effect.
  87189. */
  87190. vignetteWeight: number;
  87191. /**
  87192. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87193. * if vignetteEnabled is set to true.
  87194. */
  87195. vignetteColor: Color4;
  87196. /**
  87197. * Camera field of view used by the Vignette effect.
  87198. */
  87199. vignetteCameraFov: number;
  87200. private _vignetteBlendMode;
  87201. /**
  87202. * Gets the vignette blend mode allowing different kind of effect.
  87203. */
  87204. /**
  87205. * Sets the vignette blend mode allowing different kind of effect.
  87206. */
  87207. vignetteBlendMode: number;
  87208. private _vignetteEnabled;
  87209. /**
  87210. * Gets wether the vignette effect is enabled.
  87211. */
  87212. /**
  87213. * Sets wether the vignette effect is enabled.
  87214. */
  87215. vignetteEnabled: boolean;
  87216. private _applyByPostProcess;
  87217. /**
  87218. * Gets wether the image processing is applied through a post process or not.
  87219. */
  87220. /**
  87221. * Sets wether the image processing is applied through a post process or not.
  87222. */
  87223. applyByPostProcess: boolean;
  87224. private _isEnabled;
  87225. /**
  87226. * Gets wether the image processing is enabled or not.
  87227. */
  87228. /**
  87229. * Sets wether the image processing is enabled or not.
  87230. */
  87231. isEnabled: boolean;
  87232. /**
  87233. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87234. */
  87235. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87236. /**
  87237. * Method called each time the image processing information changes requires to recompile the effect.
  87238. */
  87239. protected _updateParameters(): void;
  87240. /**
  87241. * Gets the current class name.
  87242. * @return "ImageProcessingConfiguration"
  87243. */
  87244. getClassName(): string;
  87245. /**
  87246. * Prepare the list of uniforms associated with the Image Processing effects.
  87247. * @param uniforms The list of uniforms used in the effect
  87248. * @param defines the list of defines currently in use
  87249. */
  87250. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87251. /**
  87252. * Prepare the list of samplers associated with the Image Processing effects.
  87253. * @param samplersList The list of uniforms used in the effect
  87254. * @param defines the list of defines currently in use
  87255. */
  87256. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87257. /**
  87258. * Prepare the list of defines associated to the shader.
  87259. * @param defines the list of defines to complete
  87260. * @param forPostProcess Define if we are currently in post process mode or not
  87261. */
  87262. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87263. /**
  87264. * Returns true if all the image processing information are ready.
  87265. * @returns True if ready, otherwise, false
  87266. */
  87267. isReady(): boolean;
  87268. /**
  87269. * Binds the image processing to the shader.
  87270. * @param effect The effect to bind to
  87271. * @param aspectRatio Define the current aspect ratio of the effect
  87272. */
  87273. bind(effect: Effect, aspectRatio?: number): void;
  87274. /**
  87275. * Clones the current image processing instance.
  87276. * @return The cloned image processing
  87277. */
  87278. clone(): ImageProcessingConfiguration;
  87279. /**
  87280. * Serializes the current image processing instance to a json representation.
  87281. * @return a JSON representation
  87282. */
  87283. serialize(): any;
  87284. /**
  87285. * Parses the image processing from a json representation.
  87286. * @param source the JSON source to parse
  87287. * @return The parsed image processing
  87288. */
  87289. static Parse(source: any): ImageProcessingConfiguration;
  87290. private static _VIGNETTEMODE_MULTIPLY;
  87291. private static _VIGNETTEMODE_OPAQUE;
  87292. /**
  87293. * Used to apply the vignette as a mix with the pixel color.
  87294. */
  87295. static readonly VIGNETTEMODE_MULTIPLY: number;
  87296. /**
  87297. * Used to apply the vignette as a replacement of the pixel color.
  87298. */
  87299. static readonly VIGNETTEMODE_OPAQUE: number;
  87300. }
  87301. }
  87302. declare module BABYLON {
  87303. /**
  87304. * This represents all the required information to add a fresnel effect on a material:
  87305. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  87306. */
  87307. export class FresnelParameters {
  87308. private _isEnabled;
  87309. /**
  87310. * Define if the fresnel effect is enable or not.
  87311. */
  87312. isEnabled: boolean;
  87313. /**
  87314. * Define the color used on edges (grazing angle)
  87315. */
  87316. leftColor: Color3;
  87317. /**
  87318. * Define the color used on center
  87319. */
  87320. rightColor: Color3;
  87321. /**
  87322. * Define bias applied to computed fresnel term
  87323. */
  87324. bias: number;
  87325. /**
  87326. * Defined the power exponent applied to fresnel term
  87327. */
  87328. power: number;
  87329. /**
  87330. * Clones the current fresnel and its valuues
  87331. * @returns a clone fresnel configuration
  87332. */
  87333. clone(): FresnelParameters;
  87334. /**
  87335. * Serializes the current fresnel parameters to a JSON representation.
  87336. * @return the JSON serialization
  87337. */
  87338. serialize(): any;
  87339. /**
  87340. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  87341. * @param parsedFresnelParameters Define the JSON representation
  87342. * @returns the parsed parameters
  87343. */
  87344. static Parse(parsedFresnelParameters: any): FresnelParameters;
  87345. }
  87346. }
  87347. declare module BABYLON {
  87348. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  87349. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87350. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87351. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87352. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87353. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87354. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87355. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87356. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87357. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87358. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87359. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87360. /**
  87361. * Decorator used to define property that can be serialized as reference to a camera
  87362. * @param sourceName defines the name of the property to decorate
  87363. */
  87364. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87365. /**
  87366. * Class used to help serialization objects
  87367. */
  87368. export class SerializationHelper {
  87369. /** hidden */
  87370. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  87371. /** hidden */
  87372. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  87373. /** hidden */
  87374. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  87375. /** hidden */
  87376. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  87377. /**
  87378. * Appends the serialized animations from the source animations
  87379. * @param source Source containing the animations
  87380. * @param destination Target to store the animations
  87381. */
  87382. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  87383. /**
  87384. * Static function used to serialized a specific entity
  87385. * @param entity defines the entity to serialize
  87386. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  87387. * @returns a JSON compatible object representing the serialization of the entity
  87388. */
  87389. static Serialize<T>(entity: T, serializationObject?: any): any;
  87390. /**
  87391. * Creates a new entity from a serialization data object
  87392. * @param creationFunction defines a function used to instanciated the new entity
  87393. * @param source defines the source serialization data
  87394. * @param scene defines the hosting scene
  87395. * @param rootUrl defines the root url for resources
  87396. * @returns a new entity
  87397. */
  87398. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  87399. /**
  87400. * Clones an object
  87401. * @param creationFunction defines the function used to instanciate the new object
  87402. * @param source defines the source object
  87403. * @returns the cloned object
  87404. */
  87405. static Clone<T>(creationFunction: () => T, source: T): T;
  87406. /**
  87407. * Instanciates a new object based on a source one (some data will be shared between both object)
  87408. * @param creationFunction defines the function used to instanciate the new object
  87409. * @param source defines the source object
  87410. * @returns the new object
  87411. */
  87412. static Instanciate<T>(creationFunction: () => T, source: T): T;
  87413. }
  87414. }
  87415. declare module BABYLON {
  87416. /**
  87417. * This is the base class of all the camera used in the application.
  87418. * @see http://doc.babylonjs.com/features/cameras
  87419. */
  87420. export class Camera extends Node {
  87421. /** @hidden */
  87422. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  87423. /**
  87424. * This is the default projection mode used by the cameras.
  87425. * It helps recreating a feeling of perspective and better appreciate depth.
  87426. * This is the best way to simulate real life cameras.
  87427. */
  87428. static readonly PERSPECTIVE_CAMERA: number;
  87429. /**
  87430. * This helps creating camera with an orthographic mode.
  87431. * 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.
  87432. */
  87433. static readonly ORTHOGRAPHIC_CAMERA: number;
  87434. /**
  87435. * This is the default FOV mode for perspective cameras.
  87436. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  87437. */
  87438. static readonly FOVMODE_VERTICAL_FIXED: number;
  87439. /**
  87440. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  87441. */
  87442. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  87443. /**
  87444. * This specifies ther is no need for a camera rig.
  87445. * Basically only one eye is rendered corresponding to the camera.
  87446. */
  87447. static readonly RIG_MODE_NONE: number;
  87448. /**
  87449. * Simulates a camera Rig with one blue eye and one red eye.
  87450. * This can be use with 3d blue and red glasses.
  87451. */
  87452. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  87453. /**
  87454. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  87455. */
  87456. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  87457. /**
  87458. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  87459. */
  87460. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  87461. /**
  87462. * Defines that both eyes of the camera will be rendered over under each other.
  87463. */
  87464. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  87465. /**
  87466. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  87467. */
  87468. static readonly RIG_MODE_VR: number;
  87469. /**
  87470. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  87471. */
  87472. static readonly RIG_MODE_WEBVR: number;
  87473. /**
  87474. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  87475. */
  87476. static readonly RIG_MODE_CUSTOM: number;
  87477. /**
  87478. * Defines if by default attaching controls should prevent the default javascript event to continue.
  87479. */
  87480. static ForceAttachControlToAlwaysPreventDefault: boolean;
  87481. /**
  87482. * @hidden
  87483. * Might be removed once multiview will be a thing
  87484. */
  87485. static UseAlternateWebVRRendering: boolean;
  87486. /**
  87487. * Define the input manager associated with the camera.
  87488. */
  87489. inputs: CameraInputsManager<Camera>;
  87490. /** @hidden */
  87491. _position: Vector3;
  87492. /**
  87493. * Define the current local position of the camera in the scene
  87494. */
  87495. position: Vector3;
  87496. /**
  87497. * The vector the camera should consider as up.
  87498. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  87499. */
  87500. upVector: Vector3;
  87501. /**
  87502. * Define the current limit on the left side for an orthographic camera
  87503. * In scene unit
  87504. */
  87505. orthoLeft: Nullable<number>;
  87506. /**
  87507. * Define the current limit on the right side for an orthographic camera
  87508. * In scene unit
  87509. */
  87510. orthoRight: Nullable<number>;
  87511. /**
  87512. * Define the current limit on the bottom side for an orthographic camera
  87513. * In scene unit
  87514. */
  87515. orthoBottom: Nullable<number>;
  87516. /**
  87517. * Define the current limit on the top side for an orthographic camera
  87518. * In scene unit
  87519. */
  87520. orthoTop: Nullable<number>;
  87521. /**
  87522. * Field Of View is set in Radians. (default is 0.8)
  87523. */
  87524. fov: number;
  87525. /**
  87526. * Define the minimum distance the camera can see from.
  87527. * This is important to note that the depth buffer are not infinite and the closer it starts
  87528. * the more your scene might encounter depth fighting issue.
  87529. */
  87530. minZ: number;
  87531. /**
  87532. * Define the maximum distance the camera can see to.
  87533. * This is important to note that the depth buffer are not infinite and the further it end
  87534. * the more your scene might encounter depth fighting issue.
  87535. */
  87536. maxZ: number;
  87537. /**
  87538. * Define the default inertia of the camera.
  87539. * This helps giving a smooth feeling to the camera movement.
  87540. */
  87541. inertia: number;
  87542. /**
  87543. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  87544. */
  87545. mode: number;
  87546. /**
  87547. * Define wether the camera is intermediate.
  87548. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  87549. */
  87550. isIntermediate: boolean;
  87551. /**
  87552. * Define the viewport of the camera.
  87553. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  87554. */
  87555. viewport: Viewport;
  87556. /**
  87557. * Restricts the camera to viewing objects with the same layerMask.
  87558. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  87559. */
  87560. layerMask: number;
  87561. /**
  87562. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  87563. */
  87564. fovMode: number;
  87565. /**
  87566. * Rig mode of the camera.
  87567. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  87568. * This is normally controlled byt the camera themselves as internal use.
  87569. */
  87570. cameraRigMode: number;
  87571. /**
  87572. * Defines the distance between both "eyes" in case of a RIG
  87573. */
  87574. interaxialDistance: number;
  87575. /**
  87576. * Defines if stereoscopic rendering is done side by side or over under.
  87577. */
  87578. isStereoscopicSideBySide: boolean;
  87579. /**
  87580. * 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
  87581. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87582. * else in the scene.
  87583. */
  87584. customRenderTargets: RenderTargetTexture[];
  87585. /**
  87586. * When set, the camera will render to this render target instead of the default canvas
  87587. */
  87588. outputRenderTarget: Nullable<RenderTargetTexture>;
  87589. /**
  87590. * Observable triggered when the camera view matrix has changed.
  87591. */
  87592. onViewMatrixChangedObservable: Observable<Camera>;
  87593. /**
  87594. * Observable triggered when the camera Projection matrix has changed.
  87595. */
  87596. onProjectionMatrixChangedObservable: Observable<Camera>;
  87597. /**
  87598. * Observable triggered when the inputs have been processed.
  87599. */
  87600. onAfterCheckInputsObservable: Observable<Camera>;
  87601. /**
  87602. * Observable triggered when reset has been called and applied to the camera.
  87603. */
  87604. onRestoreStateObservable: Observable<Camera>;
  87605. /** @hidden */
  87606. _cameraRigParams: any;
  87607. /** @hidden */
  87608. _rigCameras: Camera[];
  87609. /** @hidden */
  87610. _rigPostProcess: Nullable<PostProcess>;
  87611. protected _webvrViewMatrix: Matrix;
  87612. /** @hidden */
  87613. _skipRendering: boolean;
  87614. /** @hidden */
  87615. _alternateCamera: Camera;
  87616. /** @hidden */
  87617. _projectionMatrix: Matrix;
  87618. /** @hidden */
  87619. _postProcesses: Nullable<PostProcess>[];
  87620. /** @hidden */
  87621. _activeMeshes: SmartArray<AbstractMesh>;
  87622. protected _globalPosition: Vector3;
  87623. /** hidden */
  87624. _computedViewMatrix: Matrix;
  87625. private _doNotComputeProjectionMatrix;
  87626. private _transformMatrix;
  87627. private _frustumPlanes;
  87628. private _refreshFrustumPlanes;
  87629. private _storedFov;
  87630. private _stateStored;
  87631. /**
  87632. * Instantiates a new camera object.
  87633. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87634. * @see http://doc.babylonjs.com/features/cameras
  87635. * @param name Defines the name of the camera in the scene
  87636. * @param position Defines the position of the camera
  87637. * @param scene Defines the scene the camera belongs too
  87638. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87639. */
  87640. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87641. /**
  87642. * Store current camera state (fov, position, etc..)
  87643. * @returns the camera
  87644. */
  87645. storeState(): Camera;
  87646. /**
  87647. * Restores the camera state values if it has been stored. You must call storeState() first
  87648. */
  87649. protected _restoreStateValues(): boolean;
  87650. /**
  87651. * Restored camera state. You must call storeState() first.
  87652. * @returns true if restored and false otherwise
  87653. */
  87654. restoreState(): boolean;
  87655. /**
  87656. * Gets the class name of the camera.
  87657. * @returns the class name
  87658. */
  87659. getClassName(): string;
  87660. /** @hidden */
  87661. readonly _isCamera: boolean;
  87662. /**
  87663. * Gets a string representation of the camera useful for debug purpose.
  87664. * @param fullDetails Defines that a more verboe level of logging is required
  87665. * @returns the string representation
  87666. */
  87667. toString(fullDetails?: boolean): string;
  87668. /**
  87669. * Gets the current world space position of the camera.
  87670. */
  87671. readonly globalPosition: Vector3;
  87672. /**
  87673. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87674. * @returns the active meshe list
  87675. */
  87676. getActiveMeshes(): SmartArray<AbstractMesh>;
  87677. /**
  87678. * Check wether a mesh is part of the current active mesh list of the camera
  87679. * @param mesh Defines the mesh to check
  87680. * @returns true if active, false otherwise
  87681. */
  87682. isActiveMesh(mesh: Mesh): boolean;
  87683. /**
  87684. * Is this camera ready to be used/rendered
  87685. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87686. * @return true if the camera is ready
  87687. */
  87688. isReady(completeCheck?: boolean): boolean;
  87689. /** @hidden */
  87690. _initCache(): void;
  87691. /** @hidden */
  87692. _updateCache(ignoreParentClass?: boolean): void;
  87693. /** @hidden */
  87694. _isSynchronized(): boolean;
  87695. /** @hidden */
  87696. _isSynchronizedViewMatrix(): boolean;
  87697. /** @hidden */
  87698. _isSynchronizedProjectionMatrix(): boolean;
  87699. /**
  87700. * Attach the input controls to a specific dom element to get the input from.
  87701. * @param element Defines the element the controls should be listened from
  87702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87703. */
  87704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87705. /**
  87706. * Detach the current controls from the specified dom element.
  87707. * @param element Defines the element to stop listening the inputs from
  87708. */
  87709. detachControl(element: HTMLElement): void;
  87710. /**
  87711. * Update the camera state according to the different inputs gathered during the frame.
  87712. */
  87713. update(): void;
  87714. /** @hidden */
  87715. _checkInputs(): void;
  87716. /** @hidden */
  87717. readonly rigCameras: Camera[];
  87718. /**
  87719. * Gets the post process used by the rig cameras
  87720. */
  87721. readonly rigPostProcess: Nullable<PostProcess>;
  87722. /**
  87723. * Internal, gets the first post proces.
  87724. * @returns the first post process to be run on this camera.
  87725. */
  87726. _getFirstPostProcess(): Nullable<PostProcess>;
  87727. private _cascadePostProcessesToRigCams;
  87728. /**
  87729. * Attach a post process to the camera.
  87730. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87731. * @param postProcess The post process to attach to the camera
  87732. * @param insertAt The position of the post process in case several of them are in use in the scene
  87733. * @returns the position the post process has been inserted at
  87734. */
  87735. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87736. /**
  87737. * Detach a post process to the camera.
  87738. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87739. * @param postProcess The post process to detach from the camera
  87740. */
  87741. detachPostProcess(postProcess: PostProcess): void;
  87742. /**
  87743. * Gets the current world matrix of the camera
  87744. */
  87745. getWorldMatrix(): Matrix;
  87746. /** @hidden */
  87747. _getViewMatrix(): Matrix;
  87748. /**
  87749. * Gets the current view matrix of the camera.
  87750. * @param force forces the camera to recompute the matrix without looking at the cached state
  87751. * @returns the view matrix
  87752. */
  87753. getViewMatrix(force?: boolean): Matrix;
  87754. /**
  87755. * Freeze the projection matrix.
  87756. * It will prevent the cache check of the camera projection compute and can speed up perf
  87757. * if no parameter of the camera are meant to change
  87758. * @param projection Defines manually a projection if necessary
  87759. */
  87760. freezeProjectionMatrix(projection?: Matrix): void;
  87761. /**
  87762. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87763. */
  87764. unfreezeProjectionMatrix(): void;
  87765. /**
  87766. * Gets the current projection matrix of the camera.
  87767. * @param force forces the camera to recompute the matrix without looking at the cached state
  87768. * @returns the projection matrix
  87769. */
  87770. getProjectionMatrix(force?: boolean): Matrix;
  87771. /**
  87772. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87773. * @returns a Matrix
  87774. */
  87775. getTransformationMatrix(): Matrix;
  87776. private _updateFrustumPlanes;
  87777. /**
  87778. * Checks if a cullable object (mesh...) is in the camera frustum
  87779. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87780. * @param target The object to check
  87781. * @returns true if the object is in frustum otherwise false
  87782. */
  87783. isInFrustum(target: ICullable): boolean;
  87784. /**
  87785. * Checks if a cullable object (mesh...) is in the camera frustum
  87786. * Unlike isInFrustum this cheks the full bounding box
  87787. * @param target The object to check
  87788. * @returns true if the object is in frustum otherwise false
  87789. */
  87790. isCompletelyInFrustum(target: ICullable): boolean;
  87791. /**
  87792. * Gets a ray in the forward direction from the camera.
  87793. * @param length Defines the length of the ray to create
  87794. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87795. * @param origin Defines the start point of the ray which defaults to the camera position
  87796. * @returns the forward ray
  87797. */
  87798. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87799. /**
  87800. * Releases resources associated with this node.
  87801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87803. */
  87804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87805. /** @hidden */
  87806. _isLeftCamera: boolean;
  87807. /**
  87808. * Gets the left camera of a rig setup in case of Rigged Camera
  87809. */
  87810. readonly isLeftCamera: boolean;
  87811. /** @hidden */
  87812. _isRightCamera: boolean;
  87813. /**
  87814. * Gets the right camera of a rig setup in case of Rigged Camera
  87815. */
  87816. readonly isRightCamera: boolean;
  87817. /**
  87818. * Gets the left camera of a rig setup in case of Rigged Camera
  87819. */
  87820. readonly leftCamera: Nullable<FreeCamera>;
  87821. /**
  87822. * Gets the right camera of a rig setup in case of Rigged Camera
  87823. */
  87824. readonly rightCamera: Nullable<FreeCamera>;
  87825. /**
  87826. * Gets the left camera target of a rig setup in case of Rigged Camera
  87827. * @returns the target position
  87828. */
  87829. getLeftTarget(): Nullable<Vector3>;
  87830. /**
  87831. * Gets the right camera target of a rig setup in case of Rigged Camera
  87832. * @returns the target position
  87833. */
  87834. getRightTarget(): Nullable<Vector3>;
  87835. /**
  87836. * @hidden
  87837. */
  87838. setCameraRigMode(mode: number, rigParams: any): void;
  87839. /** @hidden */
  87840. static _setStereoscopicRigMode(camera: Camera): void;
  87841. /** @hidden */
  87842. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87843. /** @hidden */
  87844. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87845. /** @hidden */
  87846. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87847. /** @hidden */
  87848. _getVRProjectionMatrix(): Matrix;
  87849. protected _updateCameraRotationMatrix(): void;
  87850. protected _updateWebVRCameraRotationMatrix(): void;
  87851. /**
  87852. * This function MUST be overwritten by the different WebVR cameras available.
  87853. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87854. * @hidden
  87855. */
  87856. _getWebVRProjectionMatrix(): Matrix;
  87857. /**
  87858. * This function MUST be overwritten by the different WebVR cameras available.
  87859. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87860. * @hidden
  87861. */
  87862. _getWebVRViewMatrix(): Matrix;
  87863. /** @hidden */
  87864. setCameraRigParameter(name: string, value: any): void;
  87865. /**
  87866. * needs to be overridden by children so sub has required properties to be copied
  87867. * @hidden
  87868. */
  87869. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87870. /**
  87871. * May need to be overridden by children
  87872. * @hidden
  87873. */
  87874. _updateRigCameras(): void;
  87875. /** @hidden */
  87876. _setupInputs(): void;
  87877. /**
  87878. * Serialiaze the camera setup to a json represention
  87879. * @returns the JSON representation
  87880. */
  87881. serialize(): any;
  87882. /**
  87883. * Clones the current camera.
  87884. * @param name The cloned camera name
  87885. * @returns the cloned camera
  87886. */
  87887. clone(name: string): Camera;
  87888. /**
  87889. * Gets the direction of the camera relative to a given local axis.
  87890. * @param localAxis Defines the reference axis to provide a relative direction.
  87891. * @return the direction
  87892. */
  87893. getDirection(localAxis: Vector3): Vector3;
  87894. /**
  87895. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87896. * @param localAxis Defines the reference axis to provide a relative direction.
  87897. * @param result Defines the vector to store the result in
  87898. */
  87899. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87900. /**
  87901. * Gets a camera constructor for a given camera type
  87902. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87903. * @param name The name of the camera the result will be able to instantiate
  87904. * @param scene The scene the result will construct the camera in
  87905. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87906. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87907. * @returns a factory method to construc the camera
  87908. */
  87909. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87910. /**
  87911. * Compute the world matrix of the camera.
  87912. * @returns the camera workd matrix
  87913. */
  87914. computeWorldMatrix(): Matrix;
  87915. /**
  87916. * Parse a JSON and creates the camera from the parsed information
  87917. * @param parsedCamera The JSON to parse
  87918. * @param scene The scene to instantiate the camera in
  87919. * @returns the newly constructed camera
  87920. */
  87921. static Parse(parsedCamera: any, scene: Scene): Camera;
  87922. }
  87923. }
  87924. declare module BABYLON {
  87925. /**
  87926. * Interface for any object that can request an animation frame
  87927. */
  87928. export interface ICustomAnimationFrameRequester {
  87929. /**
  87930. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87931. */
  87932. renderFunction?: Function;
  87933. /**
  87934. * Called to request the next frame to render to
  87935. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87936. */
  87937. requestAnimationFrame: Function;
  87938. /**
  87939. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87940. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87941. */
  87942. requestID?: number;
  87943. }
  87944. /**
  87945. * Interface containing an array of animations
  87946. */
  87947. export interface IAnimatable {
  87948. /**
  87949. * Array of animations
  87950. */
  87951. animations: Array<Animation>;
  87952. }
  87953. /** Interface used by value gradients (color, factor, ...) */
  87954. export interface IValueGradient {
  87955. /**
  87956. * Gets or sets the gradient value (between 0 and 1)
  87957. */
  87958. gradient: number;
  87959. }
  87960. /** Class used to store color4 gradient */
  87961. export class ColorGradient implements IValueGradient {
  87962. /**
  87963. * Gets or sets the gradient value (between 0 and 1)
  87964. */
  87965. gradient: number;
  87966. /**
  87967. * Gets or sets first associated color
  87968. */
  87969. color1: Color4;
  87970. /**
  87971. * Gets or sets second associated color
  87972. */
  87973. color2?: Color4;
  87974. /**
  87975. * Will get a color picked randomly between color1 and color2.
  87976. * If color2 is undefined then color1 will be used
  87977. * @param result defines the target Color4 to store the result in
  87978. */
  87979. getColorToRef(result: Color4): void;
  87980. }
  87981. /** Class used to store color 3 gradient */
  87982. export class Color3Gradient implements IValueGradient {
  87983. /**
  87984. * Gets or sets the gradient value (between 0 and 1)
  87985. */
  87986. gradient: number;
  87987. /**
  87988. * Gets or sets the associated color
  87989. */
  87990. color: Color3;
  87991. }
  87992. /** Class used to store factor gradient */
  87993. export class FactorGradient implements IValueGradient {
  87994. /**
  87995. * Gets or sets the gradient value (between 0 and 1)
  87996. */
  87997. gradient: number;
  87998. /**
  87999. * Gets or sets first associated factor
  88000. */
  88001. factor1: number;
  88002. /**
  88003. * Gets or sets second associated factor
  88004. */
  88005. factor2?: number;
  88006. /**
  88007. * Will get a number picked randomly between factor1 and factor2.
  88008. * If factor2 is undefined then factor1 will be used
  88009. * @returns the picked number
  88010. */
  88011. getFactor(): number;
  88012. }
  88013. /**
  88014. * @ignore
  88015. * Application error to support additional information when loading a file
  88016. */
  88017. export class LoadFileError extends Error {
  88018. /** defines the optional web request */
  88019. request?: WebRequest | undefined;
  88020. private static _setPrototypeOf;
  88021. /**
  88022. * Creates a new LoadFileError
  88023. * @param message defines the message of the error
  88024. * @param request defines the optional web request
  88025. */
  88026. constructor(message: string,
  88027. /** defines the optional web request */
  88028. request?: WebRequest | undefined);
  88029. }
  88030. /**
  88031. * Class used to define a retry strategy when error happens while loading assets
  88032. */
  88033. export class RetryStrategy {
  88034. /**
  88035. * Function used to defines an exponential back off strategy
  88036. * @param maxRetries defines the maximum number of retries (3 by default)
  88037. * @param baseInterval defines the interval between retries
  88038. * @returns the strategy function to use
  88039. */
  88040. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  88041. }
  88042. /**
  88043. * File request interface
  88044. */
  88045. export interface IFileRequest {
  88046. /**
  88047. * Raised when the request is complete (success or error).
  88048. */
  88049. onCompleteObservable: Observable<IFileRequest>;
  88050. /**
  88051. * Aborts the request for a file.
  88052. */
  88053. abort: () => void;
  88054. }
  88055. /**
  88056. * Class containing a set of static utilities functions
  88057. */
  88058. export class Tools {
  88059. /**
  88060. * Gets or sets the base URL to use to load assets
  88061. */
  88062. static BaseUrl: string;
  88063. /**
  88064. * Enable/Disable Custom HTTP Request Headers globally.
  88065. * default = false
  88066. * @see CustomRequestHeaders
  88067. */
  88068. static UseCustomRequestHeaders: boolean;
  88069. /**
  88070. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  88071. * i.e. when loading files, where the server/service expects an Authorization header
  88072. */
  88073. static CustomRequestHeaders: {
  88074. [key: string]: string;
  88075. };
  88076. /**
  88077. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  88078. */
  88079. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  88080. /**
  88081. * Default behaviour for cors in the application.
  88082. * It can be a string if the expected behavior is identical in the entire app.
  88083. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  88084. */
  88085. static CorsBehavior: string | ((url: string | string[]) => string);
  88086. /**
  88087. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  88088. * @ignorenaming
  88089. */
  88090. static UseFallbackTexture: boolean;
  88091. /**
  88092. * Use this object to register external classes like custom textures or material
  88093. * to allow the laoders to instantiate them
  88094. */
  88095. static RegisteredExternalClasses: {
  88096. [key: string]: Object;
  88097. };
  88098. /**
  88099. * Texture content used if a texture cannot loaded
  88100. * @ignorenaming
  88101. */
  88102. static fallbackTexture: string;
  88103. /**
  88104. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  88105. * @param u defines the coordinate on X axis
  88106. * @param v defines the coordinate on Y axis
  88107. * @param width defines the width of the source data
  88108. * @param height defines the height of the source data
  88109. * @param pixels defines the source byte array
  88110. * @param color defines the output color
  88111. */
  88112. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  88113. /**
  88114. * Interpolates between a and b via alpha
  88115. * @param a The lower value (returned when alpha = 0)
  88116. * @param b The upper value (returned when alpha = 1)
  88117. * @param alpha The interpolation-factor
  88118. * @return The mixed value
  88119. */
  88120. static Mix(a: number, b: number, alpha: number): number;
  88121. /**
  88122. * Tries to instantiate a new object from a given class name
  88123. * @param className defines the class name to instantiate
  88124. * @returns the new object or null if the system was not able to do the instantiation
  88125. */
  88126. static Instantiate(className: string): any;
  88127. /**
  88128. * Provides a slice function that will work even on IE
  88129. * @param data defines the array to slice
  88130. * @param start defines the start of the data (optional)
  88131. * @param end defines the end of the data (optional)
  88132. * @returns the new sliced array
  88133. */
  88134. static Slice<T>(data: T, start?: number, end?: number): T;
  88135. /**
  88136. * Polyfill for setImmediate
  88137. * @param action defines the action to execute after the current execution block
  88138. */
  88139. static SetImmediate(action: () => void): void;
  88140. /**
  88141. * Function indicating if a number is an exponent of 2
  88142. * @param value defines the value to test
  88143. * @returns true if the value is an exponent of 2
  88144. */
  88145. static IsExponentOfTwo(value: number): boolean;
  88146. private static _tmpFloatArray;
  88147. /**
  88148. * Returns the nearest 32-bit single precision float representation of a Number
  88149. * @param value A Number. If the parameter is of a different type, it will get converted
  88150. * to a number or to NaN if it cannot be converted
  88151. * @returns number
  88152. */
  88153. static FloatRound(value: number): number;
  88154. /**
  88155. * Find the next highest power of two.
  88156. * @param x Number to start search from.
  88157. * @return Next highest power of two.
  88158. */
  88159. static CeilingPOT(x: number): number;
  88160. /**
  88161. * Find the next lowest power of two.
  88162. * @param x Number to start search from.
  88163. * @return Next lowest power of two.
  88164. */
  88165. static FloorPOT(x: number): number;
  88166. /**
  88167. * Find the nearest power of two.
  88168. * @param x Number to start search from.
  88169. * @return Next nearest power of two.
  88170. */
  88171. static NearestPOT(x: number): number;
  88172. /**
  88173. * Get the closest exponent of two
  88174. * @param value defines the value to approximate
  88175. * @param max defines the maximum value to return
  88176. * @param mode defines how to define the closest value
  88177. * @returns closest exponent of two of the given value
  88178. */
  88179. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  88180. /**
  88181. * Extracts the filename from a path
  88182. * @param path defines the path to use
  88183. * @returns the filename
  88184. */
  88185. static GetFilename(path: string): string;
  88186. /**
  88187. * Extracts the "folder" part of a path (everything before the filename).
  88188. * @param uri The URI to extract the info from
  88189. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  88190. * @returns The "folder" part of the path
  88191. */
  88192. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  88193. /**
  88194. * Extracts text content from a DOM element hierarchy
  88195. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  88196. */
  88197. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  88198. /**
  88199. * Convert an angle in radians to degrees
  88200. * @param angle defines the angle to convert
  88201. * @returns the angle in degrees
  88202. */
  88203. static ToDegrees(angle: number): number;
  88204. /**
  88205. * Convert an angle in degrees to radians
  88206. * @param angle defines the angle to convert
  88207. * @returns the angle in radians
  88208. */
  88209. static ToRadians(angle: number): number;
  88210. /**
  88211. * Encode a buffer to a base64 string
  88212. * @param buffer defines the buffer to encode
  88213. * @returns the encoded string
  88214. */
  88215. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  88216. /**
  88217. * Extracts minimum and maximum values from a list of indexed positions
  88218. * @param positions defines the positions to use
  88219. * @param indices defines the indices to the positions
  88220. * @param indexStart defines the start index
  88221. * @param indexCount defines the end index
  88222. * @param bias defines bias value to add to the result
  88223. * @return minimum and maximum values
  88224. */
  88225. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88226. minimum: Vector3;
  88227. maximum: Vector3;
  88228. };
  88229. /**
  88230. * Extracts minimum and maximum values from a list of positions
  88231. * @param positions defines the positions to use
  88232. * @param start defines the start index in the positions array
  88233. * @param count defines the number of positions to handle
  88234. * @param bias defines bias value to add to the result
  88235. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88236. * @return minimum and maximum values
  88237. */
  88238. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88239. minimum: Vector3;
  88240. maximum: Vector3;
  88241. };
  88242. /**
  88243. * Returns an array if obj is not an array
  88244. * @param obj defines the object to evaluate as an array
  88245. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  88246. * @returns either obj directly if obj is an array or a new array containing obj
  88247. */
  88248. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  88249. /**
  88250. * Gets the pointer prefix to use
  88251. * @returns "pointer" if touch is enabled. Else returns "mouse"
  88252. */
  88253. static GetPointerPrefix(): string;
  88254. /**
  88255. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  88256. * @param func - the function to be called
  88257. * @param requester - the object that will request the next frame. Falls back to window.
  88258. * @returns frame number
  88259. */
  88260. static QueueNewFrame(func: () => void, requester?: any): number;
  88261. /**
  88262. * Ask the browser to promote the current element to fullscreen rendering mode
  88263. * @param element defines the DOM element to promote
  88264. */
  88265. static RequestFullscreen(element: HTMLElement): void;
  88266. /**
  88267. * Asks the browser to exit fullscreen mode
  88268. */
  88269. static ExitFullscreen(): void;
  88270. /**
  88271. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  88272. * @param url define the url we are trying
  88273. * @param element define the dom element where to configure the cors policy
  88274. */
  88275. static SetCorsBehavior(url: string | string[], element: {
  88276. crossOrigin: string | null;
  88277. }): void;
  88278. /**
  88279. * Removes unwanted characters from an url
  88280. * @param url defines the url to clean
  88281. * @returns the cleaned url
  88282. */
  88283. static CleanUrl(url: string): string;
  88284. /**
  88285. * Gets or sets a function used to pre-process url before using them to load assets
  88286. */
  88287. static PreprocessUrl: (url: string) => string;
  88288. /**
  88289. * Loads an image as an HTMLImageElement.
  88290. * @param input url string, ArrayBuffer, or Blob to load
  88291. * @param onLoad callback called when the image successfully loads
  88292. * @param onError callback called when the image fails to load
  88293. * @param offlineProvider offline provider for caching
  88294. * @returns the HTMLImageElement of the loaded image
  88295. */
  88296. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  88297. /**
  88298. * Loads a file
  88299. * @param url url string, ArrayBuffer, or Blob to load
  88300. * @param onSuccess callback called when the file successfully loads
  88301. * @param onProgress callback called while file is loading (if the server supports this mode)
  88302. * @param offlineProvider defines the offline provider for caching
  88303. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  88304. * @param onError callback called when the file fails to load
  88305. * @returns a file request object
  88306. */
  88307. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  88308. /**
  88309. * Load a script (identified by an url). When the url returns, the
  88310. * content of this file is added into a new script element, attached to the DOM (body element)
  88311. * @param scriptUrl defines the url of the script to laod
  88312. * @param onSuccess defines the callback called when the script is loaded
  88313. * @param onError defines the callback to call if an error occurs
  88314. */
  88315. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  88316. /**
  88317. * Loads a file from a blob
  88318. * @param fileToLoad defines the blob to use
  88319. * @param callback defines the callback to call when data is loaded
  88320. * @param progressCallback defines the callback to call during loading process
  88321. * @returns a file request object
  88322. */
  88323. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  88324. /**
  88325. * Loads a file
  88326. * @param fileToLoad defines the file to load
  88327. * @param callback defines the callback to call when data is loaded
  88328. * @param progressCallBack defines the callback to call during loading process
  88329. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  88330. * @returns a file request object
  88331. */
  88332. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  88333. /**
  88334. * Creates a data url from a given string content
  88335. * @param content defines the content to convert
  88336. * @returns the new data url link
  88337. */
  88338. static FileAsURL(content: string): string;
  88339. /**
  88340. * Format the given number to a specific decimal format
  88341. * @param value defines the number to format
  88342. * @param decimals defines the number of decimals to use
  88343. * @returns the formatted string
  88344. */
  88345. static Format(value: number, decimals?: number): string;
  88346. /**
  88347. * Checks if a given vector is inside a specific range
  88348. * @param v defines the vector to test
  88349. * @param min defines the minimum range
  88350. * @param max defines the maximum range
  88351. */
  88352. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88353. /**
  88354. * Tries to copy an object by duplicating every property
  88355. * @param source defines the source object
  88356. * @param destination defines the target object
  88357. * @param doNotCopyList defines a list of properties to avoid
  88358. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  88359. */
  88360. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  88361. /**
  88362. * Gets a boolean indicating if the given object has no own property
  88363. * @param obj defines the object to test
  88364. * @returns true if object has no own property
  88365. */
  88366. static IsEmpty(obj: any): boolean;
  88367. /**
  88368. * Function used to register events at window level
  88369. * @param events defines the events to register
  88370. */
  88371. static RegisterTopRootEvents(events: {
  88372. name: string;
  88373. handler: Nullable<(e: FocusEvent) => any>;
  88374. }[]): void;
  88375. /**
  88376. * Function used to unregister events from window level
  88377. * @param events defines the events to unregister
  88378. */
  88379. static UnregisterTopRootEvents(events: {
  88380. name: string;
  88381. handler: Nullable<(e: FocusEvent) => any>;
  88382. }[]): void;
  88383. /**
  88384. * @ignore
  88385. */
  88386. static _ScreenshotCanvas: HTMLCanvasElement;
  88387. /**
  88388. * Dumps the current bound framebuffer
  88389. * @param width defines the rendering width
  88390. * @param height defines the rendering height
  88391. * @param engine defines the hosting engine
  88392. * @param successCallback defines the callback triggered once the data are available
  88393. * @param mimeType defines the mime type of the result
  88394. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  88395. */
  88396. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88397. /**
  88398. * Converts the canvas data to blob.
  88399. * This acts as a polyfill for browsers not supporting the to blob function.
  88400. * @param canvas Defines the canvas to extract the data from
  88401. * @param successCallback Defines the callback triggered once the data are available
  88402. * @param mimeType Defines the mime type of the result
  88403. */
  88404. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  88405. /**
  88406. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  88407. * @param successCallback defines the callback triggered once the data are available
  88408. * @param mimeType defines the mime type of the result
  88409. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  88410. */
  88411. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88412. /**
  88413. * Downloads a blob in the browser
  88414. * @param blob defines the blob to download
  88415. * @param fileName defines the name of the downloaded file
  88416. */
  88417. static Download(blob: Blob, fileName: string): void;
  88418. /**
  88419. * Captures a screenshot of the current rendering
  88420. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88421. * @param engine defines the rendering engine
  88422. * @param camera defines the source camera
  88423. * @param size This parameter can be set to a single number or to an object with the
  88424. * following (optional) properties: precision, width, height. If a single number is passed,
  88425. * it will be used for both width and height. If an object is passed, the screenshot size
  88426. * will be derived from the parameters. The precision property is a multiplier allowing
  88427. * rendering at a higher or lower resolution
  88428. * @param successCallback defines the callback receives a single parameter which contains the
  88429. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88430. * src parameter of an <img> to display it
  88431. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  88432. * Check your browser for supported MIME types
  88433. */
  88434. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  88435. /**
  88436. * Generates an image screenshot from the specified camera.
  88437. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88438. * @param engine The engine to use for rendering
  88439. * @param camera The camera to use for rendering
  88440. * @param size This parameter can be set to a single number or to an object with the
  88441. * following (optional) properties: precision, width, height. If a single number is passed,
  88442. * it will be used for both width and height. If an object is passed, the screenshot size
  88443. * will be derived from the parameters. The precision property is a multiplier allowing
  88444. * rendering at a higher or lower resolution
  88445. * @param successCallback The callback receives a single parameter which contains the
  88446. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88447. * src parameter of an <img> to display it
  88448. * @param mimeType The MIME type of the screenshot image (default: image/png).
  88449. * Check your browser for supported MIME types
  88450. * @param samples Texture samples (default: 1)
  88451. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  88452. * @param fileName A name for for the downloaded file.
  88453. */
  88454. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  88455. /**
  88456. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88457. * Be aware Math.random() could cause collisions, but:
  88458. * "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"
  88459. * @returns a pseudo random id
  88460. */
  88461. static RandomId(): string;
  88462. /**
  88463. * Test if the given uri is a base64 string
  88464. * @param uri The uri to test
  88465. * @return True if the uri is a base64 string or false otherwise
  88466. */
  88467. static IsBase64(uri: string): boolean;
  88468. /**
  88469. * Decode the given base64 uri.
  88470. * @param uri The uri to decode
  88471. * @return The decoded base64 data.
  88472. */
  88473. static DecodeBase64(uri: string): ArrayBuffer;
  88474. /**
  88475. * No log
  88476. */
  88477. static readonly NoneLogLevel: number;
  88478. /**
  88479. * Only message logs
  88480. */
  88481. static readonly MessageLogLevel: number;
  88482. /**
  88483. * Only warning logs
  88484. */
  88485. static readonly WarningLogLevel: number;
  88486. /**
  88487. * Only error logs
  88488. */
  88489. static readonly ErrorLogLevel: number;
  88490. /**
  88491. * All logs
  88492. */
  88493. static readonly AllLogLevel: number;
  88494. /**
  88495. * Gets a value indicating the number of loading errors
  88496. * @ignorenaming
  88497. */
  88498. static readonly errorsCount: number;
  88499. /**
  88500. * Callback called when a new log is added
  88501. */
  88502. static OnNewCacheEntry: (entry: string) => void;
  88503. /**
  88504. * Log a message to the console
  88505. * @param message defines the message to log
  88506. */
  88507. static Log(message: string): void;
  88508. /**
  88509. * Write a warning message to the console
  88510. * @param message defines the message to log
  88511. */
  88512. static Warn(message: string): void;
  88513. /**
  88514. * Write an error message to the console
  88515. * @param message defines the message to log
  88516. */
  88517. static Error(message: string): void;
  88518. /**
  88519. * Gets current log cache (list of logs)
  88520. */
  88521. static readonly LogCache: string;
  88522. /**
  88523. * Clears the log cache
  88524. */
  88525. static ClearLogCache(): void;
  88526. /**
  88527. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  88528. */
  88529. static LogLevels: number;
  88530. /**
  88531. * Checks if the loaded document was accessed via `file:`-Protocol.
  88532. * @returns boolean
  88533. */
  88534. static IsFileURL(): boolean;
  88535. /**
  88536. * Checks if the window object exists
  88537. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  88538. */
  88539. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  88540. /**
  88541. * No performance log
  88542. */
  88543. static readonly PerformanceNoneLogLevel: number;
  88544. /**
  88545. * Use user marks to log performance
  88546. */
  88547. static readonly PerformanceUserMarkLogLevel: number;
  88548. /**
  88549. * Log performance to the console
  88550. */
  88551. static readonly PerformanceConsoleLogLevel: number;
  88552. private static _performance;
  88553. /**
  88554. * Sets the current performance log level
  88555. */
  88556. static PerformanceLogLevel: number;
  88557. private static _StartPerformanceCounterDisabled;
  88558. private static _EndPerformanceCounterDisabled;
  88559. private static _StartUserMark;
  88560. private static _EndUserMark;
  88561. private static _StartPerformanceConsole;
  88562. private static _EndPerformanceConsole;
  88563. /**
  88564. * Starts a performance counter
  88565. */
  88566. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88567. /**
  88568. * Ends a specific performance coutner
  88569. */
  88570. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88571. /**
  88572. * Gets either window.performance.now() if supported or Date.now() else
  88573. */
  88574. static readonly Now: number;
  88575. /**
  88576. * This method will return the name of the class used to create the instance of the given object.
  88577. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  88578. * @param object the object to get the class name from
  88579. * @param isType defines if the object is actually a type
  88580. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88581. */
  88582. static GetClassName(object: any, isType?: boolean): string;
  88583. /**
  88584. * Gets the first element of an array satisfying a given predicate
  88585. * @param array defines the array to browse
  88586. * @param predicate defines the predicate to use
  88587. * @returns null if not found or the element
  88588. */
  88589. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88590. /**
  88591. * This method will return the name of the full name of the class, including its owning module (if any).
  88592. * 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).
  88593. * @param object the object to get the class name from
  88594. * @param isType defines if the object is actually a type
  88595. * @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.
  88596. * @ignorenaming
  88597. */
  88598. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88599. /**
  88600. * Returns a promise that resolves after the given amount of time.
  88601. * @param delay Number of milliseconds to delay
  88602. * @returns Promise that resolves after the given amount of time
  88603. */
  88604. static DelayAsync(delay: number): Promise<void>;
  88605. /**
  88606. * Gets the current gradient from an array of IValueGradient
  88607. * @param ratio defines the current ratio to get
  88608. * @param gradients defines the array of IValueGradient
  88609. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88610. */
  88611. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88612. }
  88613. /**
  88614. * This class is used to track a performance counter which is number based.
  88615. * The user has access to many properties which give statistics of different nature.
  88616. *
  88617. * The implementer can track two kinds of Performance Counter: time and count.
  88618. * 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.
  88619. * 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.
  88620. */
  88621. export class PerfCounter {
  88622. /**
  88623. * Gets or sets a global boolean to turn on and off all the counters
  88624. */
  88625. static Enabled: boolean;
  88626. /**
  88627. * Returns the smallest value ever
  88628. */
  88629. readonly min: number;
  88630. /**
  88631. * Returns the biggest value ever
  88632. */
  88633. readonly max: number;
  88634. /**
  88635. * Returns the average value since the performance counter is running
  88636. */
  88637. readonly average: number;
  88638. /**
  88639. * Returns the average value of the last second the counter was monitored
  88640. */
  88641. readonly lastSecAverage: number;
  88642. /**
  88643. * Returns the current value
  88644. */
  88645. readonly current: number;
  88646. /**
  88647. * Gets the accumulated total
  88648. */
  88649. readonly total: number;
  88650. /**
  88651. * Gets the total value count
  88652. */
  88653. readonly count: number;
  88654. /**
  88655. * Creates a new counter
  88656. */
  88657. constructor();
  88658. /**
  88659. * Call this method to start monitoring a new frame.
  88660. * 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.
  88661. */
  88662. fetchNewFrame(): void;
  88663. /**
  88664. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88665. * @param newCount the count value to add to the monitored count
  88666. * @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.
  88667. */
  88668. addCount(newCount: number, fetchResult: boolean): void;
  88669. /**
  88670. * Start monitoring this performance counter
  88671. */
  88672. beginMonitoring(): void;
  88673. /**
  88674. * Compute the time lapsed since the previous beginMonitoring() call.
  88675. * @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
  88676. */
  88677. endMonitoring(newFrame?: boolean): void;
  88678. private _fetchResult;
  88679. private _startMonitoringTime;
  88680. private _min;
  88681. private _max;
  88682. private _average;
  88683. private _current;
  88684. private _totalValueCount;
  88685. private _totalAccumulated;
  88686. private _lastSecAverage;
  88687. private _lastSecAccumulated;
  88688. private _lastSecTime;
  88689. private _lastSecValueCount;
  88690. }
  88691. /**
  88692. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88693. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88694. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88695. * @param name The name of the class, case should be preserved
  88696. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88697. */
  88698. export function className(name: string, module?: string): (target: Object) => void;
  88699. /**
  88700. * An implementation of a loop for asynchronous functions.
  88701. */
  88702. export class AsyncLoop {
  88703. /**
  88704. * Defines the number of iterations for the loop
  88705. */
  88706. iterations: number;
  88707. /**
  88708. * Defines the current index of the loop.
  88709. */
  88710. index: number;
  88711. private _done;
  88712. private _fn;
  88713. private _successCallback;
  88714. /**
  88715. * Constructor.
  88716. * @param iterations the number of iterations.
  88717. * @param func the function to run each iteration
  88718. * @param successCallback the callback that will be called upon succesful execution
  88719. * @param offset starting offset.
  88720. */
  88721. constructor(
  88722. /**
  88723. * Defines the number of iterations for the loop
  88724. */
  88725. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88726. /**
  88727. * Execute the next iteration. Must be called after the last iteration was finished.
  88728. */
  88729. executeNext(): void;
  88730. /**
  88731. * Break the loop and run the success callback.
  88732. */
  88733. breakLoop(): void;
  88734. /**
  88735. * Create and run an async loop.
  88736. * @param iterations the number of iterations.
  88737. * @param fn the function to run each iteration
  88738. * @param successCallback the callback that will be called upon succesful execution
  88739. * @param offset starting offset.
  88740. * @returns the created async loop object
  88741. */
  88742. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88743. /**
  88744. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88745. * @param iterations total number of iterations
  88746. * @param syncedIterations number of synchronous iterations in each async iteration.
  88747. * @param fn the function to call each iteration.
  88748. * @param callback a success call back that will be called when iterating stops.
  88749. * @param breakFunction a break condition (optional)
  88750. * @param timeout timeout settings for the setTimeout function. default - 0.
  88751. * @returns the created async loop object
  88752. */
  88753. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88754. }
  88755. }
  88756. declare module BABYLON {
  88757. /** @hidden */
  88758. export interface ICollisionCoordinator {
  88759. createCollider(): Collider;
  88760. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88761. init(scene: Scene): void;
  88762. }
  88763. /** @hidden */
  88764. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88765. private _scene;
  88766. private _scaledPosition;
  88767. private _scaledVelocity;
  88768. private _finalPosition;
  88769. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88770. createCollider(): Collider;
  88771. init(scene: Scene): void;
  88772. private _collideWithWorld;
  88773. }
  88774. }
  88775. declare module BABYLON {
  88776. /**
  88777. * This class defines the direct association between an animation and a target
  88778. */
  88779. export class TargetedAnimation {
  88780. /**
  88781. * Animation to perform
  88782. */
  88783. animation: Animation;
  88784. /**
  88785. * Target to animate
  88786. */
  88787. target: any;
  88788. }
  88789. /**
  88790. * Use this class to create coordinated animations on multiple targets
  88791. */
  88792. export class AnimationGroup implements IDisposable {
  88793. /** The name of the animation group */
  88794. name: string;
  88795. private _scene;
  88796. private _targetedAnimations;
  88797. private _animatables;
  88798. private _from;
  88799. private _to;
  88800. private _isStarted;
  88801. private _isPaused;
  88802. private _speedRatio;
  88803. /**
  88804. * Gets or sets the unique id of the node
  88805. */
  88806. uniqueId: number;
  88807. /**
  88808. * This observable will notify when one animation have ended
  88809. */
  88810. onAnimationEndObservable: Observable<TargetedAnimation>;
  88811. /**
  88812. * Observer raised when one animation loops
  88813. */
  88814. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88815. /**
  88816. * This observable will notify when all animations have ended.
  88817. */
  88818. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88819. /**
  88820. * This observable will notify when all animations have paused.
  88821. */
  88822. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88823. /**
  88824. * This observable will notify when all animations are playing.
  88825. */
  88826. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88827. /**
  88828. * Gets the first frame
  88829. */
  88830. readonly from: number;
  88831. /**
  88832. * Gets the last frame
  88833. */
  88834. readonly to: number;
  88835. /**
  88836. * Define if the animations are started
  88837. */
  88838. readonly isStarted: boolean;
  88839. /**
  88840. * Gets a value indicating that the current group is playing
  88841. */
  88842. readonly isPlaying: boolean;
  88843. /**
  88844. * Gets or sets the speed ratio to use for all animations
  88845. */
  88846. /**
  88847. * Gets or sets the speed ratio to use for all animations
  88848. */
  88849. speedRatio: number;
  88850. /**
  88851. * Gets the targeted animations for this animation group
  88852. */
  88853. readonly targetedAnimations: Array<TargetedAnimation>;
  88854. /**
  88855. * returning the list of animatables controlled by this animation group.
  88856. */
  88857. readonly animatables: Array<Animatable>;
  88858. /**
  88859. * Instantiates a new Animation Group.
  88860. * This helps managing several animations at once.
  88861. * @see http://doc.babylonjs.com/how_to/group
  88862. * @param name Defines the name of the group
  88863. * @param scene Defines the scene the group belongs to
  88864. */
  88865. constructor(
  88866. /** The name of the animation group */
  88867. name: string, scene?: Nullable<Scene>);
  88868. /**
  88869. * Add an animation (with its target) in the group
  88870. * @param animation defines the animation we want to add
  88871. * @param target defines the target of the animation
  88872. * @returns the TargetedAnimation object
  88873. */
  88874. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88875. /**
  88876. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88877. * It can add constant keys at begin or end
  88878. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88879. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88880. * @returns the animation group
  88881. */
  88882. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88883. /**
  88884. * Start all animations on given targets
  88885. * @param loop defines if animations must loop
  88886. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88887. * @param from defines the from key (optional)
  88888. * @param to defines the to key (optional)
  88889. * @returns the current animation group
  88890. */
  88891. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88892. /**
  88893. * Pause all animations
  88894. * @returns the animation group
  88895. */
  88896. pause(): AnimationGroup;
  88897. /**
  88898. * Play all animations to initial state
  88899. * This function will start() the animations if they were not started or will restart() them if they were paused
  88900. * @param loop defines if animations must loop
  88901. * @returns the animation group
  88902. */
  88903. play(loop?: boolean): AnimationGroup;
  88904. /**
  88905. * Reset all animations to initial state
  88906. * @returns the animation group
  88907. */
  88908. reset(): AnimationGroup;
  88909. /**
  88910. * Restart animations from key 0
  88911. * @returns the animation group
  88912. */
  88913. restart(): AnimationGroup;
  88914. /**
  88915. * Stop all animations
  88916. * @returns the animation group
  88917. */
  88918. stop(): AnimationGroup;
  88919. /**
  88920. * Set animation weight for all animatables
  88921. * @param weight defines the weight to use
  88922. * @return the animationGroup
  88923. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88924. */
  88925. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88926. /**
  88927. * Synchronize and normalize all animatables with a source animatable
  88928. * @param root defines the root animatable to synchronize with
  88929. * @return the animationGroup
  88930. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88931. */
  88932. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88933. /**
  88934. * Goes to a specific frame in this animation group
  88935. * @param frame the frame number to go to
  88936. * @return the animationGroup
  88937. */
  88938. goToFrame(frame: number): AnimationGroup;
  88939. /**
  88940. * Dispose all associated resources
  88941. */
  88942. dispose(): void;
  88943. private _checkAnimationGroupEnded;
  88944. /**
  88945. * Clone the current animation group and returns a copy
  88946. * @param newName defines the name of the new group
  88947. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88948. * @returns the new aniamtion group
  88949. */
  88950. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88951. /**
  88952. * Returns a new AnimationGroup object parsed from the source provided.
  88953. * @param parsedAnimationGroup defines the source
  88954. * @param scene defines the scene that will receive the animationGroup
  88955. * @returns a new AnimationGroup
  88956. */
  88957. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88958. /**
  88959. * Returns the string "AnimationGroup"
  88960. * @returns "AnimationGroup"
  88961. */
  88962. getClassName(): string;
  88963. /**
  88964. * Creates a detailled string about the object
  88965. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88966. * @returns a string representing the object
  88967. */
  88968. toString(fullDetails?: boolean): string;
  88969. }
  88970. }
  88971. declare module BABYLON {
  88972. /**
  88973. * Define an interface for all classes that will hold resources
  88974. */
  88975. export interface IDisposable {
  88976. /**
  88977. * Releases all held resources
  88978. */
  88979. dispose(): void;
  88980. }
  88981. /** Interface defining initialization parameters for Scene class */
  88982. export interface SceneOptions {
  88983. /**
  88984. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88985. * It will improve performance when the number of geometries becomes important.
  88986. */
  88987. useGeometryUniqueIdsMap?: boolean;
  88988. /**
  88989. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88990. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88991. */
  88992. useMaterialMeshMap?: boolean;
  88993. /**
  88994. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88995. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88996. */
  88997. useClonedMeshhMap?: boolean;
  88998. }
  88999. /**
  89000. * Represents a scene to be rendered by the engine.
  89001. * @see http://doc.babylonjs.com/features/scene
  89002. */
  89003. export class Scene extends AbstractScene implements IAnimatable {
  89004. private static _uniqueIdCounter;
  89005. /** The fog is deactivated */
  89006. static readonly FOGMODE_NONE: number;
  89007. /** The fog density is following an exponential function */
  89008. static readonly FOGMODE_EXP: number;
  89009. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  89010. static readonly FOGMODE_EXP2: number;
  89011. /** The fog density is following a linear function. */
  89012. static readonly FOGMODE_LINEAR: number;
  89013. /**
  89014. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  89015. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89016. */
  89017. static MinDeltaTime: number;
  89018. /**
  89019. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  89020. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89021. */
  89022. static MaxDeltaTime: number;
  89023. /**
  89024. * Factory used to create the default material.
  89025. * @param name The name of the material to create
  89026. * @param scene The scene to create the material for
  89027. * @returns The default material
  89028. */
  89029. static DefaultMaterialFactory(scene: Scene): Material;
  89030. /**
  89031. * Factory used to create the a collision coordinator.
  89032. * @returns The collision coordinator
  89033. */
  89034. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  89035. /** @hidden */
  89036. readonly _isScene: boolean;
  89037. /**
  89038. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  89039. */
  89040. autoClear: boolean;
  89041. /**
  89042. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  89043. */
  89044. autoClearDepthAndStencil: boolean;
  89045. /**
  89046. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  89047. */
  89048. clearColor: Color4;
  89049. /**
  89050. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  89051. */
  89052. ambientColor: Color3;
  89053. /** @hidden */
  89054. _environmentBRDFTexture: BaseTexture;
  89055. /** @hidden */
  89056. protected _environmentTexture: Nullable<BaseTexture>;
  89057. /**
  89058. * Texture used in all pbr material as the reflection texture.
  89059. * As in the majority of the scene they are the same (exception for multi room and so on),
  89060. * this is easier to reference from here than from all the materials.
  89061. */
  89062. /**
  89063. * Texture used in all pbr material as the reflection texture.
  89064. * As in the majority of the scene they are the same (exception for multi room and so on),
  89065. * this is easier to set here than in all the materials.
  89066. */
  89067. environmentTexture: Nullable<BaseTexture>;
  89068. /** @hidden */
  89069. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89070. /**
  89071. * Default image processing configuration used either in the rendering
  89072. * Forward main pass or through the imageProcessingPostProcess if present.
  89073. * As in the majority of the scene they are the same (exception for multi camera),
  89074. * this is easier to reference from here than from all the materials and post process.
  89075. *
  89076. * No setter as we it is a shared configuration, you can set the values instead.
  89077. */
  89078. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  89079. private _forceWireframe;
  89080. /**
  89081. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  89082. */
  89083. forceWireframe: boolean;
  89084. private _forcePointsCloud;
  89085. /**
  89086. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  89087. */
  89088. forcePointsCloud: boolean;
  89089. /**
  89090. * Gets or sets the active clipplane 1
  89091. */
  89092. clipPlane: Nullable<Plane>;
  89093. /**
  89094. * Gets or sets the active clipplane 2
  89095. */
  89096. clipPlane2: Nullable<Plane>;
  89097. /**
  89098. * Gets or sets the active clipplane 3
  89099. */
  89100. clipPlane3: Nullable<Plane>;
  89101. /**
  89102. * Gets or sets the active clipplane 4
  89103. */
  89104. clipPlane4: Nullable<Plane>;
  89105. /**
  89106. * Gets or sets a boolean indicating if animations are enabled
  89107. */
  89108. animationsEnabled: boolean;
  89109. private _animationPropertiesOverride;
  89110. /**
  89111. * Gets or sets the animation properties override
  89112. */
  89113. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89114. /**
  89115. * Gets or sets a boolean indicating if a constant deltatime has to be used
  89116. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  89117. */
  89118. useConstantAnimationDeltaTime: boolean;
  89119. /**
  89120. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  89121. * Please note that it requires to run a ray cast through the scene on every frame
  89122. */
  89123. constantlyUpdateMeshUnderPointer: boolean;
  89124. /**
  89125. * Defines the HTML cursor to use when hovering over interactive elements
  89126. */
  89127. hoverCursor: string;
  89128. /**
  89129. * Defines the HTML default cursor to use (empty by default)
  89130. */
  89131. defaultCursor: string;
  89132. /**
  89133. * This is used to call preventDefault() on pointer down
  89134. * in order to block unwanted artifacts like system double clicks
  89135. */
  89136. preventDefaultOnPointerDown: boolean;
  89137. /**
  89138. * This is used to call preventDefault() on pointer up
  89139. * in order to block unwanted artifacts like system double clicks
  89140. */
  89141. preventDefaultOnPointerUp: boolean;
  89142. /**
  89143. * Gets or sets user defined metadata
  89144. */
  89145. metadata: any;
  89146. /**
  89147. * For internal use only. Please do not use.
  89148. */
  89149. reservedDataStore: any;
  89150. /**
  89151. * Gets the name of the plugin used to load this scene (null by default)
  89152. */
  89153. loadingPluginName: string;
  89154. /**
  89155. * Use this array to add regular expressions used to disable offline support for specific urls
  89156. */
  89157. disableOfflineSupportExceptionRules: RegExp[];
  89158. /**
  89159. * An event triggered when the scene is disposed.
  89160. */
  89161. onDisposeObservable: Observable<Scene>;
  89162. private _onDisposeObserver;
  89163. /** Sets a function to be executed when this scene is disposed. */
  89164. onDispose: () => void;
  89165. /**
  89166. * An event triggered before rendering the scene (right after animations and physics)
  89167. */
  89168. onBeforeRenderObservable: Observable<Scene>;
  89169. private _onBeforeRenderObserver;
  89170. /** Sets a function to be executed before rendering this scene */
  89171. beforeRender: Nullable<() => void>;
  89172. /**
  89173. * An event triggered after rendering the scene
  89174. */
  89175. onAfterRenderObservable: Observable<Scene>;
  89176. private _onAfterRenderObserver;
  89177. /** Sets a function to be executed after rendering this scene */
  89178. afterRender: Nullable<() => void>;
  89179. /**
  89180. * An event triggered before animating the scene
  89181. */
  89182. onBeforeAnimationsObservable: Observable<Scene>;
  89183. /**
  89184. * An event triggered after animations processing
  89185. */
  89186. onAfterAnimationsObservable: Observable<Scene>;
  89187. /**
  89188. * An event triggered before draw calls are ready to be sent
  89189. */
  89190. onBeforeDrawPhaseObservable: Observable<Scene>;
  89191. /**
  89192. * An event triggered after draw calls have been sent
  89193. */
  89194. onAfterDrawPhaseObservable: Observable<Scene>;
  89195. /**
  89196. * An event triggered when the scene is ready
  89197. */
  89198. onReadyObservable: Observable<Scene>;
  89199. /**
  89200. * An event triggered before rendering a camera
  89201. */
  89202. onBeforeCameraRenderObservable: Observable<Camera>;
  89203. private _onBeforeCameraRenderObserver;
  89204. /** Sets a function to be executed before rendering a camera*/
  89205. beforeCameraRender: () => void;
  89206. /**
  89207. * An event triggered after rendering a camera
  89208. */
  89209. onAfterCameraRenderObservable: Observable<Camera>;
  89210. private _onAfterCameraRenderObserver;
  89211. /** Sets a function to be executed after rendering a camera*/
  89212. afterCameraRender: () => void;
  89213. /**
  89214. * An event triggered when active meshes evaluation is about to start
  89215. */
  89216. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  89217. /**
  89218. * An event triggered when active meshes evaluation is done
  89219. */
  89220. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  89221. /**
  89222. * An event triggered when particles rendering is about to start
  89223. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89224. */
  89225. onBeforeParticlesRenderingObservable: Observable<Scene>;
  89226. /**
  89227. * An event triggered when particles rendering is done
  89228. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89229. */
  89230. onAfterParticlesRenderingObservable: Observable<Scene>;
  89231. /**
  89232. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  89233. */
  89234. onDataLoadedObservable: Observable<Scene>;
  89235. /**
  89236. * An event triggered when a camera is created
  89237. */
  89238. onNewCameraAddedObservable: Observable<Camera>;
  89239. /**
  89240. * An event triggered when a camera is removed
  89241. */
  89242. onCameraRemovedObservable: Observable<Camera>;
  89243. /**
  89244. * An event triggered when a light is created
  89245. */
  89246. onNewLightAddedObservable: Observable<Light>;
  89247. /**
  89248. * An event triggered when a light is removed
  89249. */
  89250. onLightRemovedObservable: Observable<Light>;
  89251. /**
  89252. * An event triggered when a geometry is created
  89253. */
  89254. onNewGeometryAddedObservable: Observable<Geometry>;
  89255. /**
  89256. * An event triggered when a geometry is removed
  89257. */
  89258. onGeometryRemovedObservable: Observable<Geometry>;
  89259. /**
  89260. * An event triggered when a transform node is created
  89261. */
  89262. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  89263. /**
  89264. * An event triggered when a transform node is removed
  89265. */
  89266. onTransformNodeRemovedObservable: Observable<TransformNode>;
  89267. /**
  89268. * An event triggered when a mesh is created
  89269. */
  89270. onNewMeshAddedObservable: Observable<AbstractMesh>;
  89271. /**
  89272. * An event triggered when a mesh is removed
  89273. */
  89274. onMeshRemovedObservable: Observable<AbstractMesh>;
  89275. /**
  89276. * An event triggered when a skeleton is created
  89277. */
  89278. onNewSkeletonAddedObservable: Observable<Skeleton>;
  89279. /**
  89280. * An event triggered when a skeleton is removed
  89281. */
  89282. onSkeletonRemovedObservable: Observable<Skeleton>;
  89283. /**
  89284. * An event triggered when a material is created
  89285. */
  89286. onNewMaterialAddedObservable: Observable<Material>;
  89287. /**
  89288. * An event triggered when a material is removed
  89289. */
  89290. onMaterialRemovedObservable: Observable<Material>;
  89291. /**
  89292. * An event triggered when a texture is created
  89293. */
  89294. onNewTextureAddedObservable: Observable<BaseTexture>;
  89295. /**
  89296. * An event triggered when a texture is removed
  89297. */
  89298. onTextureRemovedObservable: Observable<BaseTexture>;
  89299. /**
  89300. * An event triggered when render targets are about to be rendered
  89301. * Can happen multiple times per frame.
  89302. */
  89303. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  89304. /**
  89305. * An event triggered when render targets were rendered.
  89306. * Can happen multiple times per frame.
  89307. */
  89308. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  89309. /**
  89310. * An event triggered before calculating deterministic simulation step
  89311. */
  89312. onBeforeStepObservable: Observable<Scene>;
  89313. /**
  89314. * An event triggered after calculating deterministic simulation step
  89315. */
  89316. onAfterStepObservable: Observable<Scene>;
  89317. /**
  89318. * An event triggered when the activeCamera property is updated
  89319. */
  89320. onActiveCameraChanged: Observable<Scene>;
  89321. /**
  89322. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  89323. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  89324. * 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)
  89325. */
  89326. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  89327. /**
  89328. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  89329. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  89330. * 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)
  89331. */
  89332. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  89333. /**
  89334. * This Observable will when a mesh has been imported into the scene.
  89335. */
  89336. onMeshImportedObservable: Observable<AbstractMesh>;
  89337. /**
  89338. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  89339. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  89340. */
  89341. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  89342. /** @hidden */
  89343. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  89344. /**
  89345. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  89346. */
  89347. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  89348. /**
  89349. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  89350. */
  89351. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  89352. /**
  89353. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  89354. */
  89355. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  89356. private _onPointerMove;
  89357. private _onPointerDown;
  89358. private _onPointerUp;
  89359. /** Callback called when a pointer move is detected */
  89360. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89361. /** Callback called when a pointer down is detected */
  89362. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89363. /** Callback called when a pointer up is detected */
  89364. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  89365. /** Callback called when a pointer pick is detected */
  89366. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  89367. /**
  89368. * 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).
  89369. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  89370. */
  89371. onPrePointerObservable: Observable<PointerInfoPre>;
  89372. /**
  89373. * Observable event triggered each time an input event is received from the rendering canvas
  89374. */
  89375. onPointerObservable: Observable<PointerInfo>;
  89376. /**
  89377. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  89378. */
  89379. readonly unTranslatedPointer: Vector2;
  89380. /** The distance in pixel that you have to move to prevent some events */
  89381. static DragMovementThreshold: number;
  89382. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  89383. static LongPressDelay: number;
  89384. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  89385. static DoubleClickDelay: number;
  89386. /** If you need to check double click without raising a single click at first click, enable this flag */
  89387. static ExclusiveDoubleClickMode: boolean;
  89388. private _initClickEvent;
  89389. private _initActionManager;
  89390. private _delayedSimpleClick;
  89391. private _delayedSimpleClickTimeout;
  89392. private _previousDelayedSimpleClickTimeout;
  89393. private _meshPickProceed;
  89394. private _previousButtonPressed;
  89395. private _currentPickResult;
  89396. private _previousPickResult;
  89397. private _totalPointersPressed;
  89398. private _doubleClickOccured;
  89399. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  89400. cameraToUseForPointers: Nullable<Camera>;
  89401. private _pointerX;
  89402. private _pointerY;
  89403. private _unTranslatedPointerX;
  89404. private _unTranslatedPointerY;
  89405. private _startingPointerPosition;
  89406. private _previousStartingPointerPosition;
  89407. private _startingPointerTime;
  89408. private _previousStartingPointerTime;
  89409. private _pointerCaptures;
  89410. private _timeAccumulator;
  89411. private _currentStepId;
  89412. private _currentInternalStep;
  89413. /** @hidden */
  89414. _mirroredCameraPosition: Nullable<Vector3>;
  89415. /**
  89416. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  89417. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  89418. */
  89419. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  89420. /**
  89421. * Observable event triggered each time an keyboard event is received from the hosting window
  89422. */
  89423. onKeyboardObservable: Observable<KeyboardInfo>;
  89424. private _onKeyDown;
  89425. private _onKeyUp;
  89426. private _onCanvasFocusObserver;
  89427. private _onCanvasBlurObserver;
  89428. private _useRightHandedSystem;
  89429. /**
  89430. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  89431. */
  89432. useRightHandedSystem: boolean;
  89433. /**
  89434. * Sets the step Id used by deterministic lock step
  89435. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89436. * @param newStepId defines the step Id
  89437. */
  89438. setStepId(newStepId: number): void;
  89439. /**
  89440. * Gets the step Id used by deterministic lock step
  89441. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89442. * @returns the step Id
  89443. */
  89444. getStepId(): number;
  89445. /**
  89446. * Gets the internal step used by deterministic lock step
  89447. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89448. * @returns the internal step
  89449. */
  89450. getInternalStep(): number;
  89451. private _fogEnabled;
  89452. /**
  89453. * Gets or sets a boolean indicating if fog is enabled on this scene
  89454. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89455. * (Default is true)
  89456. */
  89457. fogEnabled: boolean;
  89458. private _fogMode;
  89459. /**
  89460. * Gets or sets the fog mode to use
  89461. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89462. * | mode | value |
  89463. * | --- | --- |
  89464. * | FOGMODE_NONE | 0 |
  89465. * | FOGMODE_EXP | 1 |
  89466. * | FOGMODE_EXP2 | 2 |
  89467. * | FOGMODE_LINEAR | 3 |
  89468. */
  89469. fogMode: number;
  89470. /**
  89471. * Gets or sets the fog color to use
  89472. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89473. * (Default is Color3(0.2, 0.2, 0.3))
  89474. */
  89475. fogColor: Color3;
  89476. /**
  89477. * Gets or sets the fog density to use
  89478. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89479. * (Default is 0.1)
  89480. */
  89481. fogDensity: number;
  89482. /**
  89483. * Gets or sets the fog start distance to use
  89484. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89485. * (Default is 0)
  89486. */
  89487. fogStart: number;
  89488. /**
  89489. * Gets or sets the fog end distance to use
  89490. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89491. * (Default is 1000)
  89492. */
  89493. fogEnd: number;
  89494. private _shadowsEnabled;
  89495. /**
  89496. * Gets or sets a boolean indicating if shadows are enabled on this scene
  89497. */
  89498. shadowsEnabled: boolean;
  89499. private _lightsEnabled;
  89500. /**
  89501. * Gets or sets a boolean indicating if lights are enabled on this scene
  89502. */
  89503. lightsEnabled: boolean;
  89504. /** All of the active cameras added to this scene. */
  89505. activeCameras: Camera[];
  89506. private _activeCamera;
  89507. /** Gets or sets the current active camera */
  89508. activeCamera: Nullable<Camera>;
  89509. private _defaultMaterial;
  89510. /** The default material used on meshes when no material is affected */
  89511. /** The default material used on meshes when no material is affected */
  89512. defaultMaterial: Material;
  89513. private _texturesEnabled;
  89514. /**
  89515. * Gets or sets a boolean indicating if textures are enabled on this scene
  89516. */
  89517. texturesEnabled: boolean;
  89518. /**
  89519. * Gets or sets a boolean indicating if particles are enabled on this scene
  89520. */
  89521. particlesEnabled: boolean;
  89522. /**
  89523. * Gets or sets a boolean indicating if sprites are enabled on this scene
  89524. */
  89525. spritesEnabled: boolean;
  89526. private _skeletonsEnabled;
  89527. /**
  89528. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  89529. */
  89530. skeletonsEnabled: boolean;
  89531. /**
  89532. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  89533. */
  89534. lensFlaresEnabled: boolean;
  89535. /**
  89536. * Gets or sets a boolean indicating if collisions are enabled on this scene
  89537. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89538. */
  89539. collisionsEnabled: boolean;
  89540. private _collisionCoordinator;
  89541. /** @hidden */
  89542. readonly collisionCoordinator: ICollisionCoordinator;
  89543. /**
  89544. * Defines the gravity applied to this scene (used only for collisions)
  89545. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89546. */
  89547. gravity: Vector3;
  89548. /**
  89549. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  89550. */
  89551. postProcessesEnabled: boolean;
  89552. /**
  89553. * The list of postprocesses added to the scene
  89554. */
  89555. postProcesses: PostProcess[];
  89556. /**
  89557. * Gets the current postprocess manager
  89558. */
  89559. postProcessManager: PostProcessManager;
  89560. /**
  89561. * Gets or sets a boolean indicating if render targets are enabled on this scene
  89562. */
  89563. renderTargetsEnabled: boolean;
  89564. /**
  89565. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  89566. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  89567. */
  89568. dumpNextRenderTargets: boolean;
  89569. /**
  89570. * The list of user defined render targets added to the scene
  89571. */
  89572. customRenderTargets: RenderTargetTexture[];
  89573. /**
  89574. * Defines if texture loading must be delayed
  89575. * If true, textures will only be loaded when they need to be rendered
  89576. */
  89577. useDelayedTextureLoading: boolean;
  89578. /**
  89579. * Gets the list of meshes imported to the scene through SceneLoader
  89580. */
  89581. importedMeshesFiles: String[];
  89582. /**
  89583. * Gets or sets a boolean indicating if probes are enabled on this scene
  89584. */
  89585. probesEnabled: boolean;
  89586. /**
  89587. * Gets or sets the current offline provider to use to store scene data
  89588. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89589. */
  89590. offlineProvider: IOfflineProvider;
  89591. /**
  89592. * Gets or sets the action manager associated with the scene
  89593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89594. */
  89595. actionManager: AbstractActionManager;
  89596. private _meshesForIntersections;
  89597. /**
  89598. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89599. */
  89600. proceduralTexturesEnabled: boolean;
  89601. private _engine;
  89602. private _totalVertices;
  89603. /** @hidden */
  89604. _activeIndices: PerfCounter;
  89605. /** @hidden */
  89606. _activeParticles: PerfCounter;
  89607. /** @hidden */
  89608. _activeBones: PerfCounter;
  89609. private _animationRatio;
  89610. /** @hidden */
  89611. _animationTimeLast: number;
  89612. /** @hidden */
  89613. _animationTime: number;
  89614. /**
  89615. * Gets or sets a general scale for animation speed
  89616. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89617. */
  89618. animationTimeScale: number;
  89619. /** @hidden */
  89620. _cachedMaterial: Nullable<Material>;
  89621. /** @hidden */
  89622. _cachedEffect: Nullable<Effect>;
  89623. /** @hidden */
  89624. _cachedVisibility: Nullable<number>;
  89625. private _renderId;
  89626. private _frameId;
  89627. private _executeWhenReadyTimeoutId;
  89628. private _intermediateRendering;
  89629. private _viewUpdateFlag;
  89630. private _projectionUpdateFlag;
  89631. private _alternateViewUpdateFlag;
  89632. private _alternateProjectionUpdateFlag;
  89633. /** @hidden */
  89634. _toBeDisposed: Nullable<IDisposable>[];
  89635. private _activeRequests;
  89636. /** @hidden */
  89637. _pendingData: any[];
  89638. private _isDisposed;
  89639. /**
  89640. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89641. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89642. */
  89643. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89644. private _activeMeshes;
  89645. private _processedMaterials;
  89646. private _renderTargets;
  89647. /** @hidden */
  89648. _activeParticleSystems: SmartArray<IParticleSystem>;
  89649. private _activeSkeletons;
  89650. private _softwareSkinnedMeshes;
  89651. private _renderingManager;
  89652. /** @hidden */
  89653. _activeAnimatables: Animatable[];
  89654. private _transformMatrix;
  89655. private _sceneUbo;
  89656. private _alternateSceneUbo;
  89657. private _viewMatrix;
  89658. private _projectionMatrix;
  89659. private _alternateViewMatrix;
  89660. private _alternateProjectionMatrix;
  89661. private _alternateTransformMatrix;
  89662. private _useAlternateCameraConfiguration;
  89663. private _alternateRendering;
  89664. private _wheelEventName;
  89665. /** @hidden */
  89666. _forcedViewPosition: Nullable<Vector3>;
  89667. /** @hidden */
  89668. readonly _isAlternateRenderingEnabled: boolean;
  89669. private _frustumPlanes;
  89670. /**
  89671. * Gets the list of frustum planes (built from the active camera)
  89672. */
  89673. readonly frustumPlanes: Plane[];
  89674. /**
  89675. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89676. * This is useful if there are more lights that the maximum simulteanous authorized
  89677. */
  89678. requireLightSorting: boolean;
  89679. /** @hidden */
  89680. readonly useMaterialMeshMap: boolean;
  89681. /** @hidden */
  89682. readonly useClonedMeshhMap: boolean;
  89683. private _pointerOverMesh;
  89684. private _pickedDownMesh;
  89685. private _pickedUpMesh;
  89686. private _externalData;
  89687. private _uid;
  89688. /**
  89689. * @hidden
  89690. * Backing store of defined scene components.
  89691. */
  89692. _components: ISceneComponent[];
  89693. /**
  89694. * @hidden
  89695. * Backing store of defined scene components.
  89696. */
  89697. _serializableComponents: ISceneSerializableComponent[];
  89698. /**
  89699. * List of components to register on the next registration step.
  89700. */
  89701. private _transientComponents;
  89702. /**
  89703. * Registers the transient components if needed.
  89704. */
  89705. private _registerTransientComponents;
  89706. /**
  89707. * @hidden
  89708. * Add a component to the scene.
  89709. * Note that the ccomponent could be registered on th next frame if this is called after
  89710. * the register component stage.
  89711. * @param component Defines the component to add to the scene
  89712. */
  89713. _addComponent(component: ISceneComponent): void;
  89714. /**
  89715. * @hidden
  89716. * Gets a component from the scene.
  89717. * @param name defines the name of the component to retrieve
  89718. * @returns the component or null if not present
  89719. */
  89720. _getComponent(name: string): Nullable<ISceneComponent>;
  89721. /**
  89722. * @hidden
  89723. * Defines the actions happening before camera updates.
  89724. */
  89725. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89726. /**
  89727. * @hidden
  89728. * Defines the actions happening before clear the canvas.
  89729. */
  89730. _beforeClearStage: Stage<SimpleStageAction>;
  89731. /**
  89732. * @hidden
  89733. * Defines the actions when collecting render targets for the frame.
  89734. */
  89735. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89736. /**
  89737. * @hidden
  89738. * Defines the actions happening for one camera in the frame.
  89739. */
  89740. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89741. /**
  89742. * @hidden
  89743. * Defines the actions happening during the per mesh ready checks.
  89744. */
  89745. _isReadyForMeshStage: Stage<MeshStageAction>;
  89746. /**
  89747. * @hidden
  89748. * Defines the actions happening before evaluate active mesh checks.
  89749. */
  89750. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89751. /**
  89752. * @hidden
  89753. * Defines the actions happening during the evaluate sub mesh checks.
  89754. */
  89755. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89756. /**
  89757. * @hidden
  89758. * Defines the actions happening during the active mesh stage.
  89759. */
  89760. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89761. /**
  89762. * @hidden
  89763. * Defines the actions happening during the per camera render target step.
  89764. */
  89765. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89766. /**
  89767. * @hidden
  89768. * Defines the actions happening just before the active camera is drawing.
  89769. */
  89770. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89771. /**
  89772. * @hidden
  89773. * Defines the actions happening just before a render target is drawing.
  89774. */
  89775. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89776. /**
  89777. * @hidden
  89778. * Defines the actions happening just before a rendering group is drawing.
  89779. */
  89780. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89781. /**
  89782. * @hidden
  89783. * Defines the actions happening just before a mesh is drawing.
  89784. */
  89785. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89786. /**
  89787. * @hidden
  89788. * Defines the actions happening just after a mesh has been drawn.
  89789. */
  89790. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89791. /**
  89792. * @hidden
  89793. * Defines the actions happening just after a rendering group has been drawn.
  89794. */
  89795. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89796. /**
  89797. * @hidden
  89798. * Defines the actions happening just after the active camera has been drawn.
  89799. */
  89800. _afterCameraDrawStage: Stage<CameraStageAction>;
  89801. /**
  89802. * @hidden
  89803. * Defines the actions happening just after a render target has been drawn.
  89804. */
  89805. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89806. /**
  89807. * @hidden
  89808. * Defines the actions happening just after rendering all cameras and computing intersections.
  89809. */
  89810. _afterRenderStage: Stage<SimpleStageAction>;
  89811. /**
  89812. * @hidden
  89813. * Defines the actions happening when a pointer move event happens.
  89814. */
  89815. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89816. /**
  89817. * @hidden
  89818. * Defines the actions happening when a pointer down event happens.
  89819. */
  89820. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89821. /**
  89822. * @hidden
  89823. * Defines the actions happening when a pointer up event happens.
  89824. */
  89825. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89826. /**
  89827. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89828. */
  89829. private geometriesByUniqueId;
  89830. /**
  89831. * Creates a new Scene
  89832. * @param engine defines the engine to use to render this scene
  89833. * @param options defines the scene options
  89834. */
  89835. constructor(engine: Engine, options?: SceneOptions);
  89836. private _defaultMeshCandidates;
  89837. /**
  89838. * @hidden
  89839. */
  89840. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89841. private _defaultSubMeshCandidates;
  89842. /**
  89843. * @hidden
  89844. */
  89845. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89846. /**
  89847. * Sets the default candidate providers for the scene.
  89848. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89849. * and getCollidingSubMeshCandidates to their default function
  89850. */
  89851. setDefaultCandidateProviders(): void;
  89852. /**
  89853. * Gets the mesh that is currently under the pointer
  89854. */
  89855. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89856. /**
  89857. * Gets or sets the current on-screen X position of the pointer
  89858. */
  89859. pointerX: number;
  89860. /**
  89861. * Gets or sets the current on-screen Y position of the pointer
  89862. */
  89863. pointerY: number;
  89864. /**
  89865. * Gets the cached material (ie. the latest rendered one)
  89866. * @returns the cached material
  89867. */
  89868. getCachedMaterial(): Nullable<Material>;
  89869. /**
  89870. * Gets the cached effect (ie. the latest rendered one)
  89871. * @returns the cached effect
  89872. */
  89873. getCachedEffect(): Nullable<Effect>;
  89874. /**
  89875. * Gets the cached visibility state (ie. the latest rendered one)
  89876. * @returns the cached visibility state
  89877. */
  89878. getCachedVisibility(): Nullable<number>;
  89879. /**
  89880. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89881. * @param material defines the current material
  89882. * @param effect defines the current effect
  89883. * @param visibility defines the current visibility state
  89884. * @returns true if one parameter is not cached
  89885. */
  89886. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89887. /**
  89888. * Gets the engine associated with the scene
  89889. * @returns an Engine
  89890. */
  89891. getEngine(): Engine;
  89892. /**
  89893. * Gets the total number of vertices rendered per frame
  89894. * @returns the total number of vertices rendered per frame
  89895. */
  89896. getTotalVertices(): number;
  89897. /**
  89898. * Gets the performance counter for total vertices
  89899. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89900. */
  89901. readonly totalVerticesPerfCounter: PerfCounter;
  89902. /**
  89903. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89904. * @returns the total number of active indices rendered per frame
  89905. */
  89906. getActiveIndices(): number;
  89907. /**
  89908. * Gets the performance counter for active indices
  89909. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89910. */
  89911. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89912. /**
  89913. * Gets the total number of active particles rendered per frame
  89914. * @returns the total number of active particles rendered per frame
  89915. */
  89916. getActiveParticles(): number;
  89917. /**
  89918. * Gets the performance counter for active particles
  89919. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89920. */
  89921. readonly activeParticlesPerfCounter: PerfCounter;
  89922. /**
  89923. * Gets the total number of active bones rendered per frame
  89924. * @returns the total number of active bones rendered per frame
  89925. */
  89926. getActiveBones(): number;
  89927. /**
  89928. * Gets the performance counter for active bones
  89929. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89930. */
  89931. readonly activeBonesPerfCounter: PerfCounter;
  89932. /**
  89933. * Gets the array of active meshes
  89934. * @returns an array of AbstractMesh
  89935. */
  89936. getActiveMeshes(): SmartArray<AbstractMesh>;
  89937. /**
  89938. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89939. * @returns a number
  89940. */
  89941. getAnimationRatio(): number;
  89942. /**
  89943. * Gets an unique Id for the current render phase
  89944. * @returns a number
  89945. */
  89946. getRenderId(): number;
  89947. /**
  89948. * Gets an unique Id for the current frame
  89949. * @returns a number
  89950. */
  89951. getFrameId(): number;
  89952. /** Call this function if you want to manually increment the render Id*/
  89953. incrementRenderId(): void;
  89954. private _updatePointerPosition;
  89955. private _createUbo;
  89956. private _createAlternateUbo;
  89957. private _setRayOnPointerInfo;
  89958. /**
  89959. * Use this method to simulate a pointer move on a mesh
  89960. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89961. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89962. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89963. * @returns the current scene
  89964. */
  89965. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89966. private _processPointerMove;
  89967. private _checkPrePointerObservable;
  89968. /**
  89969. * Use this method to simulate a pointer down on a mesh
  89970. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89971. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89972. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89973. * @returns the current scene
  89974. */
  89975. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89976. private _processPointerDown;
  89977. /**
  89978. * Use this method to simulate a pointer up on a mesh
  89979. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89980. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89981. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89982. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89983. * @returns the current scene
  89984. */
  89985. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89986. private _processPointerUp;
  89987. /**
  89988. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89989. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89990. * @returns true if the pointer was captured
  89991. */
  89992. isPointerCaptured(pointerId?: number): boolean;
  89993. /** @hidden */
  89994. _isPointerSwiping(): boolean;
  89995. /**
  89996. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89997. * @param attachUp defines if you want to attach events to pointerup
  89998. * @param attachDown defines if you want to attach events to pointerdown
  89999. * @param attachMove defines if you want to attach events to pointermove
  90000. */
  90001. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  90002. /** Detaches all event handlers*/
  90003. detachControl(): void;
  90004. /**
  90005. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  90006. * Delay loaded resources are not taking in account
  90007. * @return true if all required resources are ready
  90008. */
  90009. isReady(): boolean;
  90010. /** Resets all cached information relative to material (including effect and visibility) */
  90011. resetCachedMaterial(): void;
  90012. /**
  90013. * Registers a function to be called before every frame render
  90014. * @param func defines the function to register
  90015. */
  90016. registerBeforeRender(func: () => void): void;
  90017. /**
  90018. * Unregisters a function called before every frame render
  90019. * @param func defines the function to unregister
  90020. */
  90021. unregisterBeforeRender(func: () => void): void;
  90022. /**
  90023. * Registers a function to be called after every frame render
  90024. * @param func defines the function to register
  90025. */
  90026. registerAfterRender(func: () => void): void;
  90027. /**
  90028. * Unregisters a function called after every frame render
  90029. * @param func defines the function to unregister
  90030. */
  90031. unregisterAfterRender(func: () => void): void;
  90032. private _executeOnceBeforeRender;
  90033. /**
  90034. * The provided function will run before render once and will be disposed afterwards.
  90035. * A timeout delay can be provided so that the function will be executed in N ms.
  90036. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  90037. * @param func The function to be executed.
  90038. * @param timeout optional delay in ms
  90039. */
  90040. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  90041. /** @hidden */
  90042. _addPendingData(data: any): void;
  90043. /** @hidden */
  90044. _removePendingData(data: any): void;
  90045. /**
  90046. * Returns the number of items waiting to be loaded
  90047. * @returns the number of items waiting to be loaded
  90048. */
  90049. getWaitingItemsCount(): number;
  90050. /**
  90051. * Returns a boolean indicating if the scene is still loading data
  90052. */
  90053. readonly isLoading: boolean;
  90054. /**
  90055. * Registers a function to be executed when the scene is ready
  90056. * @param {Function} func - the function to be executed
  90057. */
  90058. executeWhenReady(func: () => void): void;
  90059. /**
  90060. * Returns a promise that resolves when the scene is ready
  90061. * @returns A promise that resolves when the scene is ready
  90062. */
  90063. whenReadyAsync(): Promise<void>;
  90064. /** @hidden */
  90065. _checkIsReady(): void;
  90066. /**
  90067. * Gets all animatable attached to the scene
  90068. */
  90069. readonly animatables: Animatable[];
  90070. /**
  90071. * Resets the last animation time frame.
  90072. * Useful to override when animations start running when loading a scene for the first time.
  90073. */
  90074. resetLastAnimationTimeFrame(): void;
  90075. /** @hidden */
  90076. _switchToAlternateCameraConfiguration(active: boolean): void;
  90077. /**
  90078. * Gets the current view matrix
  90079. * @returns a Matrix
  90080. */
  90081. getViewMatrix(): Matrix;
  90082. /**
  90083. * Gets the current projection matrix
  90084. * @returns a Matrix
  90085. */
  90086. getProjectionMatrix(): Matrix;
  90087. /**
  90088. * Gets the current transform matrix
  90089. * @returns a Matrix made of View * Projection
  90090. */
  90091. getTransformMatrix(): Matrix;
  90092. /**
  90093. * Sets the current transform matrix
  90094. * @param view defines the View matrix to use
  90095. * @param projection defines the Projection matrix to use
  90096. */
  90097. setTransformMatrix(view: Matrix, projection: Matrix): void;
  90098. /** @hidden */
  90099. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  90100. /**
  90101. * Gets the uniform buffer used to store scene data
  90102. * @returns a UniformBuffer
  90103. */
  90104. getSceneUniformBuffer(): UniformBuffer;
  90105. /**
  90106. * Gets an unique (relatively to the current scene) Id
  90107. * @returns an unique number for the scene
  90108. */
  90109. getUniqueId(): number;
  90110. /**
  90111. * Add a mesh to the list of scene's meshes
  90112. * @param newMesh defines the mesh to add
  90113. * @param recursive if all child meshes should also be added to the scene
  90114. */
  90115. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  90116. /**
  90117. * Remove a mesh for the list of scene's meshes
  90118. * @param toRemove defines the mesh to remove
  90119. * @param recursive if all child meshes should also be removed from the scene
  90120. * @returns the index where the mesh was in the mesh list
  90121. */
  90122. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  90123. /**
  90124. * Add a transform node to the list of scene's transform nodes
  90125. * @param newTransformNode defines the transform node to add
  90126. */
  90127. addTransformNode(newTransformNode: TransformNode): void;
  90128. /**
  90129. * Remove a transform node for the list of scene's transform nodes
  90130. * @param toRemove defines the transform node to remove
  90131. * @returns the index where the transform node was in the transform node list
  90132. */
  90133. removeTransformNode(toRemove: TransformNode): number;
  90134. /**
  90135. * Remove a skeleton for the list of scene's skeletons
  90136. * @param toRemove defines the skeleton to remove
  90137. * @returns the index where the skeleton was in the skeleton list
  90138. */
  90139. removeSkeleton(toRemove: Skeleton): number;
  90140. /**
  90141. * Remove a morph target for the list of scene's morph targets
  90142. * @param toRemove defines the morph target to remove
  90143. * @returns the index where the morph target was in the morph target list
  90144. */
  90145. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  90146. /**
  90147. * Remove a light for the list of scene's lights
  90148. * @param toRemove defines the light to remove
  90149. * @returns the index where the light was in the light list
  90150. */
  90151. removeLight(toRemove: Light): number;
  90152. /**
  90153. * Remove a camera for the list of scene's cameras
  90154. * @param toRemove defines the camera to remove
  90155. * @returns the index where the camera was in the camera list
  90156. */
  90157. removeCamera(toRemove: Camera): number;
  90158. /**
  90159. * Remove a particle system for the list of scene's particle systems
  90160. * @param toRemove defines the particle system to remove
  90161. * @returns the index where the particle system was in the particle system list
  90162. */
  90163. removeParticleSystem(toRemove: IParticleSystem): number;
  90164. /**
  90165. * Remove a animation for the list of scene's animations
  90166. * @param toRemove defines the animation to remove
  90167. * @returns the index where the animation was in the animation list
  90168. */
  90169. removeAnimation(toRemove: Animation): number;
  90170. /**
  90171. * Removes the given animation group from this scene.
  90172. * @param toRemove The animation group to remove
  90173. * @returns The index of the removed animation group
  90174. */
  90175. removeAnimationGroup(toRemove: AnimationGroup): number;
  90176. /**
  90177. * Removes the given multi-material from this scene.
  90178. * @param toRemove The multi-material to remove
  90179. * @returns The index of the removed multi-material
  90180. */
  90181. removeMultiMaterial(toRemove: MultiMaterial): number;
  90182. /**
  90183. * Removes the given material from this scene.
  90184. * @param toRemove The material to remove
  90185. * @returns The index of the removed material
  90186. */
  90187. removeMaterial(toRemove: Material): number;
  90188. /**
  90189. * Removes the given action manager from this scene.
  90190. * @param toRemove The action manager to remove
  90191. * @returns The index of the removed action manager
  90192. */
  90193. removeActionManager(toRemove: AbstractActionManager): number;
  90194. /**
  90195. * Removes the given texture from this scene.
  90196. * @param toRemove The texture to remove
  90197. * @returns The index of the removed texture
  90198. */
  90199. removeTexture(toRemove: BaseTexture): number;
  90200. /**
  90201. * Adds the given light to this scene
  90202. * @param newLight The light to add
  90203. */
  90204. addLight(newLight: Light): void;
  90205. /**
  90206. * Sorts the list list based on light priorities
  90207. */
  90208. sortLightsByPriority(): void;
  90209. /**
  90210. * Adds the given camera to this scene
  90211. * @param newCamera The camera to add
  90212. */
  90213. addCamera(newCamera: Camera): void;
  90214. /**
  90215. * Adds the given skeleton to this scene
  90216. * @param newSkeleton The skeleton to add
  90217. */
  90218. addSkeleton(newSkeleton: Skeleton): void;
  90219. /**
  90220. * Adds the given particle system to this scene
  90221. * @param newParticleSystem The particle system to add
  90222. */
  90223. addParticleSystem(newParticleSystem: IParticleSystem): void;
  90224. /**
  90225. * Adds the given animation to this scene
  90226. * @param newAnimation The animation to add
  90227. */
  90228. addAnimation(newAnimation: Animation): void;
  90229. /**
  90230. * Adds the given animation group to this scene.
  90231. * @param newAnimationGroup The animation group to add
  90232. */
  90233. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  90234. /**
  90235. * Adds the given multi-material to this scene
  90236. * @param newMultiMaterial The multi-material to add
  90237. */
  90238. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  90239. /**
  90240. * Adds the given material to this scene
  90241. * @param newMaterial The material to add
  90242. */
  90243. addMaterial(newMaterial: Material): void;
  90244. /**
  90245. * Adds the given morph target to this scene
  90246. * @param newMorphTargetManager The morph target to add
  90247. */
  90248. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  90249. /**
  90250. * Adds the given geometry to this scene
  90251. * @param newGeometry The geometry to add
  90252. */
  90253. addGeometry(newGeometry: Geometry): void;
  90254. /**
  90255. * Adds the given action manager to this scene
  90256. * @param newActionManager The action manager to add
  90257. */
  90258. addActionManager(newActionManager: AbstractActionManager): void;
  90259. /**
  90260. * Adds the given texture to this scene.
  90261. * @param newTexture The texture to add
  90262. */
  90263. addTexture(newTexture: BaseTexture): void;
  90264. /**
  90265. * Switch active camera
  90266. * @param newCamera defines the new active camera
  90267. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  90268. */
  90269. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  90270. /**
  90271. * sets the active camera of the scene using its ID
  90272. * @param id defines the camera's ID
  90273. * @return the new active camera or null if none found.
  90274. */
  90275. setActiveCameraByID(id: string): Nullable<Camera>;
  90276. /**
  90277. * sets the active camera of the scene using its name
  90278. * @param name defines the camera's name
  90279. * @returns the new active camera or null if none found.
  90280. */
  90281. setActiveCameraByName(name: string): Nullable<Camera>;
  90282. /**
  90283. * get an animation group using its name
  90284. * @param name defines the material's name
  90285. * @return the animation group or null if none found.
  90286. */
  90287. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  90288. /**
  90289. * get a material using its id
  90290. * @param id defines the material's ID
  90291. * @return the material or null if none found.
  90292. */
  90293. getMaterialByID(id: string): Nullable<Material>;
  90294. /**
  90295. * Gets a material using its name
  90296. * @param name defines the material's name
  90297. * @return the material or null if none found.
  90298. */
  90299. getMaterialByName(name: string): Nullable<Material>;
  90300. /**
  90301. * Gets a camera using its id
  90302. * @param id defines the id to look for
  90303. * @returns the camera or null if not found
  90304. */
  90305. getCameraByID(id: string): Nullable<Camera>;
  90306. /**
  90307. * Gets a camera using its unique id
  90308. * @param uniqueId defines the unique id to look for
  90309. * @returns the camera or null if not found
  90310. */
  90311. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  90312. /**
  90313. * Gets a camera using its name
  90314. * @param name defines the camera's name
  90315. * @return the camera or null if none found.
  90316. */
  90317. getCameraByName(name: string): Nullable<Camera>;
  90318. /**
  90319. * Gets a bone using its id
  90320. * @param id defines the bone's id
  90321. * @return the bone or null if not found
  90322. */
  90323. getBoneByID(id: string): Nullable<Bone>;
  90324. /**
  90325. * Gets a bone using its id
  90326. * @param name defines the bone's name
  90327. * @return the bone or null if not found
  90328. */
  90329. getBoneByName(name: string): Nullable<Bone>;
  90330. /**
  90331. * Gets a light node using its name
  90332. * @param name defines the the light's name
  90333. * @return the light or null if none found.
  90334. */
  90335. getLightByName(name: string): Nullable<Light>;
  90336. /**
  90337. * Gets a light node using its id
  90338. * @param id defines the light's id
  90339. * @return the light or null if none found.
  90340. */
  90341. getLightByID(id: string): Nullable<Light>;
  90342. /**
  90343. * Gets a light node using its scene-generated unique ID
  90344. * @param uniqueId defines the light's unique id
  90345. * @return the light or null if none found.
  90346. */
  90347. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  90348. /**
  90349. * Gets a particle system by id
  90350. * @param id defines the particle system id
  90351. * @return the corresponding system or null if none found
  90352. */
  90353. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  90354. /**
  90355. * Gets a geometry using its ID
  90356. * @param id defines the geometry's id
  90357. * @return the geometry or null if none found.
  90358. */
  90359. getGeometryByID(id: string): Nullable<Geometry>;
  90360. private _getGeometryByUniqueID;
  90361. /**
  90362. * Add a new geometry to this scene
  90363. * @param geometry defines the geometry to be added to the scene.
  90364. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  90365. * @return a boolean defining if the geometry was added or not
  90366. */
  90367. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  90368. /**
  90369. * Removes an existing geometry
  90370. * @param geometry defines the geometry to be removed from the scene
  90371. * @return a boolean defining if the geometry was removed or not
  90372. */
  90373. removeGeometry(geometry: Geometry): boolean;
  90374. /**
  90375. * Gets the list of geometries attached to the scene
  90376. * @returns an array of Geometry
  90377. */
  90378. getGeometries(): Geometry[];
  90379. /**
  90380. * Gets the first added mesh found of a given ID
  90381. * @param id defines the id to search for
  90382. * @return the mesh found or null if not found at all
  90383. */
  90384. getMeshByID(id: string): Nullable<AbstractMesh>;
  90385. /**
  90386. * Gets a list of meshes using their id
  90387. * @param id defines the id to search for
  90388. * @returns a list of meshes
  90389. */
  90390. getMeshesByID(id: string): Array<AbstractMesh>;
  90391. /**
  90392. * Gets the first added transform node found of a given ID
  90393. * @param id defines the id to search for
  90394. * @return the found transform node or null if not found at all.
  90395. */
  90396. getTransformNodeByID(id: string): Nullable<TransformNode>;
  90397. /**
  90398. * Gets a list of transform nodes using their id
  90399. * @param id defines the id to search for
  90400. * @returns a list of transform nodes
  90401. */
  90402. getTransformNodesByID(id: string): Array<TransformNode>;
  90403. /**
  90404. * Gets a mesh with its auto-generated unique id
  90405. * @param uniqueId defines the unique id to search for
  90406. * @return the found mesh or null if not found at all.
  90407. */
  90408. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  90409. /**
  90410. * Gets a the last added mesh using a given id
  90411. * @param id defines the id to search for
  90412. * @return the found mesh or null if not found at all.
  90413. */
  90414. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  90415. /**
  90416. * Gets a the last added node (Mesh, Camera, Light) using a given id
  90417. * @param id defines the id to search for
  90418. * @return the found node or null if not found at all
  90419. */
  90420. getLastEntryByID(id: string): Nullable<Node>;
  90421. /**
  90422. * Gets a node (Mesh, Camera, Light) using a given id
  90423. * @param id defines the id to search for
  90424. * @return the found node or null if not found at all
  90425. */
  90426. getNodeByID(id: string): Nullable<Node>;
  90427. /**
  90428. * Gets a node (Mesh, Camera, Light) using a given name
  90429. * @param name defines the name to search for
  90430. * @return the found node or null if not found at all.
  90431. */
  90432. getNodeByName(name: string): Nullable<Node>;
  90433. /**
  90434. * Gets a mesh using a given name
  90435. * @param name defines the name to search for
  90436. * @return the found mesh or null if not found at all.
  90437. */
  90438. getMeshByName(name: string): Nullable<AbstractMesh>;
  90439. /**
  90440. * Gets a transform node using a given name
  90441. * @param name defines the name to search for
  90442. * @return the found transform node or null if not found at all.
  90443. */
  90444. getTransformNodeByName(name: string): Nullable<TransformNode>;
  90445. /**
  90446. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  90447. * @param id defines the id to search for
  90448. * @return the found skeleton or null if not found at all.
  90449. */
  90450. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  90451. /**
  90452. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  90453. * @param id defines the id to search for
  90454. * @return the found skeleton or null if not found at all.
  90455. */
  90456. getSkeletonById(id: string): Nullable<Skeleton>;
  90457. /**
  90458. * Gets a skeleton using a given name
  90459. * @param name defines the name to search for
  90460. * @return the found skeleton or null if not found at all.
  90461. */
  90462. getSkeletonByName(name: string): Nullable<Skeleton>;
  90463. /**
  90464. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  90465. * @param id defines the id to search for
  90466. * @return the found morph target manager or null if not found at all.
  90467. */
  90468. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  90469. /**
  90470. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  90471. * @param id defines the id to search for
  90472. * @return the found morph target or null if not found at all.
  90473. */
  90474. getMorphTargetById(id: string): Nullable<MorphTarget>;
  90475. /**
  90476. * Gets a boolean indicating if the given mesh is active
  90477. * @param mesh defines the mesh to look for
  90478. * @returns true if the mesh is in the active list
  90479. */
  90480. isActiveMesh(mesh: AbstractMesh): boolean;
  90481. /**
  90482. * Return a unique id as a string which can serve as an identifier for the scene
  90483. */
  90484. readonly uid: string;
  90485. /**
  90486. * Add an externaly attached data from its key.
  90487. * This method call will fail and return false, if such key already exists.
  90488. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  90489. * @param key the unique key that identifies the data
  90490. * @param data the data object to associate to the key for this Engine instance
  90491. * @return true if no such key were already present and the data was added successfully, false otherwise
  90492. */
  90493. addExternalData<T>(key: string, data: T): boolean;
  90494. /**
  90495. * Get an externaly attached data from its key
  90496. * @param key the unique key that identifies the data
  90497. * @return the associated data, if present (can be null), or undefined if not present
  90498. */
  90499. getExternalData<T>(key: string): Nullable<T>;
  90500. /**
  90501. * Get an externaly attached data from its key, create it using a factory if it's not already present
  90502. * @param key the unique key that identifies the data
  90503. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  90504. * @return the associated data, can be null if the factory returned null.
  90505. */
  90506. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  90507. /**
  90508. * Remove an externaly attached data from the Engine instance
  90509. * @param key the unique key that identifies the data
  90510. * @return true if the data was successfully removed, false if it doesn't exist
  90511. */
  90512. removeExternalData(key: string): boolean;
  90513. private _evaluateSubMesh;
  90514. /**
  90515. * Clear the processed materials smart array preventing retention point in material dispose.
  90516. */
  90517. freeProcessedMaterials(): void;
  90518. private _preventFreeActiveMeshesAndRenderingGroups;
  90519. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  90520. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  90521. * when disposing several meshes in a row or a hierarchy of meshes.
  90522. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  90523. */
  90524. blockfreeActiveMeshesAndRenderingGroups: boolean;
  90525. /**
  90526. * Clear the active meshes smart array preventing retention point in mesh dispose.
  90527. */
  90528. freeActiveMeshes(): void;
  90529. /**
  90530. * Clear the info related to rendering groups preventing retention points during dispose.
  90531. */
  90532. freeRenderingGroups(): void;
  90533. /** @hidden */
  90534. _isInIntermediateRendering(): boolean;
  90535. /**
  90536. * Lambda returning the list of potentially active meshes.
  90537. */
  90538. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  90539. /**
  90540. * Lambda returning the list of potentially active sub meshes.
  90541. */
  90542. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  90543. /**
  90544. * Lambda returning the list of potentially intersecting sub meshes.
  90545. */
  90546. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  90547. /**
  90548. * Lambda returning the list of potentially colliding sub meshes.
  90549. */
  90550. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  90551. private _activeMeshesFrozen;
  90552. /**
  90553. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  90554. * @returns the current scene
  90555. */
  90556. freezeActiveMeshes(): Scene;
  90557. /**
  90558. * Use this function to restart evaluating active meshes on every frame
  90559. * @returns the current scene
  90560. */
  90561. unfreezeActiveMeshes(): Scene;
  90562. private _evaluateActiveMeshes;
  90563. private _activeMesh;
  90564. /**
  90565. * Update the transform matrix to update from the current active camera
  90566. * @param force defines a boolean used to force the update even if cache is up to date
  90567. */
  90568. updateTransformMatrix(force?: boolean): void;
  90569. /**
  90570. * 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)
  90571. * @param alternateCamera defines the camera to use
  90572. */
  90573. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  90574. /** @hidden */
  90575. _allowPostProcessClearColor: boolean;
  90576. private _renderForCamera;
  90577. private _processSubCameras;
  90578. private _checkIntersections;
  90579. /** @hidden */
  90580. _advancePhysicsEngineStep(step: number): void;
  90581. /**
  90582. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  90583. */
  90584. getDeterministicFrameTime: () => number;
  90585. /** @hidden */
  90586. _animate(): void;
  90587. /**
  90588. * Render the scene
  90589. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90590. */
  90591. render(updateCameras?: boolean): void;
  90592. /**
  90593. * Freeze all materials
  90594. * A frozen material will not be updatable but should be faster to render
  90595. */
  90596. freezeMaterials(): void;
  90597. /**
  90598. * Unfreeze all materials
  90599. * A frozen material will not be updatable but should be faster to render
  90600. */
  90601. unfreezeMaterials(): void;
  90602. /**
  90603. * Releases all held ressources
  90604. */
  90605. dispose(): void;
  90606. /**
  90607. * Gets if the scene is already disposed
  90608. */
  90609. readonly isDisposed: boolean;
  90610. /**
  90611. * Call this function to reduce memory footprint of the scene.
  90612. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90613. */
  90614. clearCachedVertexData(): void;
  90615. /**
  90616. * This function will remove the local cached buffer data from texture.
  90617. * It will save memory but will prevent the texture from being rebuilt
  90618. */
  90619. cleanCachedTextureBuffer(): void;
  90620. /**
  90621. * Get the world extend vectors with an optional filter
  90622. *
  90623. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90624. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90625. */
  90626. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90627. min: Vector3;
  90628. max: Vector3;
  90629. };
  90630. /**
  90631. * Creates a ray that can be used to pick in the scene
  90632. * @param x defines the x coordinate of the origin (on-screen)
  90633. * @param y defines the y coordinate of the origin (on-screen)
  90634. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90635. * @param camera defines the camera to use for the picking
  90636. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90637. * @returns a Ray
  90638. */
  90639. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90640. /**
  90641. * Creates a ray that can be used to pick in the scene
  90642. * @param x defines the x coordinate of the origin (on-screen)
  90643. * @param y defines the y coordinate of the origin (on-screen)
  90644. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90645. * @param result defines the ray where to store the picking ray
  90646. * @param camera defines the camera to use for the picking
  90647. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90648. * @returns the current scene
  90649. */
  90650. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90651. /**
  90652. * Creates a ray that can be used to pick in the scene
  90653. * @param x defines the x coordinate of the origin (on-screen)
  90654. * @param y defines the y coordinate of the origin (on-screen)
  90655. * @param camera defines the camera to use for the picking
  90656. * @returns a Ray
  90657. */
  90658. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90659. /**
  90660. * Creates a ray that can be used to pick in the scene
  90661. * @param x defines the x coordinate of the origin (on-screen)
  90662. * @param y defines the y coordinate of the origin (on-screen)
  90663. * @param result defines the ray where to store the picking ray
  90664. * @param camera defines the camera to use for the picking
  90665. * @returns the current scene
  90666. */
  90667. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90668. /** Launch a ray to try to pick a mesh in the scene
  90669. * @param x position on screen
  90670. * @param y position on screen
  90671. * @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
  90672. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90673. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90674. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90675. * @returns a PickingInfo
  90676. */
  90677. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90678. /** Use the given ray to pick a mesh in the scene
  90679. * @param ray The ray to use to pick meshes
  90680. * @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
  90681. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90682. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90683. * @returns a PickingInfo
  90684. */
  90685. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90686. /**
  90687. * Launch a ray to try to pick a mesh in the scene
  90688. * @param x X position on screen
  90689. * @param y Y position on screen
  90690. * @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
  90691. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90692. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90693. * @returns an array of PickingInfo
  90694. */
  90695. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90696. /**
  90697. * Launch a ray to try to pick a mesh in the scene
  90698. * @param ray Ray to use
  90699. * @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
  90700. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90701. * @returns an array of PickingInfo
  90702. */
  90703. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90704. /**
  90705. * Force the value of meshUnderPointer
  90706. * @param mesh defines the mesh to use
  90707. */
  90708. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90709. /**
  90710. * Gets the mesh under the pointer
  90711. * @returns a Mesh or null if no mesh is under the pointer
  90712. */
  90713. getPointerOverMesh(): Nullable<AbstractMesh>;
  90714. /** @hidden */
  90715. _rebuildGeometries(): void;
  90716. /** @hidden */
  90717. _rebuildTextures(): void;
  90718. private _getByTags;
  90719. /**
  90720. * Get a list of meshes by tags
  90721. * @param tagsQuery defines the tags query to use
  90722. * @param forEach defines a predicate used to filter results
  90723. * @returns an array of Mesh
  90724. */
  90725. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90726. /**
  90727. * Get a list of cameras by tags
  90728. * @param tagsQuery defines the tags query to use
  90729. * @param forEach defines a predicate used to filter results
  90730. * @returns an array of Camera
  90731. */
  90732. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90733. /**
  90734. * Get a list of lights by tags
  90735. * @param tagsQuery defines the tags query to use
  90736. * @param forEach defines a predicate used to filter results
  90737. * @returns an array of Light
  90738. */
  90739. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90740. /**
  90741. * Get a list of materials by tags
  90742. * @param tagsQuery defines the tags query to use
  90743. * @param forEach defines a predicate used to filter results
  90744. * @returns an array of Material
  90745. */
  90746. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90747. /**
  90748. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90749. * This allowed control for front to back rendering or reversly depending of the special needs.
  90750. *
  90751. * @param renderingGroupId The rendering group id corresponding to its index
  90752. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90753. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90754. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90755. */
  90756. 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;
  90757. /**
  90758. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90759. *
  90760. * @param renderingGroupId The rendering group id corresponding to its index
  90761. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90762. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90763. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90764. */
  90765. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90766. /**
  90767. * Gets the current auto clear configuration for one rendering group of the rendering
  90768. * manager.
  90769. * @param index the rendering group index to get the information for
  90770. * @returns The auto clear setup for the requested rendering group
  90771. */
  90772. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90773. private _blockMaterialDirtyMechanism;
  90774. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90775. blockMaterialDirtyMechanism: boolean;
  90776. /**
  90777. * Will flag all materials as dirty to trigger new shader compilation
  90778. * @param flag defines the flag used to specify which material part must be marked as dirty
  90779. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90780. */
  90781. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90782. /** @hidden */
  90783. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  90784. /** @hidden */
  90785. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90786. }
  90787. }
  90788. declare module BABYLON {
  90789. /**
  90790. * Set of assets to keep when moving a scene into an asset container.
  90791. */
  90792. export class KeepAssets extends AbstractScene {
  90793. }
  90794. /**
  90795. * Container with a set of assets that can be added or removed from a scene.
  90796. */
  90797. export class AssetContainer extends AbstractScene {
  90798. /**
  90799. * The scene the AssetContainer belongs to.
  90800. */
  90801. scene: Scene;
  90802. /**
  90803. * Instantiates an AssetContainer.
  90804. * @param scene The scene the AssetContainer belongs to.
  90805. */
  90806. constructor(scene: Scene);
  90807. /**
  90808. * Adds all the assets from the container to the scene.
  90809. */
  90810. addAllToScene(): void;
  90811. /**
  90812. * Removes all the assets in the container from the scene
  90813. */
  90814. removeAllFromScene(): void;
  90815. /**
  90816. * Disposes all the assets in the container
  90817. */
  90818. dispose(): void;
  90819. private _moveAssets;
  90820. /**
  90821. * Removes all the assets contained in the scene and adds them to the container.
  90822. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90823. */
  90824. moveAllFromScene(keepAssets?: KeepAssets): void;
  90825. /**
  90826. * 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.
  90827. * @returns the root mesh
  90828. */
  90829. createRootMesh(): Mesh;
  90830. }
  90831. }
  90832. declare module BABYLON {
  90833. /**
  90834. * Defines how the parser contract is defined.
  90835. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90836. */
  90837. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90838. /**
  90839. * Defines how the individual parser contract is defined.
  90840. * These parser can parse an individual asset
  90841. */
  90842. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90843. /**
  90844. * Base class of the scene acting as a container for the different elements composing a scene.
  90845. * This class is dynamically extended by the different components of the scene increasing
  90846. * flexibility and reducing coupling
  90847. */
  90848. export abstract class AbstractScene {
  90849. /**
  90850. * Stores the list of available parsers in the application.
  90851. */
  90852. private static _BabylonFileParsers;
  90853. /**
  90854. * Stores the list of available individual parsers in the application.
  90855. */
  90856. private static _IndividualBabylonFileParsers;
  90857. /**
  90858. * Adds a parser in the list of available ones
  90859. * @param name Defines the name of the parser
  90860. * @param parser Defines the parser to add
  90861. */
  90862. static AddParser(name: string, parser: BabylonFileParser): void;
  90863. /**
  90864. * Gets a general parser from the list of avaialble ones
  90865. * @param name Defines the name of the parser
  90866. * @returns the requested parser or null
  90867. */
  90868. static GetParser(name: string): Nullable<BabylonFileParser>;
  90869. /**
  90870. * Adds n individual parser in the list of available ones
  90871. * @param name Defines the name of the parser
  90872. * @param parser Defines the parser to add
  90873. */
  90874. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90875. /**
  90876. * Gets an individual parser from the list of avaialble ones
  90877. * @param name Defines the name of the parser
  90878. * @returns the requested parser or null
  90879. */
  90880. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90881. /**
  90882. * Parser json data and populate both a scene and its associated container object
  90883. * @param jsonData Defines the data to parse
  90884. * @param scene Defines the scene to parse the data for
  90885. * @param container Defines the container attached to the parsing sequence
  90886. * @param rootUrl Defines the root url of the data
  90887. */
  90888. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90889. /**
  90890. * Gets the list of root nodes (ie. nodes with no parent)
  90891. */
  90892. rootNodes: Node[];
  90893. /** All of the cameras added to this scene
  90894. * @see http://doc.babylonjs.com/babylon101/cameras
  90895. */
  90896. cameras: Camera[];
  90897. /**
  90898. * All of the lights added to this scene
  90899. * @see http://doc.babylonjs.com/babylon101/lights
  90900. */
  90901. lights: Light[];
  90902. /**
  90903. * All of the (abstract) meshes added to this scene
  90904. */
  90905. meshes: AbstractMesh[];
  90906. /**
  90907. * The list of skeletons added to the scene
  90908. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90909. */
  90910. skeletons: Skeleton[];
  90911. /**
  90912. * All of the particle systems added to this scene
  90913. * @see http://doc.babylonjs.com/babylon101/particles
  90914. */
  90915. particleSystems: IParticleSystem[];
  90916. /**
  90917. * Gets a list of Animations associated with the scene
  90918. */
  90919. animations: Animation[];
  90920. /**
  90921. * All of the animation groups added to this scene
  90922. * @see http://doc.babylonjs.com/how_to/group
  90923. */
  90924. animationGroups: AnimationGroup[];
  90925. /**
  90926. * All of the multi-materials added to this scene
  90927. * @see http://doc.babylonjs.com/how_to/multi_materials
  90928. */
  90929. multiMaterials: MultiMaterial[];
  90930. /**
  90931. * All of the materials added to this scene
  90932. * In the context of a Scene, it is not supposed to be modified manually.
  90933. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90934. * Note also that the order of the Material wihin the array is not significant and might change.
  90935. * @see http://doc.babylonjs.com/babylon101/materials
  90936. */
  90937. materials: Material[];
  90938. /**
  90939. * The list of morph target managers added to the scene
  90940. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90941. */
  90942. morphTargetManagers: MorphTargetManager[];
  90943. /**
  90944. * The list of geometries used in the scene.
  90945. */
  90946. geometries: Geometry[];
  90947. /**
  90948. * All of the tranform nodes added to this scene
  90949. * In the context of a Scene, it is not supposed to be modified manually.
  90950. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90951. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90952. * @see http://doc.babylonjs.com/how_to/transformnode
  90953. */
  90954. transformNodes: TransformNode[];
  90955. /**
  90956. * ActionManagers available on the scene.
  90957. */
  90958. actionManagers: AbstractActionManager[];
  90959. /**
  90960. * Textures to keep.
  90961. */
  90962. textures: BaseTexture[];
  90963. }
  90964. }
  90965. declare module BABYLON {
  90966. /**
  90967. * Defines a sound that can be played in the application.
  90968. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90970. */
  90971. export class Sound {
  90972. /**
  90973. * The name of the sound in the scene.
  90974. */
  90975. name: string;
  90976. /**
  90977. * Does the sound autoplay once loaded.
  90978. */
  90979. autoplay: boolean;
  90980. /**
  90981. * Does the sound loop after it finishes playing once.
  90982. */
  90983. loop: boolean;
  90984. /**
  90985. * Does the sound use a custom attenuation curve to simulate the falloff
  90986. * happening when the source gets further away from the camera.
  90987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90988. */
  90989. useCustomAttenuation: boolean;
  90990. /**
  90991. * The sound track id this sound belongs to.
  90992. */
  90993. soundTrackId: number;
  90994. /**
  90995. * Is this sound currently played.
  90996. */
  90997. isPlaying: boolean;
  90998. /**
  90999. * Is this sound currently paused.
  91000. */
  91001. isPaused: boolean;
  91002. /**
  91003. * Does this sound enables spatial sound.
  91004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91005. */
  91006. spatialSound: boolean;
  91007. /**
  91008. * Define the reference distance the sound should be heard perfectly.
  91009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91010. */
  91011. refDistance: number;
  91012. /**
  91013. * Define the roll off factor of spatial sounds.
  91014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91015. */
  91016. rolloffFactor: number;
  91017. /**
  91018. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  91019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91020. */
  91021. maxDistance: number;
  91022. /**
  91023. * Define the distance attenuation model the sound will follow.
  91024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91025. */
  91026. distanceModel: string;
  91027. /**
  91028. * @hidden
  91029. * Back Compat
  91030. **/
  91031. onended: () => any;
  91032. /**
  91033. * Observable event when the current playing sound finishes.
  91034. */
  91035. onEndedObservable: Observable<Sound>;
  91036. private _panningModel;
  91037. private _playbackRate;
  91038. private _streaming;
  91039. private _startTime;
  91040. private _startOffset;
  91041. private _position;
  91042. /** @hidden */
  91043. _positionInEmitterSpace: boolean;
  91044. private _localDirection;
  91045. private _volume;
  91046. private _isReadyToPlay;
  91047. private _isDirectional;
  91048. private _readyToPlayCallback;
  91049. private _audioBuffer;
  91050. private _soundSource;
  91051. private _streamingSource;
  91052. private _soundPanner;
  91053. private _soundGain;
  91054. private _inputAudioNode;
  91055. private _outputAudioNode;
  91056. private _coneInnerAngle;
  91057. private _coneOuterAngle;
  91058. private _coneOuterGain;
  91059. private _scene;
  91060. private _connectedTransformNode;
  91061. private _customAttenuationFunction;
  91062. private _registerFunc;
  91063. private _isOutputConnected;
  91064. private _htmlAudioElement;
  91065. private _urlType;
  91066. /** @hidden */
  91067. static _SceneComponentInitialization: (scene: Scene) => void;
  91068. /**
  91069. * Create a sound and attach it to a scene
  91070. * @param name Name of your sound
  91071. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  91072. * @param scene defines the scene the sound belongs to
  91073. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  91074. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  91075. */
  91076. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  91077. /**
  91078. * Release the sound and its associated resources
  91079. */
  91080. dispose(): void;
  91081. /**
  91082. * Gets if the sounds is ready to be played or not.
  91083. * @returns true if ready, otherwise false
  91084. */
  91085. isReady(): boolean;
  91086. private _soundLoaded;
  91087. /**
  91088. * Sets the data of the sound from an audiobuffer
  91089. * @param audioBuffer The audioBuffer containing the data
  91090. */
  91091. setAudioBuffer(audioBuffer: AudioBuffer): void;
  91092. /**
  91093. * Updates the current sounds options such as maxdistance, loop...
  91094. * @param options A JSON object containing values named as the object properties
  91095. */
  91096. updateOptions(options: any): void;
  91097. private _createSpatialParameters;
  91098. private _updateSpatialParameters;
  91099. /**
  91100. * Switch the panning model to HRTF:
  91101. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91103. */
  91104. switchPanningModelToHRTF(): void;
  91105. /**
  91106. * Switch the panning model to Equal Power:
  91107. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91109. */
  91110. switchPanningModelToEqualPower(): void;
  91111. private _switchPanningModel;
  91112. /**
  91113. * Connect this sound to a sound track audio node like gain...
  91114. * @param soundTrackAudioNode the sound track audio node to connect to
  91115. */
  91116. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  91117. /**
  91118. * Transform this sound into a directional source
  91119. * @param coneInnerAngle Size of the inner cone in degree
  91120. * @param coneOuterAngle Size of the outer cone in degree
  91121. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  91122. */
  91123. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  91124. /**
  91125. * Gets or sets the inner angle for the directional cone.
  91126. */
  91127. /**
  91128. * Gets or sets the inner angle for the directional cone.
  91129. */
  91130. directionalConeInnerAngle: number;
  91131. /**
  91132. * Gets or sets the outer angle for the directional cone.
  91133. */
  91134. /**
  91135. * Gets or sets the outer angle for the directional cone.
  91136. */
  91137. directionalConeOuterAngle: number;
  91138. /**
  91139. * Sets the position of the emitter if spatial sound is enabled
  91140. * @param newPosition Defines the new posisiton
  91141. */
  91142. setPosition(newPosition: Vector3): void;
  91143. /**
  91144. * Sets the local direction of the emitter if spatial sound is enabled
  91145. * @param newLocalDirection Defines the new local direction
  91146. */
  91147. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  91148. private _updateDirection;
  91149. /** @hidden */
  91150. updateDistanceFromListener(): void;
  91151. /**
  91152. * Sets a new custom attenuation function for the sound.
  91153. * @param callback Defines the function used for the attenuation
  91154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91155. */
  91156. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  91157. /**
  91158. * Play the sound
  91159. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  91160. * @param offset (optional) Start the sound setting it at a specific time
  91161. */
  91162. play(time?: number, offset?: number): void;
  91163. private _onended;
  91164. /**
  91165. * Stop the sound
  91166. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  91167. */
  91168. stop(time?: number): void;
  91169. /**
  91170. * Put the sound in pause
  91171. */
  91172. pause(): void;
  91173. /**
  91174. * Sets a dedicated volume for this sounds
  91175. * @param newVolume Define the new volume of the sound
  91176. * @param time Define in how long the sound should be at this value
  91177. */
  91178. setVolume(newVolume: number, time?: number): void;
  91179. /**
  91180. * Set the sound play back rate
  91181. * @param newPlaybackRate Define the playback rate the sound should be played at
  91182. */
  91183. setPlaybackRate(newPlaybackRate: number): void;
  91184. /**
  91185. * Gets the volume of the sound.
  91186. * @returns the volume of the sound
  91187. */
  91188. getVolume(): number;
  91189. /**
  91190. * Attach the sound to a dedicated mesh
  91191. * @param transformNode The transform node to connect the sound with
  91192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91193. */
  91194. attachToMesh(transformNode: TransformNode): void;
  91195. /**
  91196. * Detach the sound from the previously attached mesh
  91197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91198. */
  91199. detachFromMesh(): void;
  91200. private _onRegisterAfterWorldMatrixUpdate;
  91201. /**
  91202. * Clone the current sound in the scene.
  91203. * @returns the new sound clone
  91204. */
  91205. clone(): Nullable<Sound>;
  91206. /**
  91207. * Gets the current underlying audio buffer containing the data
  91208. * @returns the audio buffer
  91209. */
  91210. getAudioBuffer(): Nullable<AudioBuffer>;
  91211. /**
  91212. * Serializes the Sound in a JSON representation
  91213. * @returns the JSON representation of the sound
  91214. */
  91215. serialize(): any;
  91216. /**
  91217. * Parse a JSON representation of a sound to innstantiate in a given scene
  91218. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  91219. * @param scene Define the scene the new parsed sound should be created in
  91220. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  91221. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  91222. * @returns the newly parsed sound
  91223. */
  91224. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  91225. }
  91226. }
  91227. declare module BABYLON {
  91228. /**
  91229. * This defines an action helpful to play a defined sound on a triggered action.
  91230. */
  91231. export class PlaySoundAction extends Action {
  91232. private _sound;
  91233. /**
  91234. * Instantiate the action
  91235. * @param triggerOptions defines the trigger options
  91236. * @param sound defines the sound to play
  91237. * @param condition defines the trigger related conditions
  91238. */
  91239. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  91240. /** @hidden */
  91241. _prepare(): void;
  91242. /**
  91243. * Execute the action and play the sound.
  91244. */
  91245. execute(): void;
  91246. /**
  91247. * Serializes the actions and its related information.
  91248. * @param parent defines the object to serialize in
  91249. * @returns the serialized object
  91250. */
  91251. serialize(parent: any): any;
  91252. }
  91253. /**
  91254. * This defines an action helpful to stop a defined sound on a triggered action.
  91255. */
  91256. export class StopSoundAction extends Action {
  91257. private _sound;
  91258. /**
  91259. * Instantiate the action
  91260. * @param triggerOptions defines the trigger options
  91261. * @param sound defines the sound to stop
  91262. * @param condition defines the trigger related conditions
  91263. */
  91264. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  91265. /** @hidden */
  91266. _prepare(): void;
  91267. /**
  91268. * Execute the action and stop the sound.
  91269. */
  91270. execute(): void;
  91271. /**
  91272. * Serializes the actions and its related information.
  91273. * @param parent defines the object to serialize in
  91274. * @returns the serialized object
  91275. */
  91276. serialize(parent: any): any;
  91277. }
  91278. }
  91279. declare module BABYLON {
  91280. /**
  91281. * This defines an action responsible to change the value of a property
  91282. * by interpolating between its current value and the newly set one once triggered.
  91283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91284. */
  91285. export class InterpolateValueAction extends Action {
  91286. /**
  91287. * Defines the path of the property where the value should be interpolated
  91288. */
  91289. propertyPath: string;
  91290. /**
  91291. * Defines the target value at the end of the interpolation.
  91292. */
  91293. value: any;
  91294. /**
  91295. * Defines the time it will take for the property to interpolate to the value.
  91296. */
  91297. duration: number;
  91298. /**
  91299. * Defines if the other scene animations should be stopped when the action has been triggered
  91300. */
  91301. stopOtherAnimations?: boolean;
  91302. /**
  91303. * Defines a callback raised once the interpolation animation has been done.
  91304. */
  91305. onInterpolationDone?: () => void;
  91306. /**
  91307. * Observable triggered once the interpolation animation has been done.
  91308. */
  91309. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  91310. private _target;
  91311. private _effectiveTarget;
  91312. private _property;
  91313. /**
  91314. * Instantiate the action
  91315. * @param triggerOptions defines the trigger options
  91316. * @param target defines the object containing the value to interpolate
  91317. * @param propertyPath defines the path to the property in the target object
  91318. * @param value defines the target value at the end of the interpolation
  91319. * @param duration deines the time it will take for the property to interpolate to the value.
  91320. * @param condition defines the trigger related conditions
  91321. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  91322. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  91323. */
  91324. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  91325. /** @hidden */
  91326. _prepare(): void;
  91327. /**
  91328. * Execute the action starts the value interpolation.
  91329. */
  91330. execute(): void;
  91331. /**
  91332. * Serializes the actions and its related information.
  91333. * @param parent defines the object to serialize in
  91334. * @returns the serialized object
  91335. */
  91336. serialize(parent: any): any;
  91337. }
  91338. }
  91339. declare module BABYLON {
  91340. /**
  91341. * Options allowed during the creation of a sound track.
  91342. */
  91343. export interface ISoundTrackOptions {
  91344. /**
  91345. * The volume the sound track should take during creation
  91346. */
  91347. volume?: number;
  91348. /**
  91349. * Define if the sound track is the main sound track of the scene
  91350. */
  91351. mainTrack?: boolean;
  91352. }
  91353. /**
  91354. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  91355. * It will be also used in a future release to apply effects on a specific track.
  91356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91357. */
  91358. export class SoundTrack {
  91359. /**
  91360. * The unique identifier of the sound track in the scene.
  91361. */
  91362. id: number;
  91363. /**
  91364. * The list of sounds included in the sound track.
  91365. */
  91366. soundCollection: Array<Sound>;
  91367. private _outputAudioNode;
  91368. private _scene;
  91369. private _isMainTrack;
  91370. private _connectedAnalyser;
  91371. private _options;
  91372. private _isInitialized;
  91373. /**
  91374. * Creates a new sound track.
  91375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91376. * @param scene Define the scene the sound track belongs to
  91377. * @param options
  91378. */
  91379. constructor(scene: Scene, options?: ISoundTrackOptions);
  91380. private _initializeSoundTrackAudioGraph;
  91381. /**
  91382. * Release the sound track and its associated resources
  91383. */
  91384. dispose(): void;
  91385. /**
  91386. * Adds a sound to this sound track
  91387. * @param sound define the cound to add
  91388. * @ignoreNaming
  91389. */
  91390. AddSound(sound: Sound): void;
  91391. /**
  91392. * Removes a sound to this sound track
  91393. * @param sound define the cound to remove
  91394. * @ignoreNaming
  91395. */
  91396. RemoveSound(sound: Sound): void;
  91397. /**
  91398. * Set a global volume for the full sound track.
  91399. * @param newVolume Define the new volume of the sound track
  91400. */
  91401. setVolume(newVolume: number): void;
  91402. /**
  91403. * Switch the panning model to HRTF:
  91404. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91406. */
  91407. switchPanningModelToHRTF(): void;
  91408. /**
  91409. * Switch the panning model to Equal Power:
  91410. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91411. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91412. */
  91413. switchPanningModelToEqualPower(): void;
  91414. /**
  91415. * Connect the sound track to an audio analyser allowing some amazing
  91416. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  91417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  91418. * @param analyser The analyser to connect to the engine
  91419. */
  91420. connectToAnalyser(analyser: Analyser): void;
  91421. }
  91422. }
  91423. declare module BABYLON {
  91424. interface AbstractScene {
  91425. /**
  91426. * The list of sounds used in the scene.
  91427. */
  91428. sounds: Nullable<Array<Sound>>;
  91429. }
  91430. interface Scene {
  91431. /**
  91432. * @hidden
  91433. * Backing field
  91434. */
  91435. _mainSoundTrack: SoundTrack;
  91436. /**
  91437. * The main sound track played by the scene.
  91438. * It cotains your primary collection of sounds.
  91439. */
  91440. mainSoundTrack: SoundTrack;
  91441. /**
  91442. * The list of sound tracks added to the scene
  91443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91444. */
  91445. soundTracks: Nullable<Array<SoundTrack>>;
  91446. /**
  91447. * Gets a sound using a given name
  91448. * @param name defines the name to search for
  91449. * @return the found sound or null if not found at all.
  91450. */
  91451. getSoundByName(name: string): Nullable<Sound>;
  91452. /**
  91453. * Gets or sets if audio support is enabled
  91454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91455. */
  91456. audioEnabled: boolean;
  91457. /**
  91458. * Gets or sets if audio will be output to headphones
  91459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91460. */
  91461. headphone: boolean;
  91462. }
  91463. /**
  91464. * Defines the sound scene component responsible to manage any sounds
  91465. * in a given scene.
  91466. */
  91467. export class AudioSceneComponent implements ISceneSerializableComponent {
  91468. /**
  91469. * The component name helpfull to identify the component in the list of scene components.
  91470. */
  91471. readonly name: string;
  91472. /**
  91473. * The scene the component belongs to.
  91474. */
  91475. scene: Scene;
  91476. private _audioEnabled;
  91477. /**
  91478. * Gets whether audio is enabled or not.
  91479. * Please use related enable/disable method to switch state.
  91480. */
  91481. readonly audioEnabled: boolean;
  91482. private _headphone;
  91483. /**
  91484. * Gets whether audio is outputing to headphone or not.
  91485. * Please use the according Switch methods to change output.
  91486. */
  91487. readonly headphone: boolean;
  91488. /**
  91489. * Creates a new instance of the component for the given scene
  91490. * @param scene Defines the scene to register the component in
  91491. */
  91492. constructor(scene: Scene);
  91493. /**
  91494. * Registers the component in a given scene
  91495. */
  91496. register(): void;
  91497. /**
  91498. * Rebuilds the elements related to this component in case of
  91499. * context lost for instance.
  91500. */
  91501. rebuild(): void;
  91502. /**
  91503. * Serializes the component data to the specified json object
  91504. * @param serializationObject The object to serialize to
  91505. */
  91506. serialize(serializationObject: any): void;
  91507. /**
  91508. * Adds all the element from the container to the scene
  91509. * @param container the container holding the elements
  91510. */
  91511. addFromContainer(container: AbstractScene): void;
  91512. /**
  91513. * Removes all the elements in the container from the scene
  91514. * @param container contains the elements to remove
  91515. */
  91516. removeFromContainer(container: AbstractScene): void;
  91517. /**
  91518. * Disposes the component and the associated ressources.
  91519. */
  91520. dispose(): void;
  91521. /**
  91522. * Disables audio in the associated scene.
  91523. */
  91524. disableAudio(): void;
  91525. /**
  91526. * Enables audio in the associated scene.
  91527. */
  91528. enableAudio(): void;
  91529. /**
  91530. * Switch audio to headphone output.
  91531. */
  91532. switchAudioModeForHeadphones(): void;
  91533. /**
  91534. * Switch audio to normal speakers.
  91535. */
  91536. switchAudioModeForNormalSpeakers(): void;
  91537. private _afterRender;
  91538. }
  91539. }
  91540. declare module BABYLON {
  91541. /**
  91542. * Wraps one or more Sound objects and selects one with random weight for playback.
  91543. */
  91544. export class WeightedSound {
  91545. /** When true a Sound will be selected and played when the current playing Sound completes. */
  91546. loop: boolean;
  91547. private _coneInnerAngle;
  91548. private _coneOuterAngle;
  91549. private _volume;
  91550. /** A Sound is currently playing. */
  91551. isPlaying: boolean;
  91552. /** A Sound is currently paused. */
  91553. isPaused: boolean;
  91554. private _sounds;
  91555. private _weights;
  91556. private _currentIndex?;
  91557. /**
  91558. * Creates a new WeightedSound from the list of sounds given.
  91559. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  91560. * @param sounds Array of Sounds that will be selected from.
  91561. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  91562. */
  91563. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  91564. /**
  91565. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  91566. */
  91567. /**
  91568. * The size of cone in degress for a directional sound in which there will be no attenuation.
  91569. */
  91570. directionalConeInnerAngle: number;
  91571. /**
  91572. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91573. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91574. */
  91575. /**
  91576. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91577. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91578. */
  91579. directionalConeOuterAngle: number;
  91580. /**
  91581. * Playback volume.
  91582. */
  91583. /**
  91584. * Playback volume.
  91585. */
  91586. volume: number;
  91587. private _onended;
  91588. /**
  91589. * Suspend playback
  91590. */
  91591. pause(): void;
  91592. /**
  91593. * Stop playback
  91594. */
  91595. stop(): void;
  91596. /**
  91597. * Start playback.
  91598. * @param startOffset Position the clip head at a specific time in seconds.
  91599. */
  91600. play(startOffset?: number): void;
  91601. }
  91602. }
  91603. declare module BABYLON {
  91604. /**
  91605. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91606. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91607. */
  91608. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91609. /**
  91610. * Gets the name of the behavior.
  91611. */
  91612. readonly name: string;
  91613. /**
  91614. * The easing function used by animations
  91615. */
  91616. static EasingFunction: BackEase;
  91617. /**
  91618. * The easing mode used by animations
  91619. */
  91620. static EasingMode: number;
  91621. /**
  91622. * The duration of the animation, in milliseconds
  91623. */
  91624. transitionDuration: number;
  91625. /**
  91626. * Length of the distance animated by the transition when lower radius is reached
  91627. */
  91628. lowerRadiusTransitionRange: number;
  91629. /**
  91630. * Length of the distance animated by the transition when upper radius is reached
  91631. */
  91632. upperRadiusTransitionRange: number;
  91633. private _autoTransitionRange;
  91634. /**
  91635. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91636. */
  91637. /**
  91638. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91639. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91640. */
  91641. autoTransitionRange: boolean;
  91642. private _attachedCamera;
  91643. private _onAfterCheckInputsObserver;
  91644. private _onMeshTargetChangedObserver;
  91645. /**
  91646. * Initializes the behavior.
  91647. */
  91648. init(): void;
  91649. /**
  91650. * Attaches the behavior to its arc rotate camera.
  91651. * @param camera Defines the camera to attach the behavior to
  91652. */
  91653. attach(camera: ArcRotateCamera): void;
  91654. /**
  91655. * Detaches the behavior from its current arc rotate camera.
  91656. */
  91657. detach(): void;
  91658. private _radiusIsAnimating;
  91659. private _radiusBounceTransition;
  91660. private _animatables;
  91661. private _cachedWheelPrecision;
  91662. /**
  91663. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91664. * @param radiusLimit The limit to check against.
  91665. * @return Bool to indicate if at limit.
  91666. */
  91667. private _isRadiusAtLimit;
  91668. /**
  91669. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91670. * @param radiusDelta The delta by which to animate to. Can be negative.
  91671. */
  91672. private _applyBoundRadiusAnimation;
  91673. /**
  91674. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91675. */
  91676. protected _clearAnimationLocks(): void;
  91677. /**
  91678. * Stops and removes all animations that have been applied to the camera
  91679. */
  91680. stopAllAnimations(): void;
  91681. }
  91682. }
  91683. declare module BABYLON {
  91684. /**
  91685. * 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.
  91686. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91687. */
  91688. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91689. /**
  91690. * Gets the name of the behavior.
  91691. */
  91692. readonly name: string;
  91693. private _mode;
  91694. private _radiusScale;
  91695. private _positionScale;
  91696. private _defaultElevation;
  91697. private _elevationReturnTime;
  91698. private _elevationReturnWaitTime;
  91699. private _zoomStopsAnimation;
  91700. private _framingTime;
  91701. /**
  91702. * The easing function used by animations
  91703. */
  91704. static EasingFunction: ExponentialEase;
  91705. /**
  91706. * The easing mode used by animations
  91707. */
  91708. static EasingMode: number;
  91709. /**
  91710. * Sets the current mode used by the behavior
  91711. */
  91712. /**
  91713. * Gets current mode used by the behavior.
  91714. */
  91715. mode: number;
  91716. /**
  91717. * Sets the scale applied to the radius (1 by default)
  91718. */
  91719. /**
  91720. * Gets the scale applied to the radius
  91721. */
  91722. radiusScale: number;
  91723. /**
  91724. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91725. */
  91726. /**
  91727. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91728. */
  91729. positionScale: number;
  91730. /**
  91731. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91732. * behaviour is triggered, in radians.
  91733. */
  91734. /**
  91735. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91736. * behaviour is triggered, in radians.
  91737. */
  91738. defaultElevation: number;
  91739. /**
  91740. * Sets the time (in milliseconds) taken to return to the default beta position.
  91741. * Negative value indicates camera should not return to default.
  91742. */
  91743. /**
  91744. * Gets the time (in milliseconds) taken to return to the default beta position.
  91745. * Negative value indicates camera should not return to default.
  91746. */
  91747. elevationReturnTime: number;
  91748. /**
  91749. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91750. */
  91751. /**
  91752. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91753. */
  91754. elevationReturnWaitTime: number;
  91755. /**
  91756. * Sets the flag that indicates if user zooming should stop animation.
  91757. */
  91758. /**
  91759. * Gets the flag that indicates if user zooming should stop animation.
  91760. */
  91761. zoomStopsAnimation: boolean;
  91762. /**
  91763. * Sets the transition time when framing the mesh, in milliseconds
  91764. */
  91765. /**
  91766. * Gets the transition time when framing the mesh, in milliseconds
  91767. */
  91768. framingTime: number;
  91769. /**
  91770. * Define if the behavior should automatically change the configured
  91771. * camera limits and sensibilities.
  91772. */
  91773. autoCorrectCameraLimitsAndSensibility: boolean;
  91774. private _onPrePointerObservableObserver;
  91775. private _onAfterCheckInputsObserver;
  91776. private _onMeshTargetChangedObserver;
  91777. private _attachedCamera;
  91778. private _isPointerDown;
  91779. private _lastInteractionTime;
  91780. /**
  91781. * Initializes the behavior.
  91782. */
  91783. init(): void;
  91784. /**
  91785. * Attaches the behavior to its arc rotate camera.
  91786. * @param camera Defines the camera to attach the behavior to
  91787. */
  91788. attach(camera: ArcRotateCamera): void;
  91789. /**
  91790. * Detaches the behavior from its current arc rotate camera.
  91791. */
  91792. detach(): void;
  91793. private _animatables;
  91794. private _betaIsAnimating;
  91795. private _betaTransition;
  91796. private _radiusTransition;
  91797. private _vectorTransition;
  91798. /**
  91799. * Targets the given mesh and updates zoom level accordingly.
  91800. * @param mesh The mesh to target.
  91801. * @param radius Optional. If a cached radius position already exists, overrides default.
  91802. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91803. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91804. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91805. */
  91806. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91807. /**
  91808. * Targets the given mesh with its children and updates zoom level accordingly.
  91809. * @param mesh The mesh to target.
  91810. * @param radius Optional. If a cached radius position already exists, overrides default.
  91811. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91812. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91813. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91814. */
  91815. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91816. /**
  91817. * Targets the given meshes with their children and updates zoom level accordingly.
  91818. * @param meshes The mesh to target.
  91819. * @param radius Optional. If a cached radius position already exists, overrides default.
  91820. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91821. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91822. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91823. */
  91824. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91825. /**
  91826. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91827. * @param minimumWorld Determines the smaller position of the bounding box extend
  91828. * @param maximumWorld Determines the bigger position of the bounding box extend
  91829. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91830. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91831. */
  91832. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91833. /**
  91834. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91835. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91836. * frustum width.
  91837. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91838. * to fully enclose the mesh in the viewing frustum.
  91839. */
  91840. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91841. /**
  91842. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91843. * is automatically returned to its default position (expected to be above ground plane).
  91844. */
  91845. private _maintainCameraAboveGround;
  91846. /**
  91847. * Returns the frustum slope based on the canvas ratio and camera FOV
  91848. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91849. */
  91850. private _getFrustumSlope;
  91851. /**
  91852. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91853. */
  91854. private _clearAnimationLocks;
  91855. /**
  91856. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91857. */
  91858. private _applyUserInteraction;
  91859. /**
  91860. * Stops and removes all animations that have been applied to the camera
  91861. */
  91862. stopAllAnimations(): void;
  91863. /**
  91864. * Gets a value indicating if the user is moving the camera
  91865. */
  91866. readonly isUserIsMoving: boolean;
  91867. /**
  91868. * The camera can move all the way towards the mesh.
  91869. */
  91870. static IgnoreBoundsSizeMode: number;
  91871. /**
  91872. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91873. */
  91874. static FitFrustumSidesMode: number;
  91875. }
  91876. }
  91877. declare module BABYLON {
  91878. /**
  91879. * Base class for Camera Pointer Inputs.
  91880. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91881. * for example usage.
  91882. */
  91883. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91884. /**
  91885. * Defines the camera the input is attached to.
  91886. */
  91887. abstract camera: Camera;
  91888. /**
  91889. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91890. */
  91891. protected _altKey: boolean;
  91892. protected _ctrlKey: boolean;
  91893. protected _metaKey: boolean;
  91894. protected _shiftKey: boolean;
  91895. /**
  91896. * Which mouse buttons were pressed at time of last mouse event.
  91897. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91898. */
  91899. protected _buttonsPressed: number;
  91900. /**
  91901. * Defines the buttons associated with the input to handle camera move.
  91902. */
  91903. buttons: number[];
  91904. /**
  91905. * Attach the input controls to a specific dom element to get the input from.
  91906. * @param element Defines the element the controls should be listened from
  91907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91908. */
  91909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91910. /**
  91911. * Detach the current controls from the specified dom element.
  91912. * @param element Defines the element to stop listening the inputs from
  91913. */
  91914. detachControl(element: Nullable<HTMLElement>): void;
  91915. /**
  91916. * Gets the class name of the current input.
  91917. * @returns the class name
  91918. */
  91919. getClassName(): string;
  91920. /**
  91921. * Get the friendly name associated with the input class.
  91922. * @returns the input friendly name
  91923. */
  91924. getSimpleName(): string;
  91925. /**
  91926. * Called on pointer POINTERDOUBLETAP event.
  91927. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91928. */
  91929. protected onDoubleTap(type: string): void;
  91930. /**
  91931. * Called on pointer POINTERMOVE event if only a single touch is active.
  91932. * Override this method to provide functionality.
  91933. */
  91934. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91935. /**
  91936. * Called on pointer POINTERMOVE event if multiple touches are active.
  91937. * Override this method to provide functionality.
  91938. */
  91939. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91940. /**
  91941. * Called on JS contextmenu event.
  91942. * Override this method to provide functionality.
  91943. */
  91944. protected onContextMenu(evt: PointerEvent): void;
  91945. /**
  91946. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91947. * press.
  91948. * Override this method to provide functionality.
  91949. */
  91950. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91951. /**
  91952. * Called each time a new POINTERUP event occurs. Ie, for each button
  91953. * release.
  91954. * Override this method to provide functionality.
  91955. */
  91956. protected onButtonUp(evt: PointerEvent): void;
  91957. /**
  91958. * Called when window becomes inactive.
  91959. * Override this method to provide functionality.
  91960. */
  91961. protected onLostFocus(): void;
  91962. private _pointerInput;
  91963. private _observer;
  91964. private _onLostFocus;
  91965. }
  91966. }
  91967. declare module BABYLON {
  91968. /**
  91969. * Manage the pointers inputs to control an arc rotate camera.
  91970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91971. */
  91972. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91973. /**
  91974. * Defines the camera the input is attached to.
  91975. */
  91976. camera: ArcRotateCamera;
  91977. /**
  91978. * Gets the class name of the current input.
  91979. * @returns the class name
  91980. */
  91981. getClassName(): string;
  91982. /**
  91983. * Defines the buttons associated with the input to handle camera move.
  91984. */
  91985. buttons: number[];
  91986. /**
  91987. * Defines the pointer angular sensibility along the X axis or how fast is
  91988. * the camera rotating.
  91989. */
  91990. angularSensibilityX: number;
  91991. /**
  91992. * Defines the pointer angular sensibility along the Y axis or how fast is
  91993. * the camera rotating.
  91994. */
  91995. angularSensibilityY: number;
  91996. /**
  91997. * Defines the pointer pinch precision or how fast is the camera zooming.
  91998. */
  91999. pinchPrecision: number;
  92000. /**
  92001. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  92002. * from 0.
  92003. * It defines the percentage of current camera.radius to use as delta when
  92004. * pinch zoom is used.
  92005. */
  92006. pinchDeltaPercentage: number;
  92007. /**
  92008. * Defines the pointer panning sensibility or how fast is the camera moving.
  92009. */
  92010. panningSensibility: number;
  92011. /**
  92012. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  92013. */
  92014. multiTouchPanning: boolean;
  92015. /**
  92016. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  92017. * zoom (pinch) through multitouch.
  92018. */
  92019. multiTouchPanAndZoom: boolean;
  92020. /**
  92021. * Revers pinch action direction.
  92022. */
  92023. pinchInwards: boolean;
  92024. private _isPanClick;
  92025. private _twoFingerActivityCount;
  92026. private _isPinching;
  92027. /**
  92028. * Called on pointer POINTERMOVE event if only a single touch is active.
  92029. */
  92030. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92031. /**
  92032. * Called on pointer POINTERDOUBLETAP event.
  92033. */
  92034. protected onDoubleTap(type: string): void;
  92035. /**
  92036. * Called on pointer POINTERMOVE event if multiple touches are active.
  92037. */
  92038. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92039. /**
  92040. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92041. * press.
  92042. */
  92043. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  92044. /**
  92045. * Called each time a new POINTERUP event occurs. Ie, for each button
  92046. * release.
  92047. */
  92048. protected onButtonUp(evt: PointerEvent): void;
  92049. /**
  92050. * Called when window becomes inactive.
  92051. */
  92052. protected onLostFocus(): void;
  92053. }
  92054. }
  92055. declare module BABYLON {
  92056. /**
  92057. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  92058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92059. */
  92060. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  92061. /**
  92062. * Defines the camera the input is attached to.
  92063. */
  92064. camera: ArcRotateCamera;
  92065. /**
  92066. * Defines the list of key codes associated with the up action (increase alpha)
  92067. */
  92068. keysUp: number[];
  92069. /**
  92070. * Defines the list of key codes associated with the down action (decrease alpha)
  92071. */
  92072. keysDown: number[];
  92073. /**
  92074. * Defines the list of key codes associated with the left action (increase beta)
  92075. */
  92076. keysLeft: number[];
  92077. /**
  92078. * Defines the list of key codes associated with the right action (decrease beta)
  92079. */
  92080. keysRight: number[];
  92081. /**
  92082. * Defines the list of key codes associated with the reset action.
  92083. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  92084. */
  92085. keysReset: number[];
  92086. /**
  92087. * Defines the panning sensibility of the inputs.
  92088. * (How fast is the camera paning)
  92089. */
  92090. panningSensibility: number;
  92091. /**
  92092. * Defines the zooming sensibility of the inputs.
  92093. * (How fast is the camera zooming)
  92094. */
  92095. zoomingSensibility: number;
  92096. /**
  92097. * Defines wether maintaining the alt key down switch the movement mode from
  92098. * orientation to zoom.
  92099. */
  92100. useAltToZoom: boolean;
  92101. /**
  92102. * Rotation speed of the camera
  92103. */
  92104. angularSpeed: number;
  92105. private _keys;
  92106. private _ctrlPressed;
  92107. private _altPressed;
  92108. private _onCanvasBlurObserver;
  92109. private _onKeyboardObserver;
  92110. private _engine;
  92111. private _scene;
  92112. /**
  92113. * Attach the input controls to a specific dom element to get the input from.
  92114. * @param element Defines the element the controls should be listened from
  92115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92116. */
  92117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92118. /**
  92119. * Detach the current controls from the specified dom element.
  92120. * @param element Defines the element to stop listening the inputs from
  92121. */
  92122. detachControl(element: Nullable<HTMLElement>): void;
  92123. /**
  92124. * Update the current camera state depending on the inputs that have been used this frame.
  92125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92126. */
  92127. checkInputs(): void;
  92128. /**
  92129. * Gets the class name of the current intput.
  92130. * @returns the class name
  92131. */
  92132. getClassName(): string;
  92133. /**
  92134. * Get the friendly name associated with the input class.
  92135. * @returns the input friendly name
  92136. */
  92137. getSimpleName(): string;
  92138. }
  92139. }
  92140. declare module BABYLON {
  92141. /**
  92142. * Manage the mouse wheel inputs to control an arc rotate camera.
  92143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92144. */
  92145. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  92146. /**
  92147. * Defines the camera the input is attached to.
  92148. */
  92149. camera: ArcRotateCamera;
  92150. /**
  92151. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92152. */
  92153. wheelPrecision: number;
  92154. /**
  92155. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92156. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92157. */
  92158. wheelDeltaPercentage: number;
  92159. private _wheel;
  92160. private _observer;
  92161. /**
  92162. * Attach the input controls to a specific dom element to get the input from.
  92163. * @param element Defines the element the controls should be listened from
  92164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92165. */
  92166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92167. /**
  92168. * Detach the current controls from the specified dom element.
  92169. * @param element Defines the element to stop listening the inputs from
  92170. */
  92171. detachControl(element: Nullable<HTMLElement>): void;
  92172. /**
  92173. * Gets the class name of the current intput.
  92174. * @returns the class name
  92175. */
  92176. getClassName(): string;
  92177. /**
  92178. * Get the friendly name associated with the input class.
  92179. * @returns the input friendly name
  92180. */
  92181. getSimpleName(): string;
  92182. }
  92183. }
  92184. declare module BABYLON {
  92185. /**
  92186. * Default Inputs manager for the ArcRotateCamera.
  92187. * It groups all the default supported inputs for ease of use.
  92188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92189. */
  92190. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  92191. /**
  92192. * Instantiates a new ArcRotateCameraInputsManager.
  92193. * @param camera Defines the camera the inputs belong to
  92194. */
  92195. constructor(camera: ArcRotateCamera);
  92196. /**
  92197. * Add mouse wheel input support to the input manager.
  92198. * @returns the current input manager
  92199. */
  92200. addMouseWheel(): ArcRotateCameraInputsManager;
  92201. /**
  92202. * Add pointers input support to the input manager.
  92203. * @returns the current input manager
  92204. */
  92205. addPointers(): ArcRotateCameraInputsManager;
  92206. /**
  92207. * Add keyboard input support to the input manager.
  92208. * @returns the current input manager
  92209. */
  92210. addKeyboard(): ArcRotateCameraInputsManager;
  92211. }
  92212. }
  92213. declare module BABYLON {
  92214. /**
  92215. * This represents an orbital type of camera.
  92216. *
  92217. * 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.
  92218. * 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.
  92219. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  92220. */
  92221. export class ArcRotateCamera extends TargetCamera {
  92222. /**
  92223. * Defines the rotation angle of the camera along the longitudinal axis.
  92224. */
  92225. alpha: number;
  92226. /**
  92227. * Defines the rotation angle of the camera along the latitudinal axis.
  92228. */
  92229. beta: number;
  92230. /**
  92231. * Defines the radius of the camera from it s target point.
  92232. */
  92233. radius: number;
  92234. protected _target: Vector3;
  92235. protected _targetHost: Nullable<AbstractMesh>;
  92236. /**
  92237. * Defines the target point of the camera.
  92238. * The camera looks towards it form the radius distance.
  92239. */
  92240. target: Vector3;
  92241. /**
  92242. * Define the current local position of the camera in the scene
  92243. */
  92244. position: Vector3;
  92245. /**
  92246. * Current inertia value on the longitudinal axis.
  92247. * The bigger this number the longer it will take for the camera to stop.
  92248. */
  92249. inertialAlphaOffset: number;
  92250. /**
  92251. * Current inertia value on the latitudinal axis.
  92252. * The bigger this number the longer it will take for the camera to stop.
  92253. */
  92254. inertialBetaOffset: number;
  92255. /**
  92256. * Current inertia value on the radius axis.
  92257. * The bigger this number the longer it will take for the camera to stop.
  92258. */
  92259. inertialRadiusOffset: number;
  92260. /**
  92261. * Minimum allowed angle on the longitudinal axis.
  92262. * This can help limiting how the Camera is able to move in the scene.
  92263. */
  92264. lowerAlphaLimit: Nullable<number>;
  92265. /**
  92266. * Maximum allowed angle on the longitudinal axis.
  92267. * This can help limiting how the Camera is able to move in the scene.
  92268. */
  92269. upperAlphaLimit: Nullable<number>;
  92270. /**
  92271. * Minimum allowed angle on the latitudinal axis.
  92272. * This can help limiting how the Camera is able to move in the scene.
  92273. */
  92274. lowerBetaLimit: number;
  92275. /**
  92276. * Maximum allowed angle on the latitudinal axis.
  92277. * This can help limiting how the Camera is able to move in the scene.
  92278. */
  92279. upperBetaLimit: number;
  92280. /**
  92281. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  92282. * This can help limiting how the Camera is able to move in the scene.
  92283. */
  92284. lowerRadiusLimit: Nullable<number>;
  92285. /**
  92286. * Maximum allowed distance of the camera to the target (The camera can not get further).
  92287. * This can help limiting how the Camera is able to move in the scene.
  92288. */
  92289. upperRadiusLimit: Nullable<number>;
  92290. /**
  92291. * Defines the current inertia value used during panning of the camera along the X axis.
  92292. */
  92293. inertialPanningX: number;
  92294. /**
  92295. * Defines the current inertia value used during panning of the camera along the Y axis.
  92296. */
  92297. inertialPanningY: number;
  92298. /**
  92299. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  92300. * Basically if your fingers moves away from more than this distance you will be considered
  92301. * in pinch mode.
  92302. */
  92303. pinchToPanMaxDistance: number;
  92304. /**
  92305. * Defines the maximum distance the camera can pan.
  92306. * This could help keeping the cammera always in your scene.
  92307. */
  92308. panningDistanceLimit: Nullable<number>;
  92309. /**
  92310. * Defines the target of the camera before paning.
  92311. */
  92312. panningOriginTarget: Vector3;
  92313. /**
  92314. * Defines the value of the inertia used during panning.
  92315. * 0 would mean stop inertia and one would mean no decelleration at all.
  92316. */
  92317. panningInertia: number;
  92318. /**
  92319. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  92320. */
  92321. angularSensibilityX: number;
  92322. /**
  92323. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  92324. */
  92325. angularSensibilityY: number;
  92326. /**
  92327. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  92328. */
  92329. pinchPrecision: number;
  92330. /**
  92331. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  92332. * It will be used instead of pinchDeltaPrecision if different from 0.
  92333. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92334. */
  92335. pinchDeltaPercentage: number;
  92336. /**
  92337. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  92338. */
  92339. panningSensibility: number;
  92340. /**
  92341. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  92342. */
  92343. keysUp: number[];
  92344. /**
  92345. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  92346. */
  92347. keysDown: number[];
  92348. /**
  92349. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  92350. */
  92351. keysLeft: number[];
  92352. /**
  92353. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  92354. */
  92355. keysRight: number[];
  92356. /**
  92357. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92358. */
  92359. wheelPrecision: number;
  92360. /**
  92361. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  92362. * It will be used instead of pinchDeltaPrecision if different from 0.
  92363. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92364. */
  92365. wheelDeltaPercentage: number;
  92366. /**
  92367. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  92368. */
  92369. zoomOnFactor: number;
  92370. /**
  92371. * Defines a screen offset for the camera position.
  92372. */
  92373. targetScreenOffset: Vector2;
  92374. /**
  92375. * Allows the camera to be completely reversed.
  92376. * If false the camera can not arrive upside down.
  92377. */
  92378. allowUpsideDown: boolean;
  92379. /**
  92380. * Define if double tap/click is used to restore the previously saved state of the camera.
  92381. */
  92382. useInputToRestoreState: boolean;
  92383. /** @hidden */
  92384. _viewMatrix: Matrix;
  92385. /** @hidden */
  92386. _useCtrlForPanning: boolean;
  92387. /** @hidden */
  92388. _panningMouseButton: number;
  92389. /**
  92390. * Defines the input associated to the camera.
  92391. */
  92392. inputs: ArcRotateCameraInputsManager;
  92393. /** @hidden */
  92394. _reset: () => void;
  92395. /**
  92396. * Defines the allowed panning axis.
  92397. */
  92398. panningAxis: Vector3;
  92399. protected _localDirection: Vector3;
  92400. protected _transformedDirection: Vector3;
  92401. private _bouncingBehavior;
  92402. /**
  92403. * Gets the bouncing behavior of the camera if it has been enabled.
  92404. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92405. */
  92406. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  92407. /**
  92408. * Defines if the bouncing behavior of the camera is enabled on the camera.
  92409. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92410. */
  92411. useBouncingBehavior: boolean;
  92412. private _framingBehavior;
  92413. /**
  92414. * Gets the framing behavior of the camera if it has been enabled.
  92415. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92416. */
  92417. readonly framingBehavior: Nullable<FramingBehavior>;
  92418. /**
  92419. * Defines if the framing behavior of the camera is enabled on the camera.
  92420. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92421. */
  92422. useFramingBehavior: boolean;
  92423. private _autoRotationBehavior;
  92424. /**
  92425. * Gets the auto rotation behavior of the camera if it has been enabled.
  92426. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92427. */
  92428. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  92429. /**
  92430. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  92431. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92432. */
  92433. useAutoRotationBehavior: boolean;
  92434. /**
  92435. * Observable triggered when the mesh target has been changed on the camera.
  92436. */
  92437. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  92438. /**
  92439. * Event raised when the camera is colliding with a mesh.
  92440. */
  92441. onCollide: (collidedMesh: AbstractMesh) => void;
  92442. /**
  92443. * Defines whether the camera should check collision with the objects oh the scene.
  92444. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  92445. */
  92446. checkCollisions: boolean;
  92447. /**
  92448. * Defines the collision radius of the camera.
  92449. * This simulates a sphere around the camera.
  92450. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92451. */
  92452. collisionRadius: Vector3;
  92453. protected _collider: Collider;
  92454. protected _previousPosition: Vector3;
  92455. protected _collisionVelocity: Vector3;
  92456. protected _newPosition: Vector3;
  92457. protected _previousAlpha: number;
  92458. protected _previousBeta: number;
  92459. protected _previousRadius: number;
  92460. protected _collisionTriggered: boolean;
  92461. protected _targetBoundingCenter: Nullable<Vector3>;
  92462. private _computationVector;
  92463. private _tempAxisVector;
  92464. private _tempAxisRotationMatrix;
  92465. /**
  92466. * Instantiates a new ArcRotateCamera in a given scene
  92467. * @param name Defines the name of the camera
  92468. * @param alpha Defines the camera rotation along the logitudinal axis
  92469. * @param beta Defines the camera rotation along the latitudinal axis
  92470. * @param radius Defines the camera distance from its target
  92471. * @param target Defines the camera target
  92472. * @param scene Defines the scene the camera belongs to
  92473. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92474. */
  92475. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92476. /** @hidden */
  92477. _initCache(): void;
  92478. /** @hidden */
  92479. _updateCache(ignoreParentClass?: boolean): void;
  92480. protected _getTargetPosition(): Vector3;
  92481. private _storedAlpha;
  92482. private _storedBeta;
  92483. private _storedRadius;
  92484. private _storedTarget;
  92485. /**
  92486. * Stores the current state of the camera (alpha, beta, radius and target)
  92487. * @returns the camera itself
  92488. */
  92489. storeState(): Camera;
  92490. /**
  92491. * @hidden
  92492. * Restored camera state. You must call storeState() first
  92493. */
  92494. _restoreStateValues(): boolean;
  92495. /** @hidden */
  92496. _isSynchronizedViewMatrix(): boolean;
  92497. /**
  92498. * Attached controls to the current camera.
  92499. * @param element Defines the element the controls should be listened from
  92500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92501. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  92502. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  92503. */
  92504. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  92505. /**
  92506. * Detach the current controls from the camera.
  92507. * The camera will stop reacting to inputs.
  92508. * @param element Defines the element to stop listening the inputs from
  92509. */
  92510. detachControl(element: HTMLElement): void;
  92511. /** @hidden */
  92512. _checkInputs(): void;
  92513. protected _checkLimits(): void;
  92514. /**
  92515. * Rebuilds angles (alpha, beta) and radius from the give position and target
  92516. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  92517. */
  92518. rebuildAnglesAndRadius(updateView?: boolean): void;
  92519. /**
  92520. * Use a position to define the current camera related information like aplha, beta and radius
  92521. * @param position Defines the position to set the camera at
  92522. */
  92523. setPosition(position: Vector3): void;
  92524. /**
  92525. * Defines the target the camera should look at.
  92526. * This will automatically adapt alpha beta and radius to fit within the new target.
  92527. * @param target Defines the new target as a Vector or a mesh
  92528. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  92529. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  92530. */
  92531. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  92532. /** @hidden */
  92533. _getViewMatrix(): Matrix;
  92534. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  92535. /**
  92536. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  92537. * @param meshes Defines the mesh to zoom on
  92538. * @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)
  92539. */
  92540. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  92541. /**
  92542. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  92543. * The target will be changed but the radius
  92544. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  92545. * @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)
  92546. */
  92547. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  92548. min: Vector3;
  92549. max: Vector3;
  92550. distance: number;
  92551. }, doNotUpdateMaxZ?: boolean): void;
  92552. /**
  92553. * @override
  92554. * Override Camera.createRigCamera
  92555. */
  92556. createRigCamera(name: string, cameraIndex: number): Camera;
  92557. /**
  92558. * @hidden
  92559. * @override
  92560. * Override Camera._updateRigCameras
  92561. */
  92562. _updateRigCameras(): void;
  92563. /**
  92564. * Destroy the camera and release the current resources hold by it.
  92565. */
  92566. dispose(): void;
  92567. /**
  92568. * Gets the current object class name.
  92569. * @return the class name
  92570. */
  92571. getClassName(): string;
  92572. }
  92573. }
  92574. declare module BABYLON {
  92575. /**
  92576. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  92577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92578. */
  92579. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  92580. /**
  92581. * Gets the name of the behavior.
  92582. */
  92583. readonly name: string;
  92584. private _zoomStopsAnimation;
  92585. private _idleRotationSpeed;
  92586. private _idleRotationWaitTime;
  92587. private _idleRotationSpinupTime;
  92588. /**
  92589. * Sets the flag that indicates if user zooming should stop animation.
  92590. */
  92591. /**
  92592. * Gets the flag that indicates if user zooming should stop animation.
  92593. */
  92594. zoomStopsAnimation: boolean;
  92595. /**
  92596. * Sets the default speed at which the camera rotates around the model.
  92597. */
  92598. /**
  92599. * Gets the default speed at which the camera rotates around the model.
  92600. */
  92601. idleRotationSpeed: number;
  92602. /**
  92603. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92604. */
  92605. /**
  92606. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92607. */
  92608. idleRotationWaitTime: number;
  92609. /**
  92610. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92611. */
  92612. /**
  92613. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92614. */
  92615. idleRotationSpinupTime: number;
  92616. /**
  92617. * Gets a value indicating if the camera is currently rotating because of this behavior
  92618. */
  92619. readonly rotationInProgress: boolean;
  92620. private _onPrePointerObservableObserver;
  92621. private _onAfterCheckInputsObserver;
  92622. private _attachedCamera;
  92623. private _isPointerDown;
  92624. private _lastFrameTime;
  92625. private _lastInteractionTime;
  92626. private _cameraRotationSpeed;
  92627. /**
  92628. * Initializes the behavior.
  92629. */
  92630. init(): void;
  92631. /**
  92632. * Attaches the behavior to its arc rotate camera.
  92633. * @param camera Defines the camera to attach the behavior to
  92634. */
  92635. attach(camera: ArcRotateCamera): void;
  92636. /**
  92637. * Detaches the behavior from its current arc rotate camera.
  92638. */
  92639. detach(): void;
  92640. /**
  92641. * Returns true if user is scrolling.
  92642. * @return true if user is scrolling.
  92643. */
  92644. private _userIsZooming;
  92645. private _lastFrameRadius;
  92646. private _shouldAnimationStopForInteraction;
  92647. /**
  92648. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92649. */
  92650. private _applyUserInteraction;
  92651. private _userIsMoving;
  92652. }
  92653. }
  92654. declare module BABYLON {
  92655. /**
  92656. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92657. */
  92658. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92659. private ui;
  92660. /**
  92661. * The name of the behavior
  92662. */
  92663. name: string;
  92664. /**
  92665. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92666. */
  92667. distanceAwayFromFace: number;
  92668. /**
  92669. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92670. */
  92671. distanceAwayFromBottomOfFace: number;
  92672. private _faceVectors;
  92673. private _target;
  92674. private _scene;
  92675. private _onRenderObserver;
  92676. private _tmpMatrix;
  92677. private _tmpVector;
  92678. /**
  92679. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92680. * @param ui The transform node that should be attched to the mesh
  92681. */
  92682. constructor(ui: TransformNode);
  92683. /**
  92684. * Initializes the behavior
  92685. */
  92686. init(): void;
  92687. private _closestFace;
  92688. private _zeroVector;
  92689. private _lookAtTmpMatrix;
  92690. private _lookAtToRef;
  92691. /**
  92692. * Attaches the AttachToBoxBehavior to the passed in mesh
  92693. * @param target The mesh that the specified node will be attached to
  92694. */
  92695. attach(target: Mesh): void;
  92696. /**
  92697. * Detaches the behavior from the mesh
  92698. */
  92699. detach(): void;
  92700. }
  92701. }
  92702. declare module BABYLON {
  92703. /**
  92704. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92705. */
  92706. export class FadeInOutBehavior implements Behavior<Mesh> {
  92707. /**
  92708. * Time in milliseconds to delay before fading in (Default: 0)
  92709. */
  92710. delay: number;
  92711. /**
  92712. * Time in milliseconds for the mesh to fade in (Default: 300)
  92713. */
  92714. fadeInTime: number;
  92715. private _millisecondsPerFrame;
  92716. private _hovered;
  92717. private _hoverValue;
  92718. private _ownerNode;
  92719. /**
  92720. * Instatiates the FadeInOutBehavior
  92721. */
  92722. constructor();
  92723. /**
  92724. * The name of the behavior
  92725. */
  92726. readonly name: string;
  92727. /**
  92728. * Initializes the behavior
  92729. */
  92730. init(): void;
  92731. /**
  92732. * Attaches the fade behavior on the passed in mesh
  92733. * @param ownerNode The mesh that will be faded in/out once attached
  92734. */
  92735. attach(ownerNode: Mesh): void;
  92736. /**
  92737. * Detaches the behavior from the mesh
  92738. */
  92739. detach(): void;
  92740. /**
  92741. * Triggers the mesh to begin fading in or out
  92742. * @param value if the object should fade in or out (true to fade in)
  92743. */
  92744. fadeIn(value: boolean): void;
  92745. private _update;
  92746. private _setAllVisibility;
  92747. }
  92748. }
  92749. declare module BABYLON {
  92750. /**
  92751. * Class containing a set of static utilities functions for managing Pivots
  92752. * @hidden
  92753. */
  92754. export class PivotTools {
  92755. private static _PivotCached;
  92756. private static _OldPivotPoint;
  92757. private static _PivotTranslation;
  92758. private static _PivotTmpVector;
  92759. /** @hidden */
  92760. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92761. /** @hidden */
  92762. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92763. }
  92764. }
  92765. declare module BABYLON {
  92766. /**
  92767. * Class containing static functions to help procedurally build meshes
  92768. */
  92769. export class PlaneBuilder {
  92770. /**
  92771. * Creates a plane mesh
  92772. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92773. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92774. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92778. * @param name defines the name of the mesh
  92779. * @param options defines the options used to create the mesh
  92780. * @param scene defines the hosting scene
  92781. * @returns the plane mesh
  92782. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92783. */
  92784. static CreatePlane(name: string, options: {
  92785. size?: number;
  92786. width?: number;
  92787. height?: number;
  92788. sideOrientation?: number;
  92789. frontUVs?: Vector4;
  92790. backUVs?: Vector4;
  92791. updatable?: boolean;
  92792. sourcePlane?: Plane;
  92793. }, scene: Scene): Mesh;
  92794. }
  92795. }
  92796. declare module BABYLON {
  92797. /**
  92798. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92799. */
  92800. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92801. private static _AnyMouseID;
  92802. private _attachedNode;
  92803. private _dragPlane;
  92804. private _scene;
  92805. private _pointerObserver;
  92806. private _beforeRenderObserver;
  92807. private static _planeScene;
  92808. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92809. /**
  92810. * 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)
  92811. */
  92812. maxDragAngle: number;
  92813. /**
  92814. * @hidden
  92815. */
  92816. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92817. /**
  92818. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92819. */
  92820. currentDraggingPointerID: number;
  92821. /**
  92822. * The last position where the pointer hit the drag plane in world space
  92823. */
  92824. lastDragPosition: Vector3;
  92825. /**
  92826. * If the behavior is currently in a dragging state
  92827. */
  92828. dragging: boolean;
  92829. /**
  92830. * 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)
  92831. */
  92832. dragDeltaRatio: number;
  92833. /**
  92834. * If the drag plane orientation should be updated during the dragging (Default: true)
  92835. */
  92836. updateDragPlane: boolean;
  92837. private _debugMode;
  92838. private _moving;
  92839. /**
  92840. * Fires each time the attached mesh is dragged with the pointer
  92841. * * delta between last drag position and current drag position in world space
  92842. * * dragDistance along the drag axis
  92843. * * dragPlaneNormal normal of the current drag plane used during the drag
  92844. * * dragPlanePoint in world space where the drag intersects the drag plane
  92845. */
  92846. onDragObservable: Observable<{
  92847. delta: Vector3;
  92848. dragPlanePoint: Vector3;
  92849. dragPlaneNormal: Vector3;
  92850. dragDistance: number;
  92851. pointerId: number;
  92852. }>;
  92853. /**
  92854. * Fires each time a drag begins (eg. mouse down on mesh)
  92855. */
  92856. onDragStartObservable: Observable<{
  92857. dragPlanePoint: Vector3;
  92858. pointerId: number;
  92859. }>;
  92860. /**
  92861. * Fires each time a drag ends (eg. mouse release after drag)
  92862. */
  92863. onDragEndObservable: Observable<{
  92864. dragPlanePoint: Vector3;
  92865. pointerId: number;
  92866. }>;
  92867. /**
  92868. * If the attached mesh should be moved when dragged
  92869. */
  92870. moveAttached: boolean;
  92871. /**
  92872. * If the drag behavior will react to drag events (Default: true)
  92873. */
  92874. enabled: boolean;
  92875. /**
  92876. * If camera controls should be detached during the drag
  92877. */
  92878. detachCameraControls: boolean;
  92879. /**
  92880. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92881. */
  92882. useObjectOrienationForDragging: boolean;
  92883. private _options;
  92884. /**
  92885. * Creates a pointer drag behavior that can be attached to a mesh
  92886. * @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)
  92887. */
  92888. constructor(options?: {
  92889. dragAxis?: Vector3;
  92890. dragPlaneNormal?: Vector3;
  92891. });
  92892. /**
  92893. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92894. */
  92895. validateDrag: (targetPosition: Vector3) => boolean;
  92896. /**
  92897. * The name of the behavior
  92898. */
  92899. readonly name: string;
  92900. /**
  92901. * Initializes the behavior
  92902. */
  92903. init(): void;
  92904. private _tmpVector;
  92905. private _alternatePickedPoint;
  92906. private _worldDragAxis;
  92907. private _targetPosition;
  92908. private _attachedElement;
  92909. /**
  92910. * Attaches the drag behavior the passed in mesh
  92911. * @param ownerNode The mesh that will be dragged around once attached
  92912. */
  92913. attach(ownerNode: AbstractMesh): void;
  92914. /**
  92915. * Force relase the drag action by code.
  92916. */
  92917. releaseDrag(): void;
  92918. private _startDragRay;
  92919. private _lastPointerRay;
  92920. /**
  92921. * Simulates the start of a pointer drag event on the behavior
  92922. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92923. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92924. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92925. */
  92926. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92927. private _startDrag;
  92928. private _dragDelta;
  92929. private _moveDrag;
  92930. private _pickWithRayOnDragPlane;
  92931. private _pointA;
  92932. private _pointB;
  92933. private _pointC;
  92934. private _lineA;
  92935. private _lineB;
  92936. private _localAxis;
  92937. private _lookAt;
  92938. private _updateDragPlanePosition;
  92939. /**
  92940. * Detaches the behavior from the mesh
  92941. */
  92942. detach(): void;
  92943. }
  92944. }
  92945. declare module BABYLON {
  92946. /**
  92947. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92948. */
  92949. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92950. private _dragBehaviorA;
  92951. private _dragBehaviorB;
  92952. private _startDistance;
  92953. private _initialScale;
  92954. private _targetScale;
  92955. private _ownerNode;
  92956. private _sceneRenderObserver;
  92957. /**
  92958. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92959. */
  92960. constructor();
  92961. /**
  92962. * The name of the behavior
  92963. */
  92964. readonly name: string;
  92965. /**
  92966. * Initializes the behavior
  92967. */
  92968. init(): void;
  92969. private _getCurrentDistance;
  92970. /**
  92971. * Attaches the scale behavior the passed in mesh
  92972. * @param ownerNode The mesh that will be scaled around once attached
  92973. */
  92974. attach(ownerNode: Mesh): void;
  92975. /**
  92976. * Detaches the behavior from the mesh
  92977. */
  92978. detach(): void;
  92979. }
  92980. }
  92981. declare module BABYLON {
  92982. /**
  92983. * 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
  92984. */
  92985. export class SixDofDragBehavior implements Behavior<Mesh> {
  92986. private static _virtualScene;
  92987. private _ownerNode;
  92988. private _sceneRenderObserver;
  92989. private _scene;
  92990. private _targetPosition;
  92991. private _virtualOriginMesh;
  92992. private _virtualDragMesh;
  92993. private _pointerObserver;
  92994. private _moving;
  92995. private _startingOrientation;
  92996. /**
  92997. * 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)
  92998. */
  92999. private zDragFactor;
  93000. /**
  93001. * If the object should rotate to face the drag origin
  93002. */
  93003. rotateDraggedObject: boolean;
  93004. /**
  93005. * If the behavior is currently in a dragging state
  93006. */
  93007. dragging: boolean;
  93008. /**
  93009. * 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)
  93010. */
  93011. dragDeltaRatio: number;
  93012. /**
  93013. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93014. */
  93015. currentDraggingPointerID: number;
  93016. /**
  93017. * If camera controls should be detached during the drag
  93018. */
  93019. detachCameraControls: boolean;
  93020. /**
  93021. * Fires each time a drag starts
  93022. */
  93023. onDragStartObservable: Observable<{}>;
  93024. /**
  93025. * Fires each time a drag ends (eg. mouse release after drag)
  93026. */
  93027. onDragEndObservable: Observable<{}>;
  93028. /**
  93029. * 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
  93030. */
  93031. constructor();
  93032. /**
  93033. * The name of the behavior
  93034. */
  93035. readonly name: string;
  93036. /**
  93037. * Initializes the behavior
  93038. */
  93039. init(): void;
  93040. /**
  93041. * Attaches the scale behavior the passed in mesh
  93042. * @param ownerNode The mesh that will be scaled around once attached
  93043. */
  93044. attach(ownerNode: Mesh): void;
  93045. /**
  93046. * Detaches the behavior from the mesh
  93047. */
  93048. detach(): void;
  93049. }
  93050. }
  93051. declare module BABYLON {
  93052. /**
  93053. * Class used to apply inverse kinematics to bones
  93054. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  93055. */
  93056. export class BoneIKController {
  93057. private static _tmpVecs;
  93058. private static _tmpQuat;
  93059. private static _tmpMats;
  93060. /**
  93061. * Gets or sets the target mesh
  93062. */
  93063. targetMesh: AbstractMesh;
  93064. /** Gets or sets the mesh used as pole */
  93065. poleTargetMesh: AbstractMesh;
  93066. /**
  93067. * Gets or sets the bone used as pole
  93068. */
  93069. poleTargetBone: Nullable<Bone>;
  93070. /**
  93071. * Gets or sets the target position
  93072. */
  93073. targetPosition: Vector3;
  93074. /**
  93075. * Gets or sets the pole target position
  93076. */
  93077. poleTargetPosition: Vector3;
  93078. /**
  93079. * Gets or sets the pole target local offset
  93080. */
  93081. poleTargetLocalOffset: Vector3;
  93082. /**
  93083. * Gets or sets the pole angle
  93084. */
  93085. poleAngle: number;
  93086. /**
  93087. * Gets or sets the mesh associated with the controller
  93088. */
  93089. mesh: AbstractMesh;
  93090. /**
  93091. * 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)
  93092. */
  93093. slerpAmount: number;
  93094. private _bone1Quat;
  93095. private _bone1Mat;
  93096. private _bone2Ang;
  93097. private _bone1;
  93098. private _bone2;
  93099. private _bone1Length;
  93100. private _bone2Length;
  93101. private _maxAngle;
  93102. private _maxReach;
  93103. private _rightHandedSystem;
  93104. private _bendAxis;
  93105. private _slerping;
  93106. private _adjustRoll;
  93107. /**
  93108. * Gets or sets maximum allowed angle
  93109. */
  93110. maxAngle: number;
  93111. /**
  93112. * Creates a new BoneIKController
  93113. * @param mesh defines the mesh to control
  93114. * @param bone defines the bone to control
  93115. * @param options defines options to set up the controller
  93116. */
  93117. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  93118. targetMesh?: AbstractMesh;
  93119. poleTargetMesh?: AbstractMesh;
  93120. poleTargetBone?: Bone;
  93121. poleTargetLocalOffset?: Vector3;
  93122. poleAngle?: number;
  93123. bendAxis?: Vector3;
  93124. maxAngle?: number;
  93125. slerpAmount?: number;
  93126. });
  93127. private _setMaxAngle;
  93128. /**
  93129. * Force the controller to update the bones
  93130. */
  93131. update(): void;
  93132. }
  93133. }
  93134. declare module BABYLON {
  93135. /**
  93136. * Class used to make a bone look toward a point in space
  93137. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  93138. */
  93139. export class BoneLookController {
  93140. private static _tmpVecs;
  93141. private static _tmpQuat;
  93142. private static _tmpMats;
  93143. /**
  93144. * The target Vector3 that the bone will look at
  93145. */
  93146. target: Vector3;
  93147. /**
  93148. * The mesh that the bone is attached to
  93149. */
  93150. mesh: AbstractMesh;
  93151. /**
  93152. * The bone that will be looking to the target
  93153. */
  93154. bone: Bone;
  93155. /**
  93156. * The up axis of the coordinate system that is used when the bone is rotated
  93157. */
  93158. upAxis: Vector3;
  93159. /**
  93160. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  93161. */
  93162. upAxisSpace: Space;
  93163. /**
  93164. * Used to make an adjustment to the yaw of the bone
  93165. */
  93166. adjustYaw: number;
  93167. /**
  93168. * Used to make an adjustment to the pitch of the bone
  93169. */
  93170. adjustPitch: number;
  93171. /**
  93172. * Used to make an adjustment to the roll of the bone
  93173. */
  93174. adjustRoll: number;
  93175. /**
  93176. * 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)
  93177. */
  93178. slerpAmount: number;
  93179. private _minYaw;
  93180. private _maxYaw;
  93181. private _minPitch;
  93182. private _maxPitch;
  93183. private _minYawSin;
  93184. private _minYawCos;
  93185. private _maxYawSin;
  93186. private _maxYawCos;
  93187. private _midYawConstraint;
  93188. private _minPitchTan;
  93189. private _maxPitchTan;
  93190. private _boneQuat;
  93191. private _slerping;
  93192. private _transformYawPitch;
  93193. private _transformYawPitchInv;
  93194. private _firstFrameSkipped;
  93195. private _yawRange;
  93196. private _fowardAxis;
  93197. /**
  93198. * Gets or sets the minimum yaw angle that the bone can look to
  93199. */
  93200. minYaw: number;
  93201. /**
  93202. * Gets or sets the maximum yaw angle that the bone can look to
  93203. */
  93204. maxYaw: number;
  93205. /**
  93206. * Gets or sets the minimum pitch angle that the bone can look to
  93207. */
  93208. minPitch: number;
  93209. /**
  93210. * Gets or sets the maximum pitch angle that the bone can look to
  93211. */
  93212. maxPitch: number;
  93213. /**
  93214. * Create a BoneLookController
  93215. * @param mesh the mesh that the bone belongs to
  93216. * @param bone the bone that will be looking to the target
  93217. * @param target the target Vector3 to look at
  93218. * @param options optional settings:
  93219. * * maxYaw: the maximum angle the bone will yaw to
  93220. * * minYaw: the minimum angle the bone will yaw to
  93221. * * maxPitch: the maximum angle the bone will pitch to
  93222. * * minPitch: the minimum angle the bone will yaw to
  93223. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  93224. * * upAxis: the up axis of the coordinate system
  93225. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  93226. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  93227. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  93228. * * adjustYaw: used to make an adjustment to the yaw of the bone
  93229. * * adjustPitch: used to make an adjustment to the pitch of the bone
  93230. * * adjustRoll: used to make an adjustment to the roll of the bone
  93231. **/
  93232. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  93233. maxYaw?: number;
  93234. minYaw?: number;
  93235. maxPitch?: number;
  93236. minPitch?: number;
  93237. slerpAmount?: number;
  93238. upAxis?: Vector3;
  93239. upAxisSpace?: Space;
  93240. yawAxis?: Vector3;
  93241. pitchAxis?: Vector3;
  93242. adjustYaw?: number;
  93243. adjustPitch?: number;
  93244. adjustRoll?: number;
  93245. });
  93246. /**
  93247. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  93248. */
  93249. update(): void;
  93250. private _getAngleDiff;
  93251. private _getAngleBetween;
  93252. private _isAngleBetween;
  93253. }
  93254. }
  93255. declare module BABYLON {
  93256. /**
  93257. * Manage the gamepad inputs to control an arc rotate camera.
  93258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93259. */
  93260. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  93261. /**
  93262. * Defines the camera the input is attached to.
  93263. */
  93264. camera: ArcRotateCamera;
  93265. /**
  93266. * Defines the gamepad the input is gathering event from.
  93267. */
  93268. gamepad: Nullable<Gamepad>;
  93269. /**
  93270. * Defines the gamepad rotation sensiblity.
  93271. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93272. */
  93273. gamepadRotationSensibility: number;
  93274. /**
  93275. * Defines the gamepad move sensiblity.
  93276. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93277. */
  93278. gamepadMoveSensibility: number;
  93279. private _onGamepadConnectedObserver;
  93280. private _onGamepadDisconnectedObserver;
  93281. /**
  93282. * Attach the input controls to a specific dom element to get the input from.
  93283. * @param element Defines the element the controls should be listened from
  93284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93285. */
  93286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93287. /**
  93288. * Detach the current controls from the specified dom element.
  93289. * @param element Defines the element to stop listening the inputs from
  93290. */
  93291. detachControl(element: Nullable<HTMLElement>): void;
  93292. /**
  93293. * Update the current camera state depending on the inputs that have been used this frame.
  93294. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93295. */
  93296. checkInputs(): void;
  93297. /**
  93298. * Gets the class name of the current intput.
  93299. * @returns the class name
  93300. */
  93301. getClassName(): string;
  93302. /**
  93303. * Get the friendly name associated with the input class.
  93304. * @returns the input friendly name
  93305. */
  93306. getSimpleName(): string;
  93307. }
  93308. }
  93309. declare module BABYLON {
  93310. interface ArcRotateCameraInputsManager {
  93311. /**
  93312. * Add orientation input support to the input manager.
  93313. * @returns the current input manager
  93314. */
  93315. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  93316. }
  93317. /**
  93318. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  93319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93320. */
  93321. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  93322. /**
  93323. * Defines the camera the input is attached to.
  93324. */
  93325. camera: ArcRotateCamera;
  93326. /**
  93327. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  93328. */
  93329. alphaCorrection: number;
  93330. /**
  93331. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  93332. */
  93333. gammaCorrection: number;
  93334. private _alpha;
  93335. private _gamma;
  93336. private _dirty;
  93337. private _deviceOrientationHandler;
  93338. /**
  93339. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  93340. */
  93341. constructor();
  93342. /**
  93343. * Attach the input controls to a specific dom element to get the input from.
  93344. * @param element Defines the element the controls should be listened from
  93345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93346. */
  93347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93348. /** @hidden */
  93349. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  93350. /**
  93351. * Update the current camera state depending on the inputs that have been used this frame.
  93352. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93353. */
  93354. checkInputs(): void;
  93355. /**
  93356. * Detach the current controls from the specified dom element.
  93357. * @param element Defines the element to stop listening the inputs from
  93358. */
  93359. detachControl(element: Nullable<HTMLElement>): void;
  93360. /**
  93361. * Gets the class name of the current intput.
  93362. * @returns the class name
  93363. */
  93364. getClassName(): string;
  93365. /**
  93366. * Get the friendly name associated with the input class.
  93367. * @returns the input friendly name
  93368. */
  93369. getSimpleName(): string;
  93370. }
  93371. }
  93372. declare module BABYLON {
  93373. /**
  93374. * Listen to mouse events to control the camera.
  93375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93376. */
  93377. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  93378. /**
  93379. * Defines the camera the input is attached to.
  93380. */
  93381. camera: FlyCamera;
  93382. /**
  93383. * Defines if touch is enabled. (Default is true.)
  93384. */
  93385. touchEnabled: boolean;
  93386. /**
  93387. * Defines the buttons associated with the input to handle camera rotation.
  93388. */
  93389. buttons: number[];
  93390. /**
  93391. * Assign buttons for Yaw control.
  93392. */
  93393. buttonsYaw: number[];
  93394. /**
  93395. * Assign buttons for Pitch control.
  93396. */
  93397. buttonsPitch: number[];
  93398. /**
  93399. * Assign buttons for Roll control.
  93400. */
  93401. buttonsRoll: number[];
  93402. /**
  93403. * Detect if any button is being pressed while mouse is moved.
  93404. * -1 = Mouse locked.
  93405. * 0 = Left button.
  93406. * 1 = Middle Button.
  93407. * 2 = Right Button.
  93408. */
  93409. activeButton: number;
  93410. /**
  93411. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  93412. * Higher values reduce its sensitivity.
  93413. */
  93414. angularSensibility: number;
  93415. private _mousemoveCallback;
  93416. private _observer;
  93417. private _rollObserver;
  93418. private previousPosition;
  93419. private noPreventDefault;
  93420. private element;
  93421. /**
  93422. * Listen to mouse events to control the camera.
  93423. * @param touchEnabled Define if touch is enabled. (Default is true.)
  93424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93425. */
  93426. constructor(touchEnabled?: boolean);
  93427. /**
  93428. * Attach the mouse control to the HTML DOM element.
  93429. * @param element Defines the element that listens to the input events.
  93430. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  93431. */
  93432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93433. /**
  93434. * Detach the current controls from the specified dom element.
  93435. * @param element Defines the element to stop listening the inputs from
  93436. */
  93437. detachControl(element: Nullable<HTMLElement>): void;
  93438. /**
  93439. * Gets the class name of the current input.
  93440. * @returns the class name.
  93441. */
  93442. getClassName(): string;
  93443. /**
  93444. * Get the friendly name associated with the input class.
  93445. * @returns the input's friendly name.
  93446. */
  93447. getSimpleName(): string;
  93448. private _pointerInput;
  93449. private _onMouseMove;
  93450. /**
  93451. * Rotate camera by mouse offset.
  93452. */
  93453. private rotateCamera;
  93454. }
  93455. }
  93456. declare module BABYLON {
  93457. /**
  93458. * Default Inputs manager for the FlyCamera.
  93459. * It groups all the default supported inputs for ease of use.
  93460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93461. */
  93462. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  93463. /**
  93464. * Instantiates a new FlyCameraInputsManager.
  93465. * @param camera Defines the camera the inputs belong to.
  93466. */
  93467. constructor(camera: FlyCamera);
  93468. /**
  93469. * Add keyboard input support to the input manager.
  93470. * @returns the new FlyCameraKeyboardMoveInput().
  93471. */
  93472. addKeyboard(): FlyCameraInputsManager;
  93473. /**
  93474. * Add mouse input support to the input manager.
  93475. * @param touchEnabled Enable touch screen support.
  93476. * @returns the new FlyCameraMouseInput().
  93477. */
  93478. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  93479. }
  93480. }
  93481. declare module BABYLON {
  93482. /**
  93483. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93484. * such as in a 3D Space Shooter or a Flight Simulator.
  93485. */
  93486. export class FlyCamera extends TargetCamera {
  93487. /**
  93488. * Define the collision ellipsoid of the camera.
  93489. * This is helpful for simulating a camera body, like a player's body.
  93490. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93491. */
  93492. ellipsoid: Vector3;
  93493. /**
  93494. * Define an offset for the position of the ellipsoid around the camera.
  93495. * This can be helpful if the camera is attached away from the player's body center,
  93496. * such as at its head.
  93497. */
  93498. ellipsoidOffset: Vector3;
  93499. /**
  93500. * Enable or disable collisions of the camera with the rest of the scene objects.
  93501. */
  93502. checkCollisions: boolean;
  93503. /**
  93504. * Enable or disable gravity on the camera.
  93505. */
  93506. applyGravity: boolean;
  93507. /**
  93508. * Define the current direction the camera is moving to.
  93509. */
  93510. cameraDirection: Vector3;
  93511. /**
  93512. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  93513. * This overrides and empties cameraRotation.
  93514. */
  93515. rotationQuaternion: Quaternion;
  93516. /**
  93517. * Track Roll to maintain the wanted Rolling when looking around.
  93518. */
  93519. _trackRoll: number;
  93520. /**
  93521. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  93522. */
  93523. rollCorrect: number;
  93524. /**
  93525. * Mimic a banked turn, Rolling the camera when Yawing.
  93526. * It's recommended to use rollCorrect = 10 for faster banking correction.
  93527. */
  93528. bankedTurn: boolean;
  93529. /**
  93530. * Limit in radians for how much Roll banking will add. (Default: 90°)
  93531. */
  93532. bankedTurnLimit: number;
  93533. /**
  93534. * Value of 0 disables the banked Roll.
  93535. * Value of 1 is equal to the Yaw angle in radians.
  93536. */
  93537. bankedTurnMultiplier: number;
  93538. /**
  93539. * The inputs manager loads all the input sources, such as keyboard and mouse.
  93540. */
  93541. inputs: FlyCameraInputsManager;
  93542. /**
  93543. * Gets the input sensibility for mouse input.
  93544. * Higher values reduce sensitivity.
  93545. */
  93546. /**
  93547. * Sets the input sensibility for a mouse input.
  93548. * Higher values reduce sensitivity.
  93549. */
  93550. angularSensibility: number;
  93551. /**
  93552. * Get the keys for camera movement forward.
  93553. */
  93554. /**
  93555. * Set the keys for camera movement forward.
  93556. */
  93557. keysForward: number[];
  93558. /**
  93559. * Get the keys for camera movement backward.
  93560. */
  93561. keysBackward: number[];
  93562. /**
  93563. * Get the keys for camera movement up.
  93564. */
  93565. /**
  93566. * Set the keys for camera movement up.
  93567. */
  93568. keysUp: number[];
  93569. /**
  93570. * Get the keys for camera movement down.
  93571. */
  93572. /**
  93573. * Set the keys for camera movement down.
  93574. */
  93575. keysDown: number[];
  93576. /**
  93577. * Get the keys for camera movement left.
  93578. */
  93579. /**
  93580. * Set the keys for camera movement left.
  93581. */
  93582. keysLeft: number[];
  93583. /**
  93584. * Set the keys for camera movement right.
  93585. */
  93586. /**
  93587. * Set the keys for camera movement right.
  93588. */
  93589. keysRight: number[];
  93590. /**
  93591. * Event raised when the camera collides with a mesh in the scene.
  93592. */
  93593. onCollide: (collidedMesh: AbstractMesh) => void;
  93594. private _collider;
  93595. private _needMoveForGravity;
  93596. private _oldPosition;
  93597. private _diffPosition;
  93598. private _newPosition;
  93599. /** @hidden */
  93600. _localDirection: Vector3;
  93601. /** @hidden */
  93602. _transformedDirection: Vector3;
  93603. /**
  93604. * Instantiates a FlyCamera.
  93605. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93606. * such as in a 3D Space Shooter or a Flight Simulator.
  93607. * @param name Define the name of the camera in the scene.
  93608. * @param position Define the starting position of the camera in the scene.
  93609. * @param scene Define the scene the camera belongs to.
  93610. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93611. */
  93612. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93613. /**
  93614. * Attach a control to the HTML DOM element.
  93615. * @param element Defines the element that listens to the input events.
  93616. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93617. */
  93618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93619. /**
  93620. * Detach a control from the HTML DOM element.
  93621. * The camera will stop reacting to that input.
  93622. * @param element Defines the element that listens to the input events.
  93623. */
  93624. detachControl(element: HTMLElement): void;
  93625. private _collisionMask;
  93626. /**
  93627. * Get the mask that the camera ignores in collision events.
  93628. */
  93629. /**
  93630. * Set the mask that the camera ignores in collision events.
  93631. */
  93632. collisionMask: number;
  93633. /** @hidden */
  93634. _collideWithWorld(displacement: Vector3): void;
  93635. /** @hidden */
  93636. private _onCollisionPositionChange;
  93637. /** @hidden */
  93638. _checkInputs(): void;
  93639. /** @hidden */
  93640. _decideIfNeedsToMove(): boolean;
  93641. /** @hidden */
  93642. _updatePosition(): void;
  93643. /**
  93644. * Restore the Roll to its target value at the rate specified.
  93645. * @param rate - Higher means slower restoring.
  93646. * @hidden
  93647. */
  93648. restoreRoll(rate: number): void;
  93649. /**
  93650. * Destroy the camera and release the current resources held by it.
  93651. */
  93652. dispose(): void;
  93653. /**
  93654. * Get the current object class name.
  93655. * @returns the class name.
  93656. */
  93657. getClassName(): string;
  93658. }
  93659. }
  93660. declare module BABYLON {
  93661. /**
  93662. * Listen to keyboard events to control the camera.
  93663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93664. */
  93665. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93666. /**
  93667. * Defines the camera the input is attached to.
  93668. */
  93669. camera: FlyCamera;
  93670. /**
  93671. * The list of keyboard keys used to control the forward move of the camera.
  93672. */
  93673. keysForward: number[];
  93674. /**
  93675. * The list of keyboard keys used to control the backward move of the camera.
  93676. */
  93677. keysBackward: number[];
  93678. /**
  93679. * The list of keyboard keys used to control the forward move of the camera.
  93680. */
  93681. keysUp: number[];
  93682. /**
  93683. * The list of keyboard keys used to control the backward move of the camera.
  93684. */
  93685. keysDown: number[];
  93686. /**
  93687. * The list of keyboard keys used to control the right strafe move of the camera.
  93688. */
  93689. keysRight: number[];
  93690. /**
  93691. * The list of keyboard keys used to control the left strafe move of the camera.
  93692. */
  93693. keysLeft: number[];
  93694. private _keys;
  93695. private _onCanvasBlurObserver;
  93696. private _onKeyboardObserver;
  93697. private _engine;
  93698. private _scene;
  93699. /**
  93700. * Attach the input controls to a specific dom element to get the input from.
  93701. * @param element Defines the element the controls should be listened from
  93702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93703. */
  93704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93705. /**
  93706. * Detach the current controls from the specified dom element.
  93707. * @param element Defines the element to stop listening the inputs from
  93708. */
  93709. detachControl(element: Nullable<HTMLElement>): void;
  93710. /**
  93711. * Gets the class name of the current intput.
  93712. * @returns the class name
  93713. */
  93714. getClassName(): string;
  93715. /** @hidden */
  93716. _onLostFocus(e: FocusEvent): void;
  93717. /**
  93718. * Get the friendly name associated with the input class.
  93719. * @returns the input friendly name
  93720. */
  93721. getSimpleName(): string;
  93722. /**
  93723. * Update the current camera state depending on the inputs that have been used this frame.
  93724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93725. */
  93726. checkInputs(): void;
  93727. }
  93728. }
  93729. declare module BABYLON {
  93730. /**
  93731. * Manage the mouse wheel inputs to control a follow camera.
  93732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93733. */
  93734. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93735. /**
  93736. * Defines the camera the input is attached to.
  93737. */
  93738. camera: FollowCamera;
  93739. /**
  93740. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93741. */
  93742. axisControlRadius: boolean;
  93743. /**
  93744. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93745. */
  93746. axisControlHeight: boolean;
  93747. /**
  93748. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93749. */
  93750. axisControlRotation: boolean;
  93751. /**
  93752. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93753. * relation to mouseWheel events.
  93754. */
  93755. wheelPrecision: number;
  93756. /**
  93757. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93758. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93759. */
  93760. wheelDeltaPercentage: number;
  93761. private _wheel;
  93762. private _observer;
  93763. /**
  93764. * Attach the input controls to a specific dom element to get the input from.
  93765. * @param element Defines the element the controls should be listened from
  93766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93767. */
  93768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93769. /**
  93770. * Detach the current controls from the specified dom element.
  93771. * @param element Defines the element to stop listening the inputs from
  93772. */
  93773. detachControl(element: Nullable<HTMLElement>): void;
  93774. /**
  93775. * Gets the class name of the current intput.
  93776. * @returns the class name
  93777. */
  93778. getClassName(): string;
  93779. /**
  93780. * Get the friendly name associated with the input class.
  93781. * @returns the input friendly name
  93782. */
  93783. getSimpleName(): string;
  93784. }
  93785. }
  93786. declare module BABYLON {
  93787. /**
  93788. * Manage the pointers inputs to control an follow camera.
  93789. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93790. */
  93791. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93792. /**
  93793. * Defines the camera the input is attached to.
  93794. */
  93795. camera: FollowCamera;
  93796. /**
  93797. * Gets the class name of the current input.
  93798. * @returns the class name
  93799. */
  93800. getClassName(): string;
  93801. /**
  93802. * Defines the pointer angular sensibility along the X axis or how fast is
  93803. * the camera rotating.
  93804. * A negative number will reverse the axis direction.
  93805. */
  93806. angularSensibilityX: number;
  93807. /**
  93808. * Defines the pointer angular sensibility along the Y axis or how fast is
  93809. * the camera rotating.
  93810. * A negative number will reverse the axis direction.
  93811. */
  93812. angularSensibilityY: number;
  93813. /**
  93814. * Defines the pointer pinch precision or how fast is the camera zooming.
  93815. * A negative number will reverse the axis direction.
  93816. */
  93817. pinchPrecision: number;
  93818. /**
  93819. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93820. * from 0.
  93821. * It defines the percentage of current camera.radius to use as delta when
  93822. * pinch zoom is used.
  93823. */
  93824. pinchDeltaPercentage: number;
  93825. /**
  93826. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93827. */
  93828. axisXControlRadius: boolean;
  93829. /**
  93830. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93831. */
  93832. axisXControlHeight: boolean;
  93833. /**
  93834. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93835. */
  93836. axisXControlRotation: boolean;
  93837. /**
  93838. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93839. */
  93840. axisYControlRadius: boolean;
  93841. /**
  93842. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93843. */
  93844. axisYControlHeight: boolean;
  93845. /**
  93846. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93847. */
  93848. axisYControlRotation: boolean;
  93849. /**
  93850. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93851. */
  93852. axisPinchControlRadius: boolean;
  93853. /**
  93854. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93855. */
  93856. axisPinchControlHeight: boolean;
  93857. /**
  93858. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93859. */
  93860. axisPinchControlRotation: boolean;
  93861. /**
  93862. * Log error messages if basic misconfiguration has occurred.
  93863. */
  93864. warningEnable: boolean;
  93865. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93866. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93867. private _warningCounter;
  93868. private _warning;
  93869. }
  93870. }
  93871. declare module BABYLON {
  93872. /**
  93873. * Default Inputs manager for the FollowCamera.
  93874. * It groups all the default supported inputs for ease of use.
  93875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93876. */
  93877. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93878. /**
  93879. * Instantiates a new FollowCameraInputsManager.
  93880. * @param camera Defines the camera the inputs belong to
  93881. */
  93882. constructor(camera: FollowCamera);
  93883. /**
  93884. * Add keyboard input support to the input manager.
  93885. * @returns the current input manager
  93886. */
  93887. addKeyboard(): FollowCameraInputsManager;
  93888. /**
  93889. * Add mouse wheel input support to the input manager.
  93890. * @returns the current input manager
  93891. */
  93892. addMouseWheel(): FollowCameraInputsManager;
  93893. /**
  93894. * Add pointers input support to the input manager.
  93895. * @returns the current input manager
  93896. */
  93897. addPointers(): FollowCameraInputsManager;
  93898. /**
  93899. * Add orientation input support to the input manager.
  93900. * @returns the current input manager
  93901. */
  93902. addVRDeviceOrientation(): FollowCameraInputsManager;
  93903. }
  93904. }
  93905. declare module BABYLON {
  93906. /**
  93907. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93908. * an arc rotate version arcFollowCamera are available.
  93909. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93910. */
  93911. export class FollowCamera extends TargetCamera {
  93912. /**
  93913. * Distance the follow camera should follow an object at
  93914. */
  93915. radius: number;
  93916. /**
  93917. * Minimum allowed distance of the camera to the axis of rotation
  93918. * (The camera can not get closer).
  93919. * This can help limiting how the Camera is able to move in the scene.
  93920. */
  93921. lowerRadiusLimit: Nullable<number>;
  93922. /**
  93923. * Maximum allowed distance of the camera to the axis of rotation
  93924. * (The camera can not get further).
  93925. * This can help limiting how the Camera is able to move in the scene.
  93926. */
  93927. upperRadiusLimit: Nullable<number>;
  93928. /**
  93929. * Define a rotation offset between the camera and the object it follows
  93930. */
  93931. rotationOffset: number;
  93932. /**
  93933. * Minimum allowed angle to camera position relative to target object.
  93934. * This can help limiting how the Camera is able to move in the scene.
  93935. */
  93936. lowerRotationOffsetLimit: Nullable<number>;
  93937. /**
  93938. * Maximum allowed angle to camera position relative to target object.
  93939. * This can help limiting how the Camera is able to move in the scene.
  93940. */
  93941. upperRotationOffsetLimit: Nullable<number>;
  93942. /**
  93943. * Define a height offset between the camera and the object it follows.
  93944. * It can help following an object from the top (like a car chaing a plane)
  93945. */
  93946. heightOffset: number;
  93947. /**
  93948. * Minimum allowed height of camera position relative to target object.
  93949. * This can help limiting how the Camera is able to move in the scene.
  93950. */
  93951. lowerHeightOffsetLimit: Nullable<number>;
  93952. /**
  93953. * Maximum allowed height of camera position relative to target object.
  93954. * This can help limiting how the Camera is able to move in the scene.
  93955. */
  93956. upperHeightOffsetLimit: Nullable<number>;
  93957. /**
  93958. * Define how fast the camera can accelerate to follow it s target.
  93959. */
  93960. cameraAcceleration: number;
  93961. /**
  93962. * Define the speed limit of the camera following an object.
  93963. */
  93964. maxCameraSpeed: number;
  93965. /**
  93966. * Define the target of the camera.
  93967. */
  93968. lockedTarget: Nullable<AbstractMesh>;
  93969. /**
  93970. * Defines the input associated with the camera.
  93971. */
  93972. inputs: FollowCameraInputsManager;
  93973. /**
  93974. * Instantiates the follow camera.
  93975. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93976. * @param name Define the name of the camera in the scene
  93977. * @param position Define the position of the camera
  93978. * @param scene Define the scene the camera belong to
  93979. * @param lockedTarget Define the target of the camera
  93980. */
  93981. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93982. private _follow;
  93983. /**
  93984. * Attached controls to the current camera.
  93985. * @param element Defines the element the controls should be listened from
  93986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93987. */
  93988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93989. /**
  93990. * Detach the current controls from the camera.
  93991. * The camera will stop reacting to inputs.
  93992. * @param element Defines the element to stop listening the inputs from
  93993. */
  93994. detachControl(element: HTMLElement): void;
  93995. /** @hidden */
  93996. _checkInputs(): void;
  93997. private _checkLimits;
  93998. /**
  93999. * Gets the camera class name.
  94000. * @returns the class name
  94001. */
  94002. getClassName(): string;
  94003. }
  94004. /**
  94005. * Arc Rotate version of the follow camera.
  94006. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  94007. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94008. */
  94009. export class ArcFollowCamera extends TargetCamera {
  94010. /** The longitudinal angle of the camera */
  94011. alpha: number;
  94012. /** The latitudinal angle of the camera */
  94013. beta: number;
  94014. /** The radius of the camera from its target */
  94015. radius: number;
  94016. /** Define the camera target (the messh it should follow) */
  94017. target: Nullable<AbstractMesh>;
  94018. private _cartesianCoordinates;
  94019. /**
  94020. * Instantiates a new ArcFollowCamera
  94021. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94022. * @param name Define the name of the camera
  94023. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  94024. * @param beta Define the rotation angle of the camera around the elevation axis
  94025. * @param radius Define the radius of the camera from its target point
  94026. * @param target Define the target of the camera
  94027. * @param scene Define the scene the camera belongs to
  94028. */
  94029. constructor(name: string,
  94030. /** The longitudinal angle of the camera */
  94031. alpha: number,
  94032. /** The latitudinal angle of the camera */
  94033. beta: number,
  94034. /** The radius of the camera from its target */
  94035. radius: number,
  94036. /** Define the camera target (the messh it should follow) */
  94037. target: Nullable<AbstractMesh>, scene: Scene);
  94038. private _follow;
  94039. /** @hidden */
  94040. _checkInputs(): void;
  94041. /**
  94042. * Returns the class name of the object.
  94043. * It is mostly used internally for serialization purposes.
  94044. */
  94045. getClassName(): string;
  94046. }
  94047. }
  94048. declare module BABYLON {
  94049. /**
  94050. * Manage the keyboard inputs to control the movement of a follow camera.
  94051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94052. */
  94053. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  94054. /**
  94055. * Defines the camera the input is attached to.
  94056. */
  94057. camera: FollowCamera;
  94058. /**
  94059. * Defines the list of key codes associated with the up action (increase heightOffset)
  94060. */
  94061. keysHeightOffsetIncr: number[];
  94062. /**
  94063. * Defines the list of key codes associated with the down action (decrease heightOffset)
  94064. */
  94065. keysHeightOffsetDecr: number[];
  94066. /**
  94067. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  94068. */
  94069. keysHeightOffsetModifierAlt: boolean;
  94070. /**
  94071. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  94072. */
  94073. keysHeightOffsetModifierCtrl: boolean;
  94074. /**
  94075. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  94076. */
  94077. keysHeightOffsetModifierShift: boolean;
  94078. /**
  94079. * Defines the list of key codes associated with the left action (increase rotationOffset)
  94080. */
  94081. keysRotationOffsetIncr: number[];
  94082. /**
  94083. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  94084. */
  94085. keysRotationOffsetDecr: number[];
  94086. /**
  94087. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  94088. */
  94089. keysRotationOffsetModifierAlt: boolean;
  94090. /**
  94091. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  94092. */
  94093. keysRotationOffsetModifierCtrl: boolean;
  94094. /**
  94095. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  94096. */
  94097. keysRotationOffsetModifierShift: boolean;
  94098. /**
  94099. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  94100. */
  94101. keysRadiusIncr: number[];
  94102. /**
  94103. * Defines the list of key codes associated with the zoom-out action (increase radius)
  94104. */
  94105. keysRadiusDecr: number[];
  94106. /**
  94107. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  94108. */
  94109. keysRadiusModifierAlt: boolean;
  94110. /**
  94111. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  94112. */
  94113. keysRadiusModifierCtrl: boolean;
  94114. /**
  94115. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  94116. */
  94117. keysRadiusModifierShift: boolean;
  94118. /**
  94119. * Defines the rate of change of heightOffset.
  94120. */
  94121. heightSensibility: number;
  94122. /**
  94123. * Defines the rate of change of rotationOffset.
  94124. */
  94125. rotationSensibility: number;
  94126. /**
  94127. * Defines the rate of change of radius.
  94128. */
  94129. radiusSensibility: number;
  94130. private _keys;
  94131. private _ctrlPressed;
  94132. private _altPressed;
  94133. private _shiftPressed;
  94134. private _onCanvasBlurObserver;
  94135. private _onKeyboardObserver;
  94136. private _engine;
  94137. private _scene;
  94138. /**
  94139. * Attach the input controls to a specific dom element to get the input from.
  94140. * @param element Defines the element the controls should be listened from
  94141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94142. */
  94143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94144. /**
  94145. * Detach the current controls from the specified dom element.
  94146. * @param element Defines the element to stop listening the inputs from
  94147. */
  94148. detachControl(element: Nullable<HTMLElement>): void;
  94149. /**
  94150. * Update the current camera state depending on the inputs that have been used this frame.
  94151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94152. */
  94153. checkInputs(): void;
  94154. /**
  94155. * Gets the class name of the current input.
  94156. * @returns the class name
  94157. */
  94158. getClassName(): string;
  94159. /**
  94160. * Get the friendly name associated with the input class.
  94161. * @returns the input friendly name
  94162. */
  94163. getSimpleName(): string;
  94164. /**
  94165. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94166. * allow modification of the heightOffset value.
  94167. */
  94168. private _modifierHeightOffset;
  94169. /**
  94170. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94171. * allow modification of the rotationOffset value.
  94172. */
  94173. private _modifierRotationOffset;
  94174. /**
  94175. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94176. * allow modification of the radius value.
  94177. */
  94178. private _modifierRadius;
  94179. }
  94180. }
  94181. declare module BABYLON {
  94182. interface FreeCameraInputsManager {
  94183. /**
  94184. * Add orientation input support to the input manager.
  94185. * @returns the current input manager
  94186. */
  94187. addDeviceOrientation(): FreeCameraInputsManager;
  94188. }
  94189. /**
  94190. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  94191. * Screen rotation is taken into account.
  94192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94193. */
  94194. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  94195. private _camera;
  94196. private _screenOrientationAngle;
  94197. private _constantTranform;
  94198. private _screenQuaternion;
  94199. private _alpha;
  94200. private _beta;
  94201. private _gamma;
  94202. /**
  94203. * Instantiates a new input
  94204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94205. */
  94206. constructor();
  94207. /**
  94208. * Define the camera controlled by the input.
  94209. */
  94210. camera: FreeCamera;
  94211. /**
  94212. * Attach the input controls to a specific dom element to get the input from.
  94213. * @param element Defines the element the controls should be listened from
  94214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94215. */
  94216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94217. private _orientationChanged;
  94218. private _deviceOrientation;
  94219. /**
  94220. * Detach the current controls from the specified dom element.
  94221. * @param element Defines the element to stop listening the inputs from
  94222. */
  94223. detachControl(element: Nullable<HTMLElement>): void;
  94224. /**
  94225. * Update the current camera state depending on the inputs that have been used this frame.
  94226. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94227. */
  94228. checkInputs(): void;
  94229. /**
  94230. * Gets the class name of the current intput.
  94231. * @returns the class name
  94232. */
  94233. getClassName(): string;
  94234. /**
  94235. * Get the friendly name associated with the input class.
  94236. * @returns the input friendly name
  94237. */
  94238. getSimpleName(): string;
  94239. }
  94240. }
  94241. declare module BABYLON {
  94242. /**
  94243. * Manage the gamepad inputs to control a free camera.
  94244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94245. */
  94246. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  94247. /**
  94248. * Define the camera the input is attached to.
  94249. */
  94250. camera: FreeCamera;
  94251. /**
  94252. * Define the Gamepad controlling the input
  94253. */
  94254. gamepad: Nullable<Gamepad>;
  94255. /**
  94256. * Defines the gamepad rotation sensiblity.
  94257. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94258. */
  94259. gamepadAngularSensibility: number;
  94260. /**
  94261. * Defines the gamepad move sensiblity.
  94262. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94263. */
  94264. gamepadMoveSensibility: number;
  94265. private _onGamepadConnectedObserver;
  94266. private _onGamepadDisconnectedObserver;
  94267. private _cameraTransform;
  94268. private _deltaTransform;
  94269. private _vector3;
  94270. private _vector2;
  94271. /**
  94272. * Attach the input controls to a specific dom element to get the input from.
  94273. * @param element Defines the element the controls should be listened from
  94274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94275. */
  94276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94277. /**
  94278. * Detach the current controls from the specified dom element.
  94279. * @param element Defines the element to stop listening the inputs from
  94280. */
  94281. detachControl(element: Nullable<HTMLElement>): void;
  94282. /**
  94283. * Update the current camera state depending on the inputs that have been used this frame.
  94284. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94285. */
  94286. checkInputs(): void;
  94287. /**
  94288. * Gets the class name of the current intput.
  94289. * @returns the class name
  94290. */
  94291. getClassName(): string;
  94292. /**
  94293. * Get the friendly name associated with the input class.
  94294. * @returns the input friendly name
  94295. */
  94296. getSimpleName(): string;
  94297. }
  94298. }
  94299. declare module BABYLON {
  94300. /**
  94301. * Defines the potential axis of a Joystick
  94302. */
  94303. export enum JoystickAxis {
  94304. /** X axis */
  94305. X = 0,
  94306. /** Y axis */
  94307. Y = 1,
  94308. /** Z axis */
  94309. Z = 2
  94310. }
  94311. /**
  94312. * Class used to define virtual joystick (used in touch mode)
  94313. */
  94314. export class VirtualJoystick {
  94315. /**
  94316. * Gets or sets a boolean indicating that left and right values must be inverted
  94317. */
  94318. reverseLeftRight: boolean;
  94319. /**
  94320. * Gets or sets a boolean indicating that up and down values must be inverted
  94321. */
  94322. reverseUpDown: boolean;
  94323. /**
  94324. * Gets the offset value for the position (ie. the change of the position value)
  94325. */
  94326. deltaPosition: Vector3;
  94327. /**
  94328. * Gets a boolean indicating if the virtual joystick was pressed
  94329. */
  94330. pressed: boolean;
  94331. /**
  94332. * Canvas the virtual joystick will render onto, default z-index of this is 5
  94333. */
  94334. static Canvas: Nullable<HTMLCanvasElement>;
  94335. private static _globalJoystickIndex;
  94336. private static vjCanvasContext;
  94337. private static vjCanvasWidth;
  94338. private static vjCanvasHeight;
  94339. private static halfWidth;
  94340. private _action;
  94341. private _axisTargetedByLeftAndRight;
  94342. private _axisTargetedByUpAndDown;
  94343. private _joystickSensibility;
  94344. private _inversedSensibility;
  94345. private _joystickPointerID;
  94346. private _joystickColor;
  94347. private _joystickPointerPos;
  94348. private _joystickPreviousPointerPos;
  94349. private _joystickPointerStartPos;
  94350. private _deltaJoystickVector;
  94351. private _leftJoystick;
  94352. private _touches;
  94353. private _onPointerDownHandlerRef;
  94354. private _onPointerMoveHandlerRef;
  94355. private _onPointerUpHandlerRef;
  94356. private _onResize;
  94357. /**
  94358. * Creates a new virtual joystick
  94359. * @param leftJoystick defines that the joystick is for left hand (false by default)
  94360. */
  94361. constructor(leftJoystick?: boolean);
  94362. /**
  94363. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  94364. * @param newJoystickSensibility defines the new sensibility
  94365. */
  94366. setJoystickSensibility(newJoystickSensibility: number): void;
  94367. private _onPointerDown;
  94368. private _onPointerMove;
  94369. private _onPointerUp;
  94370. /**
  94371. * Change the color of the virtual joystick
  94372. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  94373. */
  94374. setJoystickColor(newColor: string): void;
  94375. /**
  94376. * Defines a callback to call when the joystick is touched
  94377. * @param action defines the callback
  94378. */
  94379. setActionOnTouch(action: () => any): void;
  94380. /**
  94381. * Defines which axis you'd like to control for left & right
  94382. * @param axis defines the axis to use
  94383. */
  94384. setAxisForLeftRight(axis: JoystickAxis): void;
  94385. /**
  94386. * Defines which axis you'd like to control for up & down
  94387. * @param axis defines the axis to use
  94388. */
  94389. setAxisForUpDown(axis: JoystickAxis): void;
  94390. private _drawVirtualJoystick;
  94391. /**
  94392. * Release internal HTML canvas
  94393. */
  94394. releaseCanvas(): void;
  94395. }
  94396. }
  94397. declare module BABYLON {
  94398. interface FreeCameraInputsManager {
  94399. /**
  94400. * Add virtual joystick input support to the input manager.
  94401. * @returns the current input manager
  94402. */
  94403. addVirtualJoystick(): FreeCameraInputsManager;
  94404. }
  94405. /**
  94406. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  94407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94408. */
  94409. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  94410. /**
  94411. * Defines the camera the input is attached to.
  94412. */
  94413. camera: FreeCamera;
  94414. private _leftjoystick;
  94415. private _rightjoystick;
  94416. /**
  94417. * Gets the left stick of the virtual joystick.
  94418. * @returns The virtual Joystick
  94419. */
  94420. getLeftJoystick(): VirtualJoystick;
  94421. /**
  94422. * Gets the right stick of the virtual joystick.
  94423. * @returns The virtual Joystick
  94424. */
  94425. getRightJoystick(): VirtualJoystick;
  94426. /**
  94427. * Update the current camera state depending on the inputs that have been used this frame.
  94428. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94429. */
  94430. checkInputs(): void;
  94431. /**
  94432. * Attach the input controls to a specific dom element to get the input from.
  94433. * @param element Defines the element the controls should be listened from
  94434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94435. */
  94436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94437. /**
  94438. * Detach the current controls from the specified dom element.
  94439. * @param element Defines the element to stop listening the inputs from
  94440. */
  94441. detachControl(element: Nullable<HTMLElement>): void;
  94442. /**
  94443. * Gets the class name of the current intput.
  94444. * @returns the class name
  94445. */
  94446. getClassName(): string;
  94447. /**
  94448. * Get the friendly name associated with the input class.
  94449. * @returns the input friendly name
  94450. */
  94451. getSimpleName(): string;
  94452. }
  94453. }
  94454. declare module BABYLON {
  94455. /**
  94456. * This represents a FPS type of camera controlled by touch.
  94457. * This is like a universal camera minus the Gamepad controls.
  94458. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94459. */
  94460. export class TouchCamera extends FreeCamera {
  94461. /**
  94462. * Defines the touch sensibility for rotation.
  94463. * The higher the faster.
  94464. */
  94465. touchAngularSensibility: number;
  94466. /**
  94467. * Defines the touch sensibility for move.
  94468. * The higher the faster.
  94469. */
  94470. touchMoveSensibility: number;
  94471. /**
  94472. * Instantiates a new touch camera.
  94473. * This represents a FPS type of camera controlled by touch.
  94474. * This is like a universal camera minus the Gamepad controls.
  94475. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94476. * @param name Define the name of the camera in the scene
  94477. * @param position Define the start position of the camera in the scene
  94478. * @param scene Define the scene the camera belongs to
  94479. */
  94480. constructor(name: string, position: Vector3, scene: Scene);
  94481. /**
  94482. * Gets the current object class name.
  94483. * @return the class name
  94484. */
  94485. getClassName(): string;
  94486. /** @hidden */
  94487. _setupInputs(): void;
  94488. }
  94489. }
  94490. declare module BABYLON {
  94491. /**
  94492. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  94493. * being tilted forward or back and left or right.
  94494. */
  94495. export class DeviceOrientationCamera extends FreeCamera {
  94496. private _initialQuaternion;
  94497. private _quaternionCache;
  94498. /**
  94499. * Creates a new device orientation camera
  94500. * @param name The name of the camera
  94501. * @param position The start position camera
  94502. * @param scene The scene the camera belongs to
  94503. */
  94504. constructor(name: string, position: Vector3, scene: Scene);
  94505. /**
  94506. * Gets the current instance class name ("DeviceOrientationCamera").
  94507. * This helps avoiding instanceof at run time.
  94508. * @returns the class name
  94509. */
  94510. getClassName(): string;
  94511. /**
  94512. * @hidden
  94513. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  94514. */
  94515. _checkInputs(): void;
  94516. /**
  94517. * Reset the camera to its default orientation on the specified axis only.
  94518. * @param axis The axis to reset
  94519. */
  94520. resetToCurrentRotation(axis?: Axis): void;
  94521. }
  94522. }
  94523. declare module BABYLON {
  94524. /**
  94525. * 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,
  94526. * which still works and will still be found in many Playgrounds.
  94527. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94528. */
  94529. export class UniversalCamera extends TouchCamera {
  94530. /**
  94531. * Defines the gamepad rotation sensiblity.
  94532. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94533. */
  94534. gamepadAngularSensibility: number;
  94535. /**
  94536. * Defines the gamepad move sensiblity.
  94537. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94538. */
  94539. gamepadMoveSensibility: number;
  94540. /**
  94541. * 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,
  94542. * which still works and will still be found in many Playgrounds.
  94543. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94544. * @param name Define the name of the camera in the scene
  94545. * @param position Define the start position of the camera in the scene
  94546. * @param scene Define the scene the camera belongs to
  94547. */
  94548. constructor(name: string, position: Vector3, scene: Scene);
  94549. /**
  94550. * Gets the current object class name.
  94551. * @return the class name
  94552. */
  94553. getClassName(): string;
  94554. }
  94555. }
  94556. declare module BABYLON {
  94557. /**
  94558. * This represents a FPS type of camera. This is only here for back compat purpose.
  94559. * Please use the UniversalCamera instead as both are identical.
  94560. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94561. */
  94562. export class GamepadCamera extends UniversalCamera {
  94563. /**
  94564. * Instantiates a new Gamepad Camera
  94565. * This represents a FPS type of camera. This is only here for back compat purpose.
  94566. * Please use the UniversalCamera instead as both are identical.
  94567. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94568. * @param name Define the name of the camera in the scene
  94569. * @param position Define the start position of the camera in the scene
  94570. * @param scene Define the scene the camera belongs to
  94571. */
  94572. constructor(name: string, position: Vector3, scene: Scene);
  94573. /**
  94574. * Gets the current object class name.
  94575. * @return the class name
  94576. */
  94577. getClassName(): string;
  94578. }
  94579. }
  94580. declare module BABYLON {
  94581. /** @hidden */
  94582. export var passPixelShader: {
  94583. name: string;
  94584. shader: string;
  94585. };
  94586. }
  94587. declare module BABYLON {
  94588. /** @hidden */
  94589. export var passCubePixelShader: {
  94590. name: string;
  94591. shader: string;
  94592. };
  94593. }
  94594. declare module BABYLON {
  94595. /**
  94596. * PassPostProcess which produces an output the same as it's input
  94597. */
  94598. export class PassPostProcess extends PostProcess {
  94599. /**
  94600. * Creates the PassPostProcess
  94601. * @param name The name of the effect.
  94602. * @param options The required width/height ratio to downsize to before computing the render pass.
  94603. * @param camera The camera to apply the render pass to.
  94604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94605. * @param engine The engine which the post process will be applied. (default: current engine)
  94606. * @param reusable If the post process can be reused on the same frame. (default: false)
  94607. * @param textureType The type of texture to be used when performing the post processing.
  94608. * @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)
  94609. */
  94610. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94611. }
  94612. /**
  94613. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94614. */
  94615. export class PassCubePostProcess extends PostProcess {
  94616. private _face;
  94617. /**
  94618. * Gets or sets the cube face to display.
  94619. * * 0 is +X
  94620. * * 1 is -X
  94621. * * 2 is +Y
  94622. * * 3 is -Y
  94623. * * 4 is +Z
  94624. * * 5 is -Z
  94625. */
  94626. face: number;
  94627. /**
  94628. * Creates the PassCubePostProcess
  94629. * @param name The name of the effect.
  94630. * @param options The required width/height ratio to downsize to before computing the render pass.
  94631. * @param camera The camera to apply the render pass to.
  94632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94633. * @param engine The engine which the post process will be applied. (default: current engine)
  94634. * @param reusable If the post process can be reused on the same frame. (default: false)
  94635. * @param textureType The type of texture to be used when performing the post processing.
  94636. * @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)
  94637. */
  94638. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94639. }
  94640. }
  94641. declare module BABYLON {
  94642. /** @hidden */
  94643. export var anaglyphPixelShader: {
  94644. name: string;
  94645. shader: string;
  94646. };
  94647. }
  94648. declare module BABYLON {
  94649. /**
  94650. * Postprocess used to generate anaglyphic rendering
  94651. */
  94652. export class AnaglyphPostProcess extends PostProcess {
  94653. private _passedProcess;
  94654. /**
  94655. * Creates a new AnaglyphPostProcess
  94656. * @param name defines postprocess name
  94657. * @param options defines creation options or target ratio scale
  94658. * @param rigCameras defines cameras using this postprocess
  94659. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94660. * @param engine defines hosting engine
  94661. * @param reusable defines if the postprocess will be reused multiple times per frame
  94662. */
  94663. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94664. }
  94665. }
  94666. declare module BABYLON {
  94667. /**
  94668. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94669. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94670. */
  94671. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94672. /**
  94673. * Creates a new AnaglyphArcRotateCamera
  94674. * @param name defines camera name
  94675. * @param alpha defines alpha angle (in radians)
  94676. * @param beta defines beta angle (in radians)
  94677. * @param radius defines radius
  94678. * @param target defines camera target
  94679. * @param interaxialDistance defines distance between each color axis
  94680. * @param scene defines the hosting scene
  94681. */
  94682. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94683. /**
  94684. * Gets camera class name
  94685. * @returns AnaglyphArcRotateCamera
  94686. */
  94687. getClassName(): string;
  94688. }
  94689. }
  94690. declare module BABYLON {
  94691. /**
  94692. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94693. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94694. */
  94695. export class AnaglyphFreeCamera extends FreeCamera {
  94696. /**
  94697. * Creates a new AnaglyphFreeCamera
  94698. * @param name defines camera name
  94699. * @param position defines initial position
  94700. * @param interaxialDistance defines distance between each color axis
  94701. * @param scene defines the hosting scene
  94702. */
  94703. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94704. /**
  94705. * Gets camera class name
  94706. * @returns AnaglyphFreeCamera
  94707. */
  94708. getClassName(): string;
  94709. }
  94710. }
  94711. declare module BABYLON {
  94712. /**
  94713. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94714. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94715. */
  94716. export class AnaglyphGamepadCamera extends GamepadCamera {
  94717. /**
  94718. * Creates a new AnaglyphGamepadCamera
  94719. * @param name defines camera name
  94720. * @param position defines initial position
  94721. * @param interaxialDistance defines distance between each color axis
  94722. * @param scene defines the hosting scene
  94723. */
  94724. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94725. /**
  94726. * Gets camera class name
  94727. * @returns AnaglyphGamepadCamera
  94728. */
  94729. getClassName(): string;
  94730. }
  94731. }
  94732. declare module BABYLON {
  94733. /**
  94734. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94735. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94736. */
  94737. export class AnaglyphUniversalCamera extends UniversalCamera {
  94738. /**
  94739. * Creates a new AnaglyphUniversalCamera
  94740. * @param name defines camera name
  94741. * @param position defines initial position
  94742. * @param interaxialDistance defines distance between each color axis
  94743. * @param scene defines the hosting scene
  94744. */
  94745. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94746. /**
  94747. * Gets camera class name
  94748. * @returns AnaglyphUniversalCamera
  94749. */
  94750. getClassName(): string;
  94751. }
  94752. }
  94753. declare module BABYLON {
  94754. /** @hidden */
  94755. export var stereoscopicInterlacePixelShader: {
  94756. name: string;
  94757. shader: string;
  94758. };
  94759. }
  94760. declare module BABYLON {
  94761. /**
  94762. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94763. */
  94764. export class StereoscopicInterlacePostProcess extends PostProcess {
  94765. private _stepSize;
  94766. private _passedProcess;
  94767. /**
  94768. * Initializes a StereoscopicInterlacePostProcess
  94769. * @param name The name of the effect.
  94770. * @param rigCameras The rig cameras to be appled to the post process
  94771. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94773. * @param engine The engine which the post process will be applied. (default: current engine)
  94774. * @param reusable If the post process can be reused on the same frame. (default: false)
  94775. */
  94776. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94777. }
  94778. }
  94779. declare module BABYLON {
  94780. /**
  94781. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94782. * @see http://doc.babylonjs.com/features/cameras
  94783. */
  94784. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94785. /**
  94786. * Creates a new StereoscopicArcRotateCamera
  94787. * @param name defines camera name
  94788. * @param alpha defines alpha angle (in radians)
  94789. * @param beta defines beta angle (in radians)
  94790. * @param radius defines radius
  94791. * @param target defines camera target
  94792. * @param interaxialDistance defines distance between each color axis
  94793. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94794. * @param scene defines the hosting scene
  94795. */
  94796. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94797. /**
  94798. * Gets camera class name
  94799. * @returns StereoscopicArcRotateCamera
  94800. */
  94801. getClassName(): string;
  94802. }
  94803. }
  94804. declare module BABYLON {
  94805. /**
  94806. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94807. * @see http://doc.babylonjs.com/features/cameras
  94808. */
  94809. export class StereoscopicFreeCamera extends FreeCamera {
  94810. /**
  94811. * Creates a new StereoscopicFreeCamera
  94812. * @param name defines camera name
  94813. * @param position defines initial position
  94814. * @param interaxialDistance defines distance between each color axis
  94815. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94816. * @param scene defines the hosting scene
  94817. */
  94818. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94819. /**
  94820. * Gets camera class name
  94821. * @returns StereoscopicFreeCamera
  94822. */
  94823. getClassName(): string;
  94824. }
  94825. }
  94826. declare module BABYLON {
  94827. /**
  94828. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94829. * @see http://doc.babylonjs.com/features/cameras
  94830. */
  94831. export class StereoscopicGamepadCamera extends GamepadCamera {
  94832. /**
  94833. * Creates a new StereoscopicGamepadCamera
  94834. * @param name defines camera name
  94835. * @param position defines initial position
  94836. * @param interaxialDistance defines distance between each color axis
  94837. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94838. * @param scene defines the hosting scene
  94839. */
  94840. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94841. /**
  94842. * Gets camera class name
  94843. * @returns StereoscopicGamepadCamera
  94844. */
  94845. getClassName(): string;
  94846. }
  94847. }
  94848. declare module BABYLON {
  94849. /**
  94850. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94851. * @see http://doc.babylonjs.com/features/cameras
  94852. */
  94853. export class StereoscopicUniversalCamera extends UniversalCamera {
  94854. /**
  94855. * Creates a new StereoscopicUniversalCamera
  94856. * @param name defines camera name
  94857. * @param position defines initial position
  94858. * @param interaxialDistance defines distance between each color axis
  94859. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94860. * @param scene defines the hosting scene
  94861. */
  94862. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94863. /**
  94864. * Gets camera class name
  94865. * @returns StereoscopicUniversalCamera
  94866. */
  94867. getClassName(): string;
  94868. }
  94869. }
  94870. declare module BABYLON {
  94871. /**
  94872. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94873. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94874. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94875. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94876. */
  94877. export class VirtualJoysticksCamera extends FreeCamera {
  94878. /**
  94879. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94880. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94881. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94882. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94883. * @param name Define the name of the camera in the scene
  94884. * @param position Define the start position of the camera in the scene
  94885. * @param scene Define the scene the camera belongs to
  94886. */
  94887. constructor(name: string, position: Vector3, scene: Scene);
  94888. /**
  94889. * Gets the current object class name.
  94890. * @return the class name
  94891. */
  94892. getClassName(): string;
  94893. }
  94894. }
  94895. declare module BABYLON {
  94896. /**
  94897. * This represents all the required metrics to create a VR camera.
  94898. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94899. */
  94900. export class VRCameraMetrics {
  94901. /**
  94902. * Define the horizontal resolution off the screen.
  94903. */
  94904. hResolution: number;
  94905. /**
  94906. * Define the vertical resolution off the screen.
  94907. */
  94908. vResolution: number;
  94909. /**
  94910. * Define the horizontal screen size.
  94911. */
  94912. hScreenSize: number;
  94913. /**
  94914. * Define the vertical screen size.
  94915. */
  94916. vScreenSize: number;
  94917. /**
  94918. * Define the vertical screen center position.
  94919. */
  94920. vScreenCenter: number;
  94921. /**
  94922. * Define the distance of the eyes to the screen.
  94923. */
  94924. eyeToScreenDistance: number;
  94925. /**
  94926. * Define the distance between both lenses
  94927. */
  94928. lensSeparationDistance: number;
  94929. /**
  94930. * Define the distance between both viewer's eyes.
  94931. */
  94932. interpupillaryDistance: number;
  94933. /**
  94934. * Define the distortion factor of the VR postprocess.
  94935. * Please, touch with care.
  94936. */
  94937. distortionK: number[];
  94938. /**
  94939. * Define the chromatic aberration correction factors for the VR post process.
  94940. */
  94941. chromaAbCorrection: number[];
  94942. /**
  94943. * Define the scale factor of the post process.
  94944. * The smaller the better but the slower.
  94945. */
  94946. postProcessScaleFactor: number;
  94947. /**
  94948. * Define an offset for the lens center.
  94949. */
  94950. lensCenterOffset: number;
  94951. /**
  94952. * Define if the current vr camera should compensate the distortion of the lense or not.
  94953. */
  94954. compensateDistortion: boolean;
  94955. /**
  94956. * Gets the rendering aspect ratio based on the provided resolutions.
  94957. */
  94958. readonly aspectRatio: number;
  94959. /**
  94960. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94961. */
  94962. readonly aspectRatioFov: number;
  94963. /**
  94964. * @hidden
  94965. */
  94966. readonly leftHMatrix: Matrix;
  94967. /**
  94968. * @hidden
  94969. */
  94970. readonly rightHMatrix: Matrix;
  94971. /**
  94972. * @hidden
  94973. */
  94974. readonly leftPreViewMatrix: Matrix;
  94975. /**
  94976. * @hidden
  94977. */
  94978. readonly rightPreViewMatrix: Matrix;
  94979. /**
  94980. * Get the default VRMetrics based on the most generic setup.
  94981. * @returns the default vr metrics
  94982. */
  94983. static GetDefault(): VRCameraMetrics;
  94984. }
  94985. }
  94986. declare module BABYLON {
  94987. /** @hidden */
  94988. export var vrDistortionCorrectionPixelShader: {
  94989. name: string;
  94990. shader: string;
  94991. };
  94992. }
  94993. declare module BABYLON {
  94994. /**
  94995. * VRDistortionCorrectionPostProcess used for mobile VR
  94996. */
  94997. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94998. private _isRightEye;
  94999. private _distortionFactors;
  95000. private _postProcessScaleFactor;
  95001. private _lensCenterOffset;
  95002. private _scaleIn;
  95003. private _scaleFactor;
  95004. private _lensCenter;
  95005. /**
  95006. * Initializes the VRDistortionCorrectionPostProcess
  95007. * @param name The name of the effect.
  95008. * @param camera The camera to apply the render pass to.
  95009. * @param isRightEye If this is for the right eye distortion
  95010. * @param vrMetrics All the required metrics for the VR camera
  95011. */
  95012. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  95013. }
  95014. }
  95015. declare module BABYLON {
  95016. /**
  95017. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  95018. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95019. */
  95020. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  95021. /**
  95022. * Creates a new VRDeviceOrientationArcRotateCamera
  95023. * @param name defines camera name
  95024. * @param alpha defines the camera rotation along the logitudinal axis
  95025. * @param beta defines the camera rotation along the latitudinal axis
  95026. * @param radius defines the camera distance from its target
  95027. * @param target defines the camera target
  95028. * @param scene defines the scene the camera belongs to
  95029. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95030. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95031. */
  95032. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95033. /**
  95034. * Gets camera class name
  95035. * @returns VRDeviceOrientationArcRotateCamera
  95036. */
  95037. getClassName(): string;
  95038. }
  95039. }
  95040. declare module BABYLON {
  95041. /**
  95042. * Camera used to simulate VR rendering (based on FreeCamera)
  95043. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95044. */
  95045. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  95046. /**
  95047. * Creates a new VRDeviceOrientationFreeCamera
  95048. * @param name defines camera name
  95049. * @param position defines the start position of the camera
  95050. * @param scene defines the scene the camera belongs to
  95051. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95052. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95053. */
  95054. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95055. /**
  95056. * Gets camera class name
  95057. * @returns VRDeviceOrientationFreeCamera
  95058. */
  95059. getClassName(): string;
  95060. }
  95061. }
  95062. declare module BABYLON {
  95063. /**
  95064. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  95065. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95066. */
  95067. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  95068. /**
  95069. * Creates a new VRDeviceOrientationGamepadCamera
  95070. * @param name defines camera name
  95071. * @param position defines the start position of the camera
  95072. * @param scene defines the scene the camera belongs to
  95073. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95074. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95075. */
  95076. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95077. /**
  95078. * Gets camera class name
  95079. * @returns VRDeviceOrientationGamepadCamera
  95080. */
  95081. getClassName(): string;
  95082. }
  95083. }
  95084. declare module BABYLON {
  95085. /**
  95086. * Defines supported buttons for XBox360 compatible gamepads
  95087. */
  95088. export enum Xbox360Button {
  95089. /** A */
  95090. A = 0,
  95091. /** B */
  95092. B = 1,
  95093. /** X */
  95094. X = 2,
  95095. /** Y */
  95096. Y = 3,
  95097. /** Start */
  95098. Start = 4,
  95099. /** Back */
  95100. Back = 5,
  95101. /** Left button */
  95102. LB = 6,
  95103. /** Right button */
  95104. RB = 7,
  95105. /** Left stick */
  95106. LeftStick = 8,
  95107. /** Right stick */
  95108. RightStick = 9
  95109. }
  95110. /** Defines values for XBox360 DPad */
  95111. export enum Xbox360Dpad {
  95112. /** Up */
  95113. Up = 0,
  95114. /** Down */
  95115. Down = 1,
  95116. /** Left */
  95117. Left = 2,
  95118. /** Right */
  95119. Right = 3
  95120. }
  95121. /**
  95122. * Defines a XBox360 gamepad
  95123. */
  95124. export class Xbox360Pad extends Gamepad {
  95125. private _leftTrigger;
  95126. private _rightTrigger;
  95127. private _onlefttriggerchanged;
  95128. private _onrighttriggerchanged;
  95129. private _onbuttondown;
  95130. private _onbuttonup;
  95131. private _ondpaddown;
  95132. private _ondpadup;
  95133. /** Observable raised when a button is pressed */
  95134. onButtonDownObservable: Observable<Xbox360Button>;
  95135. /** Observable raised when a button is released */
  95136. onButtonUpObservable: Observable<Xbox360Button>;
  95137. /** Observable raised when a pad is pressed */
  95138. onPadDownObservable: Observable<Xbox360Dpad>;
  95139. /** Observable raised when a pad is released */
  95140. onPadUpObservable: Observable<Xbox360Dpad>;
  95141. private _buttonA;
  95142. private _buttonB;
  95143. private _buttonX;
  95144. private _buttonY;
  95145. private _buttonBack;
  95146. private _buttonStart;
  95147. private _buttonLB;
  95148. private _buttonRB;
  95149. private _buttonLeftStick;
  95150. private _buttonRightStick;
  95151. private _dPadUp;
  95152. private _dPadDown;
  95153. private _dPadLeft;
  95154. private _dPadRight;
  95155. private _isXboxOnePad;
  95156. /**
  95157. * Creates a new XBox360 gamepad object
  95158. * @param id defines the id of this gamepad
  95159. * @param index defines its index
  95160. * @param gamepad defines the internal HTML gamepad object
  95161. * @param xboxOne defines if it is a XBox One gamepad
  95162. */
  95163. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  95164. /**
  95165. * Defines the callback to call when left trigger is pressed
  95166. * @param callback defines the callback to use
  95167. */
  95168. onlefttriggerchanged(callback: (value: number) => void): void;
  95169. /**
  95170. * Defines the callback to call when right trigger is pressed
  95171. * @param callback defines the callback to use
  95172. */
  95173. onrighttriggerchanged(callback: (value: number) => void): void;
  95174. /**
  95175. * Gets the left trigger value
  95176. */
  95177. /**
  95178. * Sets the left trigger value
  95179. */
  95180. leftTrigger: number;
  95181. /**
  95182. * Gets the right trigger value
  95183. */
  95184. /**
  95185. * Sets the right trigger value
  95186. */
  95187. rightTrigger: number;
  95188. /**
  95189. * Defines the callback to call when a button is pressed
  95190. * @param callback defines the callback to use
  95191. */
  95192. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  95193. /**
  95194. * Defines the callback to call when a button is released
  95195. * @param callback defines the callback to use
  95196. */
  95197. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  95198. /**
  95199. * Defines the callback to call when a pad is pressed
  95200. * @param callback defines the callback to use
  95201. */
  95202. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  95203. /**
  95204. * Defines the callback to call when a pad is released
  95205. * @param callback defines the callback to use
  95206. */
  95207. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  95208. private _setButtonValue;
  95209. private _setDPadValue;
  95210. /**
  95211. * Gets the value of the `A` button
  95212. */
  95213. /**
  95214. * Sets the value of the `A` button
  95215. */
  95216. buttonA: number;
  95217. /**
  95218. * Gets the value of the `B` button
  95219. */
  95220. /**
  95221. * Sets the value of the `B` button
  95222. */
  95223. buttonB: number;
  95224. /**
  95225. * Gets the value of the `X` button
  95226. */
  95227. /**
  95228. * Sets the value of the `X` button
  95229. */
  95230. buttonX: number;
  95231. /**
  95232. * Gets the value of the `Y` button
  95233. */
  95234. /**
  95235. * Sets the value of the `Y` button
  95236. */
  95237. buttonY: number;
  95238. /**
  95239. * Gets the value of the `Start` button
  95240. */
  95241. /**
  95242. * Sets the value of the `Start` button
  95243. */
  95244. buttonStart: number;
  95245. /**
  95246. * Gets the value of the `Back` button
  95247. */
  95248. /**
  95249. * Sets the value of the `Back` button
  95250. */
  95251. buttonBack: number;
  95252. /**
  95253. * Gets the value of the `Left` button
  95254. */
  95255. /**
  95256. * Sets the value of the `Left` button
  95257. */
  95258. buttonLB: number;
  95259. /**
  95260. * Gets the value of the `Right` button
  95261. */
  95262. /**
  95263. * Sets the value of the `Right` button
  95264. */
  95265. buttonRB: number;
  95266. /**
  95267. * Gets the value of the Left joystick
  95268. */
  95269. /**
  95270. * Sets the value of the Left joystick
  95271. */
  95272. buttonLeftStick: number;
  95273. /**
  95274. * Gets the value of the Right joystick
  95275. */
  95276. /**
  95277. * Sets the value of the Right joystick
  95278. */
  95279. buttonRightStick: number;
  95280. /**
  95281. * Gets the value of D-pad up
  95282. */
  95283. /**
  95284. * Sets the value of D-pad up
  95285. */
  95286. dPadUp: number;
  95287. /**
  95288. * Gets the value of D-pad down
  95289. */
  95290. /**
  95291. * Sets the value of D-pad down
  95292. */
  95293. dPadDown: number;
  95294. /**
  95295. * Gets the value of D-pad left
  95296. */
  95297. /**
  95298. * Sets the value of D-pad left
  95299. */
  95300. dPadLeft: number;
  95301. /**
  95302. * Gets the value of D-pad right
  95303. */
  95304. /**
  95305. * Sets the value of D-pad right
  95306. */
  95307. dPadRight: number;
  95308. /**
  95309. * Force the gamepad to synchronize with device values
  95310. */
  95311. update(): void;
  95312. /**
  95313. * Disposes the gamepad
  95314. */
  95315. dispose(): void;
  95316. }
  95317. }
  95318. declare module BABYLON {
  95319. /**
  95320. * Base class of materials working in push mode in babylon JS
  95321. * @hidden
  95322. */
  95323. export class PushMaterial extends Material {
  95324. protected _activeEffect: Effect;
  95325. protected _normalMatrix: Matrix;
  95326. /**
  95327. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  95328. * This means that the material can keep using a previous shader while a new one is being compiled.
  95329. * This is mostly used when shader parallel compilation is supported (true by default)
  95330. */
  95331. allowShaderHotSwapping: boolean;
  95332. constructor(name: string, scene: Scene);
  95333. getEffect(): Effect;
  95334. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95335. /**
  95336. * Binds the given world matrix to the active effect
  95337. *
  95338. * @param world the matrix to bind
  95339. */
  95340. bindOnlyWorldMatrix(world: Matrix): void;
  95341. /**
  95342. * Binds the given normal matrix to the active effect
  95343. *
  95344. * @param normalMatrix the matrix to bind
  95345. */
  95346. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  95347. bind(world: Matrix, mesh?: Mesh): void;
  95348. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  95349. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  95350. }
  95351. }
  95352. declare module BABYLON {
  95353. /**
  95354. * This groups all the flags used to control the materials channel.
  95355. */
  95356. export class MaterialFlags {
  95357. private static _DiffuseTextureEnabled;
  95358. /**
  95359. * Are diffuse textures enabled in the application.
  95360. */
  95361. static DiffuseTextureEnabled: boolean;
  95362. private static _AmbientTextureEnabled;
  95363. /**
  95364. * Are ambient textures enabled in the application.
  95365. */
  95366. static AmbientTextureEnabled: boolean;
  95367. private static _OpacityTextureEnabled;
  95368. /**
  95369. * Are opacity textures enabled in the application.
  95370. */
  95371. static OpacityTextureEnabled: boolean;
  95372. private static _ReflectionTextureEnabled;
  95373. /**
  95374. * Are reflection textures enabled in the application.
  95375. */
  95376. static ReflectionTextureEnabled: boolean;
  95377. private static _EmissiveTextureEnabled;
  95378. /**
  95379. * Are emissive textures enabled in the application.
  95380. */
  95381. static EmissiveTextureEnabled: boolean;
  95382. private static _SpecularTextureEnabled;
  95383. /**
  95384. * Are specular textures enabled in the application.
  95385. */
  95386. static SpecularTextureEnabled: boolean;
  95387. private static _BumpTextureEnabled;
  95388. /**
  95389. * Are bump textures enabled in the application.
  95390. */
  95391. static BumpTextureEnabled: boolean;
  95392. private static _LightmapTextureEnabled;
  95393. /**
  95394. * Are lightmap textures enabled in the application.
  95395. */
  95396. static LightmapTextureEnabled: boolean;
  95397. private static _RefractionTextureEnabled;
  95398. /**
  95399. * Are refraction textures enabled in the application.
  95400. */
  95401. static RefractionTextureEnabled: boolean;
  95402. private static _ColorGradingTextureEnabled;
  95403. /**
  95404. * Are color grading textures enabled in the application.
  95405. */
  95406. static ColorGradingTextureEnabled: boolean;
  95407. private static _FresnelEnabled;
  95408. /**
  95409. * Are fresnels enabled in the application.
  95410. */
  95411. static FresnelEnabled: boolean;
  95412. private static _ClearCoatTextureEnabled;
  95413. /**
  95414. * Are clear coat textures enabled in the application.
  95415. */
  95416. static ClearCoatTextureEnabled: boolean;
  95417. private static _ClearCoatBumpTextureEnabled;
  95418. /**
  95419. * Are clear coat bump textures enabled in the application.
  95420. */
  95421. static ClearCoatBumpTextureEnabled: boolean;
  95422. private static _ClearCoatTintTextureEnabled;
  95423. /**
  95424. * Are clear coat tint textures enabled in the application.
  95425. */
  95426. static ClearCoatTintTextureEnabled: boolean;
  95427. private static _SheenTextureEnabled;
  95428. /**
  95429. * Are sheen textures enabled in the application.
  95430. */
  95431. static SheenTextureEnabled: boolean;
  95432. private static _AnisotropicTextureEnabled;
  95433. /**
  95434. * Are anisotropic textures enabled in the application.
  95435. */
  95436. static AnisotropicTextureEnabled: boolean;
  95437. }
  95438. }
  95439. declare module BABYLON {
  95440. /** @hidden */
  95441. export var defaultFragmentDeclaration: {
  95442. name: string;
  95443. shader: string;
  95444. };
  95445. }
  95446. declare module BABYLON {
  95447. /** @hidden */
  95448. export var defaultUboDeclaration: {
  95449. name: string;
  95450. shader: string;
  95451. };
  95452. }
  95453. declare module BABYLON {
  95454. /** @hidden */
  95455. export var lightFragmentDeclaration: {
  95456. name: string;
  95457. shader: string;
  95458. };
  95459. }
  95460. declare module BABYLON {
  95461. /** @hidden */
  95462. export var lightUboDeclaration: {
  95463. name: string;
  95464. shader: string;
  95465. };
  95466. }
  95467. declare module BABYLON {
  95468. /** @hidden */
  95469. export var lightsFragmentFunctions: {
  95470. name: string;
  95471. shader: string;
  95472. };
  95473. }
  95474. declare module BABYLON {
  95475. /** @hidden */
  95476. export var shadowsFragmentFunctions: {
  95477. name: string;
  95478. shader: string;
  95479. };
  95480. }
  95481. declare module BABYLON {
  95482. /** @hidden */
  95483. export var fresnelFunction: {
  95484. name: string;
  95485. shader: string;
  95486. };
  95487. }
  95488. declare module BABYLON {
  95489. /** @hidden */
  95490. export var reflectionFunction: {
  95491. name: string;
  95492. shader: string;
  95493. };
  95494. }
  95495. declare module BABYLON {
  95496. /** @hidden */
  95497. export var bumpFragmentFunctions: {
  95498. name: string;
  95499. shader: string;
  95500. };
  95501. }
  95502. declare module BABYLON {
  95503. /** @hidden */
  95504. export var logDepthDeclaration: {
  95505. name: string;
  95506. shader: string;
  95507. };
  95508. }
  95509. declare module BABYLON {
  95510. /** @hidden */
  95511. export var bumpFragment: {
  95512. name: string;
  95513. shader: string;
  95514. };
  95515. }
  95516. declare module BABYLON {
  95517. /** @hidden */
  95518. export var depthPrePass: {
  95519. name: string;
  95520. shader: string;
  95521. };
  95522. }
  95523. declare module BABYLON {
  95524. /** @hidden */
  95525. export var lightFragment: {
  95526. name: string;
  95527. shader: string;
  95528. };
  95529. }
  95530. declare module BABYLON {
  95531. /** @hidden */
  95532. export var logDepthFragment: {
  95533. name: string;
  95534. shader: string;
  95535. };
  95536. }
  95537. declare module BABYLON {
  95538. /** @hidden */
  95539. export var defaultPixelShader: {
  95540. name: string;
  95541. shader: string;
  95542. };
  95543. }
  95544. declare module BABYLON {
  95545. /** @hidden */
  95546. export var defaultVertexDeclaration: {
  95547. name: string;
  95548. shader: string;
  95549. };
  95550. }
  95551. declare module BABYLON {
  95552. /** @hidden */
  95553. export var bumpVertexDeclaration: {
  95554. name: string;
  95555. shader: string;
  95556. };
  95557. }
  95558. declare module BABYLON {
  95559. /** @hidden */
  95560. export var bumpVertex: {
  95561. name: string;
  95562. shader: string;
  95563. };
  95564. }
  95565. declare module BABYLON {
  95566. /** @hidden */
  95567. export var fogVertex: {
  95568. name: string;
  95569. shader: string;
  95570. };
  95571. }
  95572. declare module BABYLON {
  95573. /** @hidden */
  95574. export var shadowsVertex: {
  95575. name: string;
  95576. shader: string;
  95577. };
  95578. }
  95579. declare module BABYLON {
  95580. /** @hidden */
  95581. export var pointCloudVertex: {
  95582. name: string;
  95583. shader: string;
  95584. };
  95585. }
  95586. declare module BABYLON {
  95587. /** @hidden */
  95588. export var logDepthVertex: {
  95589. name: string;
  95590. shader: string;
  95591. };
  95592. }
  95593. declare module BABYLON {
  95594. /** @hidden */
  95595. export var defaultVertexShader: {
  95596. name: string;
  95597. shader: string;
  95598. };
  95599. }
  95600. declare module BABYLON {
  95601. /** @hidden */
  95602. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95603. MAINUV1: boolean;
  95604. MAINUV2: boolean;
  95605. DIFFUSE: boolean;
  95606. DIFFUSEDIRECTUV: number;
  95607. AMBIENT: boolean;
  95608. AMBIENTDIRECTUV: number;
  95609. OPACITY: boolean;
  95610. OPACITYDIRECTUV: number;
  95611. OPACITYRGB: boolean;
  95612. REFLECTION: boolean;
  95613. EMISSIVE: boolean;
  95614. EMISSIVEDIRECTUV: number;
  95615. SPECULAR: boolean;
  95616. SPECULARDIRECTUV: number;
  95617. BUMP: boolean;
  95618. BUMPDIRECTUV: number;
  95619. PARALLAX: boolean;
  95620. PARALLAXOCCLUSION: boolean;
  95621. SPECULAROVERALPHA: boolean;
  95622. CLIPPLANE: boolean;
  95623. CLIPPLANE2: boolean;
  95624. CLIPPLANE3: boolean;
  95625. CLIPPLANE4: boolean;
  95626. ALPHATEST: boolean;
  95627. DEPTHPREPASS: boolean;
  95628. ALPHAFROMDIFFUSE: boolean;
  95629. POINTSIZE: boolean;
  95630. FOG: boolean;
  95631. SPECULARTERM: boolean;
  95632. DIFFUSEFRESNEL: boolean;
  95633. OPACITYFRESNEL: boolean;
  95634. REFLECTIONFRESNEL: boolean;
  95635. REFRACTIONFRESNEL: boolean;
  95636. EMISSIVEFRESNEL: boolean;
  95637. FRESNEL: boolean;
  95638. NORMAL: boolean;
  95639. UV1: boolean;
  95640. UV2: boolean;
  95641. VERTEXCOLOR: boolean;
  95642. VERTEXALPHA: boolean;
  95643. NUM_BONE_INFLUENCERS: number;
  95644. BonesPerMesh: number;
  95645. BONETEXTURE: boolean;
  95646. INSTANCES: boolean;
  95647. GLOSSINESS: boolean;
  95648. ROUGHNESS: boolean;
  95649. EMISSIVEASILLUMINATION: boolean;
  95650. LINKEMISSIVEWITHDIFFUSE: boolean;
  95651. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95652. LIGHTMAP: boolean;
  95653. LIGHTMAPDIRECTUV: number;
  95654. OBJECTSPACE_NORMALMAP: boolean;
  95655. USELIGHTMAPASSHADOWMAP: boolean;
  95656. REFLECTIONMAP_3D: boolean;
  95657. REFLECTIONMAP_SPHERICAL: boolean;
  95658. REFLECTIONMAP_PLANAR: boolean;
  95659. REFLECTIONMAP_CUBIC: boolean;
  95660. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95661. REFLECTIONMAP_PROJECTION: boolean;
  95662. REFLECTIONMAP_SKYBOX: boolean;
  95663. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95664. REFLECTIONMAP_EXPLICIT: boolean;
  95665. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95666. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95667. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95668. INVERTCUBICMAP: boolean;
  95669. LOGARITHMICDEPTH: boolean;
  95670. REFRACTION: boolean;
  95671. REFRACTIONMAP_3D: boolean;
  95672. REFLECTIONOVERALPHA: boolean;
  95673. TWOSIDEDLIGHTING: boolean;
  95674. SHADOWFLOAT: boolean;
  95675. MORPHTARGETS: boolean;
  95676. MORPHTARGETS_NORMAL: boolean;
  95677. MORPHTARGETS_TANGENT: boolean;
  95678. NUM_MORPH_INFLUENCERS: number;
  95679. NONUNIFORMSCALING: boolean;
  95680. PREMULTIPLYALPHA: boolean;
  95681. IMAGEPROCESSING: boolean;
  95682. VIGNETTE: boolean;
  95683. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95684. VIGNETTEBLENDMODEOPAQUE: boolean;
  95685. TONEMAPPING: boolean;
  95686. TONEMAPPING_ACES: boolean;
  95687. CONTRAST: boolean;
  95688. COLORCURVES: boolean;
  95689. COLORGRADING: boolean;
  95690. COLORGRADING3D: boolean;
  95691. SAMPLER3DGREENDEPTH: boolean;
  95692. SAMPLER3DBGRMAP: boolean;
  95693. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95694. /**
  95695. * If the reflection texture on this material is in linear color space
  95696. * @hidden
  95697. */
  95698. IS_REFLECTION_LINEAR: boolean;
  95699. /**
  95700. * If the refraction texture on this material is in linear color space
  95701. * @hidden
  95702. */
  95703. IS_REFRACTION_LINEAR: boolean;
  95704. EXPOSURE: boolean;
  95705. constructor();
  95706. setReflectionMode(modeToEnable: string): void;
  95707. }
  95708. /**
  95709. * This is the default material used in Babylon. It is the best trade off between quality
  95710. * and performances.
  95711. * @see http://doc.babylonjs.com/babylon101/materials
  95712. */
  95713. export class StandardMaterial extends PushMaterial {
  95714. private _diffuseTexture;
  95715. /**
  95716. * The basic texture of the material as viewed under a light.
  95717. */
  95718. diffuseTexture: Nullable<BaseTexture>;
  95719. private _ambientTexture;
  95720. /**
  95721. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95722. */
  95723. ambientTexture: Nullable<BaseTexture>;
  95724. private _opacityTexture;
  95725. /**
  95726. * Define the transparency of the material from a texture.
  95727. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95728. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95729. */
  95730. opacityTexture: Nullable<BaseTexture>;
  95731. private _reflectionTexture;
  95732. /**
  95733. * Define the texture used to display the reflection.
  95734. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95735. */
  95736. reflectionTexture: Nullable<BaseTexture>;
  95737. private _emissiveTexture;
  95738. /**
  95739. * Define texture of the material as if self lit.
  95740. * This will be mixed in the final result even in the absence of light.
  95741. */
  95742. emissiveTexture: Nullable<BaseTexture>;
  95743. private _specularTexture;
  95744. /**
  95745. * Define how the color and intensity of the highlight given by the light in the material.
  95746. */
  95747. specularTexture: Nullable<BaseTexture>;
  95748. private _bumpTexture;
  95749. /**
  95750. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95751. * 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.
  95752. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95753. */
  95754. bumpTexture: Nullable<BaseTexture>;
  95755. private _lightmapTexture;
  95756. /**
  95757. * Complex lighting can be computationally expensive to compute at runtime.
  95758. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95759. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95760. */
  95761. lightmapTexture: Nullable<BaseTexture>;
  95762. private _refractionTexture;
  95763. /**
  95764. * Define the texture used to display the refraction.
  95765. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95766. */
  95767. refractionTexture: Nullable<BaseTexture>;
  95768. /**
  95769. * The color of the material lit by the environmental background lighting.
  95770. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95771. */
  95772. ambientColor: Color3;
  95773. /**
  95774. * The basic color of the material as viewed under a light.
  95775. */
  95776. diffuseColor: Color3;
  95777. /**
  95778. * Define how the color and intensity of the highlight given by the light in the material.
  95779. */
  95780. specularColor: Color3;
  95781. /**
  95782. * Define the color of the material as if self lit.
  95783. * This will be mixed in the final result even in the absence of light.
  95784. */
  95785. emissiveColor: Color3;
  95786. /**
  95787. * Defines how sharp are the highlights in the material.
  95788. * The bigger the value the sharper giving a more glossy feeling to the result.
  95789. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95790. */
  95791. specularPower: number;
  95792. private _useAlphaFromDiffuseTexture;
  95793. /**
  95794. * Does the transparency come from the diffuse texture alpha channel.
  95795. */
  95796. useAlphaFromDiffuseTexture: boolean;
  95797. private _useEmissiveAsIllumination;
  95798. /**
  95799. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95800. */
  95801. useEmissiveAsIllumination: boolean;
  95802. private _linkEmissiveWithDiffuse;
  95803. /**
  95804. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95805. * the emissive level when the final color is close to one.
  95806. */
  95807. linkEmissiveWithDiffuse: boolean;
  95808. private _useSpecularOverAlpha;
  95809. /**
  95810. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95811. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95812. */
  95813. useSpecularOverAlpha: boolean;
  95814. private _useReflectionOverAlpha;
  95815. /**
  95816. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95817. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95818. */
  95819. useReflectionOverAlpha: boolean;
  95820. private _disableLighting;
  95821. /**
  95822. * Does lights from the scene impacts this material.
  95823. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95824. */
  95825. disableLighting: boolean;
  95826. private _useObjectSpaceNormalMap;
  95827. /**
  95828. * Allows using an object space normal map (instead of tangent space).
  95829. */
  95830. useObjectSpaceNormalMap: boolean;
  95831. private _useParallax;
  95832. /**
  95833. * Is parallax enabled or not.
  95834. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95835. */
  95836. useParallax: boolean;
  95837. private _useParallaxOcclusion;
  95838. /**
  95839. * Is parallax occlusion enabled or not.
  95840. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95841. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95842. */
  95843. useParallaxOcclusion: boolean;
  95844. /**
  95845. * 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.
  95846. */
  95847. parallaxScaleBias: number;
  95848. private _roughness;
  95849. /**
  95850. * Helps to define how blurry the reflections should appears in the material.
  95851. */
  95852. roughness: number;
  95853. /**
  95854. * In case of refraction, define the value of the indice of refraction.
  95855. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95856. */
  95857. indexOfRefraction: number;
  95858. /**
  95859. * Invert the refraction texture alongside the y axis.
  95860. * It can be useful with procedural textures or probe for instance.
  95861. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95862. */
  95863. invertRefractionY: boolean;
  95864. /**
  95865. * Defines the alpha limits in alpha test mode.
  95866. */
  95867. alphaCutOff: number;
  95868. private _useLightmapAsShadowmap;
  95869. /**
  95870. * In case of light mapping, define whether the map contains light or shadow informations.
  95871. */
  95872. useLightmapAsShadowmap: boolean;
  95873. private _diffuseFresnelParameters;
  95874. /**
  95875. * Define the diffuse fresnel parameters of the material.
  95876. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95877. */
  95878. diffuseFresnelParameters: FresnelParameters;
  95879. private _opacityFresnelParameters;
  95880. /**
  95881. * Define the opacity fresnel parameters of the material.
  95882. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95883. */
  95884. opacityFresnelParameters: FresnelParameters;
  95885. private _reflectionFresnelParameters;
  95886. /**
  95887. * Define the reflection fresnel parameters of the material.
  95888. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95889. */
  95890. reflectionFresnelParameters: FresnelParameters;
  95891. private _refractionFresnelParameters;
  95892. /**
  95893. * Define the refraction fresnel parameters of the material.
  95894. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95895. */
  95896. refractionFresnelParameters: FresnelParameters;
  95897. private _emissiveFresnelParameters;
  95898. /**
  95899. * Define the emissive fresnel parameters of the material.
  95900. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95901. */
  95902. emissiveFresnelParameters: FresnelParameters;
  95903. private _useReflectionFresnelFromSpecular;
  95904. /**
  95905. * If true automatically deducts the fresnels values from the material specularity.
  95906. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95907. */
  95908. useReflectionFresnelFromSpecular: boolean;
  95909. private _useGlossinessFromSpecularMapAlpha;
  95910. /**
  95911. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95912. */
  95913. useGlossinessFromSpecularMapAlpha: boolean;
  95914. private _maxSimultaneousLights;
  95915. /**
  95916. * Defines the maximum number of lights that can be used in the material
  95917. */
  95918. maxSimultaneousLights: number;
  95919. private _invertNormalMapX;
  95920. /**
  95921. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95922. */
  95923. invertNormalMapX: boolean;
  95924. private _invertNormalMapY;
  95925. /**
  95926. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95927. */
  95928. invertNormalMapY: boolean;
  95929. private _twoSidedLighting;
  95930. /**
  95931. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95932. */
  95933. twoSidedLighting: boolean;
  95934. /**
  95935. * Default configuration related to image processing available in the standard Material.
  95936. */
  95937. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95938. /**
  95939. * Gets the image processing configuration used either in this material.
  95940. */
  95941. /**
  95942. * Sets the Default image processing configuration used either in the this material.
  95943. *
  95944. * If sets to null, the scene one is in use.
  95945. */
  95946. imageProcessingConfiguration: ImageProcessingConfiguration;
  95947. /**
  95948. * Keep track of the image processing observer to allow dispose and replace.
  95949. */
  95950. private _imageProcessingObserver;
  95951. /**
  95952. * Attaches a new image processing configuration to the Standard Material.
  95953. * @param configuration
  95954. */
  95955. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95956. /**
  95957. * Gets wether the color curves effect is enabled.
  95958. */
  95959. /**
  95960. * Sets wether the color curves effect is enabled.
  95961. */
  95962. cameraColorCurvesEnabled: boolean;
  95963. /**
  95964. * Gets wether the color grading effect is enabled.
  95965. */
  95966. /**
  95967. * Gets wether the color grading effect is enabled.
  95968. */
  95969. cameraColorGradingEnabled: boolean;
  95970. /**
  95971. * Gets wether tonemapping is enabled or not.
  95972. */
  95973. /**
  95974. * Sets wether tonemapping is enabled or not
  95975. */
  95976. cameraToneMappingEnabled: boolean;
  95977. /**
  95978. * The camera exposure used on this material.
  95979. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95980. * This corresponds to a photographic exposure.
  95981. */
  95982. /**
  95983. * The camera exposure used on this material.
  95984. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95985. * This corresponds to a photographic exposure.
  95986. */
  95987. cameraExposure: number;
  95988. /**
  95989. * Gets The camera contrast used on this material.
  95990. */
  95991. /**
  95992. * Sets The camera contrast used on this material.
  95993. */
  95994. cameraContrast: number;
  95995. /**
  95996. * Gets the Color Grading 2D Lookup Texture.
  95997. */
  95998. /**
  95999. * Sets the Color Grading 2D Lookup Texture.
  96000. */
  96001. cameraColorGradingTexture: Nullable<BaseTexture>;
  96002. /**
  96003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96005. * 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;
  96006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96007. */
  96008. /**
  96009. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96010. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96011. * 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;
  96012. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96013. */
  96014. cameraColorCurves: Nullable<ColorCurves>;
  96015. /**
  96016. * Custom callback helping to override the default shader used in the material.
  96017. */
  96018. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  96019. protected _renderTargets: SmartArray<RenderTargetTexture>;
  96020. protected _worldViewProjectionMatrix: Matrix;
  96021. protected _globalAmbientColor: Color3;
  96022. protected _useLogarithmicDepth: boolean;
  96023. /**
  96024. * Instantiates a new standard material.
  96025. * This is the default material used in Babylon. It is the best trade off between quality
  96026. * and performances.
  96027. * @see http://doc.babylonjs.com/babylon101/materials
  96028. * @param name Define the name of the material in the scene
  96029. * @param scene Define the scene the material belong to
  96030. */
  96031. constructor(name: string, scene: Scene);
  96032. /**
  96033. * Gets a boolean indicating that current material needs to register RTT
  96034. */
  96035. readonly hasRenderTargetTextures: boolean;
  96036. /**
  96037. * Gets the current class name of the material e.g. "StandardMaterial"
  96038. * Mainly use in serialization.
  96039. * @returns the class name
  96040. */
  96041. getClassName(): string;
  96042. /**
  96043. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  96044. * You can try switching to logarithmic depth.
  96045. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  96046. */
  96047. useLogarithmicDepth: boolean;
  96048. /**
  96049. * Specifies if the material will require alpha blending
  96050. * @returns a boolean specifying if alpha blending is needed
  96051. */
  96052. needAlphaBlending(): boolean;
  96053. /**
  96054. * Specifies if this material should be rendered in alpha test mode
  96055. * @returns a boolean specifying if an alpha test is needed.
  96056. */
  96057. needAlphaTesting(): boolean;
  96058. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  96059. /**
  96060. * Get the texture used for alpha test purpose.
  96061. * @returns the diffuse texture in case of the standard material.
  96062. */
  96063. getAlphaTestTexture(): Nullable<BaseTexture>;
  96064. /**
  96065. * Get if the submesh is ready to be used and all its information available.
  96066. * Child classes can use it to update shaders
  96067. * @param mesh defines the mesh to check
  96068. * @param subMesh defines which submesh to check
  96069. * @param useInstances specifies that instances should be used
  96070. * @returns a boolean indicating that the submesh is ready or not
  96071. */
  96072. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96073. /**
  96074. * Builds the material UBO layouts.
  96075. * Used internally during the effect preparation.
  96076. */
  96077. buildUniformLayout(): void;
  96078. /**
  96079. * Unbinds the material from the mesh
  96080. */
  96081. unbind(): void;
  96082. /**
  96083. * Binds the submesh to this material by preparing the effect and shader to draw
  96084. * @param world defines the world transformation matrix
  96085. * @param mesh defines the mesh containing the submesh
  96086. * @param subMesh defines the submesh to bind the material to
  96087. */
  96088. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96089. /**
  96090. * Get the list of animatables in the material.
  96091. * @returns the list of animatables object used in the material
  96092. */
  96093. getAnimatables(): IAnimatable[];
  96094. /**
  96095. * Gets the active textures from the material
  96096. * @returns an array of textures
  96097. */
  96098. getActiveTextures(): BaseTexture[];
  96099. /**
  96100. * Specifies if the material uses a texture
  96101. * @param texture defines the texture to check against the material
  96102. * @returns a boolean specifying if the material uses the texture
  96103. */
  96104. hasTexture(texture: BaseTexture): boolean;
  96105. /**
  96106. * Disposes the material
  96107. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96108. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96109. */
  96110. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  96111. /**
  96112. * Makes a duplicate of the material, and gives it a new name
  96113. * @param name defines the new name for the duplicated material
  96114. * @returns the cloned material
  96115. */
  96116. clone(name: string): StandardMaterial;
  96117. /**
  96118. * Serializes this material in a JSON representation
  96119. * @returns the serialized material object
  96120. */
  96121. serialize(): any;
  96122. /**
  96123. * Creates a standard material from parsed material data
  96124. * @param source defines the JSON representation of the material
  96125. * @param scene defines the hosting scene
  96126. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96127. * @returns a new standard material
  96128. */
  96129. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  96130. /**
  96131. * Are diffuse textures enabled in the application.
  96132. */
  96133. static DiffuseTextureEnabled: boolean;
  96134. /**
  96135. * Are ambient textures enabled in the application.
  96136. */
  96137. static AmbientTextureEnabled: boolean;
  96138. /**
  96139. * Are opacity textures enabled in the application.
  96140. */
  96141. static OpacityTextureEnabled: boolean;
  96142. /**
  96143. * Are reflection textures enabled in the application.
  96144. */
  96145. static ReflectionTextureEnabled: boolean;
  96146. /**
  96147. * Are emissive textures enabled in the application.
  96148. */
  96149. static EmissiveTextureEnabled: boolean;
  96150. /**
  96151. * Are specular textures enabled in the application.
  96152. */
  96153. static SpecularTextureEnabled: boolean;
  96154. /**
  96155. * Are bump textures enabled in the application.
  96156. */
  96157. static BumpTextureEnabled: boolean;
  96158. /**
  96159. * Are lightmap textures enabled in the application.
  96160. */
  96161. static LightmapTextureEnabled: boolean;
  96162. /**
  96163. * Are refraction textures enabled in the application.
  96164. */
  96165. static RefractionTextureEnabled: boolean;
  96166. /**
  96167. * Are color grading textures enabled in the application.
  96168. */
  96169. static ColorGradingTextureEnabled: boolean;
  96170. /**
  96171. * Are fresnels enabled in the application.
  96172. */
  96173. static FresnelEnabled: boolean;
  96174. }
  96175. }
  96176. declare module BABYLON {
  96177. /**
  96178. * A class extending Texture allowing drawing on a texture
  96179. * @see http://doc.babylonjs.com/how_to/dynamictexture
  96180. */
  96181. export class DynamicTexture extends Texture {
  96182. private _generateMipMaps;
  96183. private _canvas;
  96184. private _context;
  96185. private _engine;
  96186. /**
  96187. * Creates a DynamicTexture
  96188. * @param name defines the name of the texture
  96189. * @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
  96190. * @param scene defines the scene where you want the texture
  96191. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  96192. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96193. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  96194. */
  96195. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  96196. /**
  96197. * Get the current class name of the texture useful for serialization or dynamic coding.
  96198. * @returns "DynamicTexture"
  96199. */
  96200. getClassName(): string;
  96201. /**
  96202. * Gets the current state of canRescale
  96203. */
  96204. readonly canRescale: boolean;
  96205. private _recreate;
  96206. /**
  96207. * Scales the texture
  96208. * @param ratio the scale factor to apply to both width and height
  96209. */
  96210. scale(ratio: number): void;
  96211. /**
  96212. * Resizes the texture
  96213. * @param width the new width
  96214. * @param height the new height
  96215. */
  96216. scaleTo(width: number, height: number): void;
  96217. /**
  96218. * Gets the context of the canvas used by the texture
  96219. * @returns the canvas context of the dynamic texture
  96220. */
  96221. getContext(): CanvasRenderingContext2D;
  96222. /**
  96223. * Clears the texture
  96224. */
  96225. clear(): void;
  96226. /**
  96227. * Updates the texture
  96228. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96229. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  96230. */
  96231. update(invertY?: boolean, premulAlpha?: boolean): void;
  96232. /**
  96233. * Draws text onto the texture
  96234. * @param text defines the text to be drawn
  96235. * @param x defines the placement of the text from the left
  96236. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  96237. * @param font defines the font to be used with font-style, font-size, font-name
  96238. * @param color defines the color used for the text
  96239. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  96240. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96241. * @param update defines whether texture is immediately update (default is true)
  96242. */
  96243. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  96244. /**
  96245. * Clones the texture
  96246. * @returns the clone of the texture.
  96247. */
  96248. clone(): DynamicTexture;
  96249. /**
  96250. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  96251. * @returns a serialized dynamic texture object
  96252. */
  96253. serialize(): any;
  96254. /** @hidden */
  96255. _rebuild(): void;
  96256. }
  96257. }
  96258. declare module BABYLON {
  96259. /** @hidden */
  96260. export var imageProcessingPixelShader: {
  96261. name: string;
  96262. shader: string;
  96263. };
  96264. }
  96265. declare module BABYLON {
  96266. /**
  96267. * ImageProcessingPostProcess
  96268. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  96269. */
  96270. export class ImageProcessingPostProcess extends PostProcess {
  96271. /**
  96272. * Default configuration related to image processing available in the PBR Material.
  96273. */
  96274. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96275. /**
  96276. * Gets the image processing configuration used either in this material.
  96277. */
  96278. /**
  96279. * Sets the Default image processing configuration used either in the this material.
  96280. *
  96281. * If sets to null, the scene one is in use.
  96282. */
  96283. imageProcessingConfiguration: ImageProcessingConfiguration;
  96284. /**
  96285. * Keep track of the image processing observer to allow dispose and replace.
  96286. */
  96287. private _imageProcessingObserver;
  96288. /**
  96289. * Attaches a new image processing configuration to the PBR Material.
  96290. * @param configuration
  96291. */
  96292. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  96293. /**
  96294. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  96295. */
  96296. /**
  96297. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  96298. */
  96299. colorCurves: Nullable<ColorCurves>;
  96300. /**
  96301. * Gets wether the color curves effect is enabled.
  96302. */
  96303. /**
  96304. * Sets wether the color curves effect is enabled.
  96305. */
  96306. colorCurvesEnabled: boolean;
  96307. /**
  96308. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  96309. */
  96310. /**
  96311. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  96312. */
  96313. colorGradingTexture: Nullable<BaseTexture>;
  96314. /**
  96315. * Gets wether the color grading effect is enabled.
  96316. */
  96317. /**
  96318. * Gets wether the color grading effect is enabled.
  96319. */
  96320. colorGradingEnabled: boolean;
  96321. /**
  96322. * Gets exposure used in the effect.
  96323. */
  96324. /**
  96325. * Sets exposure used in the effect.
  96326. */
  96327. exposure: number;
  96328. /**
  96329. * Gets wether tonemapping is enabled or not.
  96330. */
  96331. /**
  96332. * Sets wether tonemapping is enabled or not
  96333. */
  96334. toneMappingEnabled: boolean;
  96335. /**
  96336. * Gets the type of tone mapping effect.
  96337. */
  96338. /**
  96339. * Sets the type of tone mapping effect.
  96340. */
  96341. toneMappingType: number;
  96342. /**
  96343. * Gets contrast used in the effect.
  96344. */
  96345. /**
  96346. * Sets contrast used in the effect.
  96347. */
  96348. contrast: number;
  96349. /**
  96350. * Gets Vignette stretch size.
  96351. */
  96352. /**
  96353. * Sets Vignette stretch size.
  96354. */
  96355. vignetteStretch: number;
  96356. /**
  96357. * Gets Vignette centre X Offset.
  96358. */
  96359. /**
  96360. * Sets Vignette centre X Offset.
  96361. */
  96362. vignetteCentreX: number;
  96363. /**
  96364. * Gets Vignette centre Y Offset.
  96365. */
  96366. /**
  96367. * Sets Vignette centre Y Offset.
  96368. */
  96369. vignetteCentreY: number;
  96370. /**
  96371. * Gets Vignette weight or intensity of the vignette effect.
  96372. */
  96373. /**
  96374. * Sets Vignette weight or intensity of the vignette effect.
  96375. */
  96376. vignetteWeight: number;
  96377. /**
  96378. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96379. * if vignetteEnabled is set to true.
  96380. */
  96381. /**
  96382. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96383. * if vignetteEnabled is set to true.
  96384. */
  96385. vignetteColor: Color4;
  96386. /**
  96387. * Gets Camera field of view used by the Vignette effect.
  96388. */
  96389. /**
  96390. * Sets Camera field of view used by the Vignette effect.
  96391. */
  96392. vignetteCameraFov: number;
  96393. /**
  96394. * Gets the vignette blend mode allowing different kind of effect.
  96395. */
  96396. /**
  96397. * Sets the vignette blend mode allowing different kind of effect.
  96398. */
  96399. vignetteBlendMode: number;
  96400. /**
  96401. * Gets wether the vignette effect is enabled.
  96402. */
  96403. /**
  96404. * Sets wether the vignette effect is enabled.
  96405. */
  96406. vignetteEnabled: boolean;
  96407. private _fromLinearSpace;
  96408. /**
  96409. * Gets wether the input of the processing is in Gamma or Linear Space.
  96410. */
  96411. /**
  96412. * Sets wether the input of the processing is in Gamma or Linear Space.
  96413. */
  96414. fromLinearSpace: boolean;
  96415. /**
  96416. * Defines cache preventing GC.
  96417. */
  96418. private _defines;
  96419. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  96420. /**
  96421. * "ImageProcessingPostProcess"
  96422. * @returns "ImageProcessingPostProcess"
  96423. */
  96424. getClassName(): string;
  96425. protected _updateParameters(): void;
  96426. dispose(camera?: Camera): void;
  96427. }
  96428. }
  96429. declare module BABYLON {
  96430. /**
  96431. * Class containing static functions to help procedurally build meshes
  96432. */
  96433. export class GroundBuilder {
  96434. /**
  96435. * Creates a ground mesh
  96436. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  96437. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  96438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96439. * @param name defines the name of the mesh
  96440. * @param options defines the options used to create the mesh
  96441. * @param scene defines the hosting scene
  96442. * @returns the ground mesh
  96443. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  96444. */
  96445. static CreateGround(name: string, options: {
  96446. width?: number;
  96447. height?: number;
  96448. subdivisions?: number;
  96449. subdivisionsX?: number;
  96450. subdivisionsY?: number;
  96451. updatable?: boolean;
  96452. }, scene: any): Mesh;
  96453. /**
  96454. * Creates a tiled ground mesh
  96455. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  96456. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  96457. * * 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
  96458. * * 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
  96459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96460. * @param name defines the name of the mesh
  96461. * @param options defines the options used to create the mesh
  96462. * @param scene defines the hosting scene
  96463. * @returns the tiled ground mesh
  96464. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  96465. */
  96466. static CreateTiledGround(name: string, options: {
  96467. xmin: number;
  96468. zmin: number;
  96469. xmax: number;
  96470. zmax: number;
  96471. subdivisions?: {
  96472. w: number;
  96473. h: number;
  96474. };
  96475. precision?: {
  96476. w: number;
  96477. h: number;
  96478. };
  96479. updatable?: boolean;
  96480. }, scene: Scene): Mesh;
  96481. /**
  96482. * Creates a ground mesh from a height map
  96483. * * The parameter `url` sets the URL of the height map image resource.
  96484. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  96485. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  96486. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  96487. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  96488. * * 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.
  96489. * * 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).
  96490. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96492. * @param name defines the name of the mesh
  96493. * @param url defines the url to the height map
  96494. * @param options defines the options used to create the mesh
  96495. * @param scene defines the hosting scene
  96496. * @returns the ground mesh
  96497. * @see https://doc.babylonjs.com/babylon101/height_map
  96498. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  96499. */
  96500. static CreateGroundFromHeightMap(name: string, url: string, options: {
  96501. width?: number;
  96502. height?: number;
  96503. subdivisions?: number;
  96504. minHeight?: number;
  96505. maxHeight?: number;
  96506. colorFilter?: Color3;
  96507. alphaFilter?: number;
  96508. updatable?: boolean;
  96509. onReady?: (mesh: GroundMesh) => void;
  96510. }, scene: Scene): GroundMesh;
  96511. }
  96512. }
  96513. declare module BABYLON {
  96514. /**
  96515. * Class containing static functions to help procedurally build meshes
  96516. */
  96517. export class TorusBuilder {
  96518. /**
  96519. * Creates a torus mesh
  96520. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  96521. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  96522. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  96523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96526. * @param name defines the name of the mesh
  96527. * @param options defines the options used to create the mesh
  96528. * @param scene defines the hosting scene
  96529. * @returns the torus mesh
  96530. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  96531. */
  96532. static CreateTorus(name: string, options: {
  96533. diameter?: number;
  96534. thickness?: number;
  96535. tessellation?: number;
  96536. updatable?: boolean;
  96537. sideOrientation?: number;
  96538. frontUVs?: Vector4;
  96539. backUVs?: Vector4;
  96540. }, scene: any): Mesh;
  96541. }
  96542. }
  96543. declare module BABYLON {
  96544. /**
  96545. * Class containing static functions to help procedurally build meshes
  96546. */
  96547. export class CylinderBuilder {
  96548. /**
  96549. * Creates a cylinder or a cone mesh
  96550. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  96551. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  96552. * * 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.
  96553. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  96554. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  96555. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  96556. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  96557. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  96558. * * 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).
  96559. * * 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
  96560. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  96561. * * 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
  96562. * * 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.
  96563. * * If `enclose` is false, a ring surface is one element.
  96564. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  96565. * * 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
  96566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96569. * @param name defines the name of the mesh
  96570. * @param options defines the options used to create the mesh
  96571. * @param scene defines the hosting scene
  96572. * @returns the cylinder mesh
  96573. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  96574. */
  96575. static CreateCylinder(name: string, options: {
  96576. height?: number;
  96577. diameterTop?: number;
  96578. diameterBottom?: number;
  96579. diameter?: number;
  96580. tessellation?: number;
  96581. subdivisions?: number;
  96582. arc?: number;
  96583. faceColors?: Color4[];
  96584. faceUV?: Vector4[];
  96585. updatable?: boolean;
  96586. hasRings?: boolean;
  96587. enclose?: boolean;
  96588. sideOrientation?: number;
  96589. frontUVs?: Vector4;
  96590. backUVs?: Vector4;
  96591. }, scene: any): Mesh;
  96592. }
  96593. }
  96594. declare module BABYLON {
  96595. /**
  96596. * Manager for handling gamepads
  96597. */
  96598. export class GamepadManager {
  96599. private _scene?;
  96600. private _babylonGamepads;
  96601. private _oneGamepadConnected;
  96602. /** @hidden */
  96603. _isMonitoring: boolean;
  96604. private _gamepadEventSupported;
  96605. private _gamepadSupport;
  96606. /**
  96607. * observable to be triggered when the gamepad controller has been connected
  96608. */
  96609. onGamepadConnectedObservable: Observable<Gamepad>;
  96610. /**
  96611. * observable to be triggered when the gamepad controller has been disconnected
  96612. */
  96613. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96614. private _onGamepadConnectedEvent;
  96615. private _onGamepadDisconnectedEvent;
  96616. /**
  96617. * Initializes the gamepad manager
  96618. * @param _scene BabylonJS scene
  96619. */
  96620. constructor(_scene?: Scene | undefined);
  96621. /**
  96622. * The gamepads in the game pad manager
  96623. */
  96624. readonly gamepads: Gamepad[];
  96625. /**
  96626. * Get the gamepad controllers based on type
  96627. * @param type The type of gamepad controller
  96628. * @returns Nullable gamepad
  96629. */
  96630. getGamepadByType(type?: number): Nullable<Gamepad>;
  96631. /**
  96632. * Disposes the gamepad manager
  96633. */
  96634. dispose(): void;
  96635. private _addNewGamepad;
  96636. private _startMonitoringGamepads;
  96637. private _stopMonitoringGamepads;
  96638. /** @hidden */
  96639. _checkGamepadsStatus(): void;
  96640. private _updateGamepadObjects;
  96641. }
  96642. }
  96643. declare module BABYLON {
  96644. interface Scene {
  96645. /** @hidden */
  96646. _gamepadManager: Nullable<GamepadManager>;
  96647. /**
  96648. * Gets the gamepad manager associated with the scene
  96649. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96650. */
  96651. gamepadManager: GamepadManager;
  96652. }
  96653. /**
  96654. * Interface representing a free camera inputs manager
  96655. */
  96656. interface FreeCameraInputsManager {
  96657. /**
  96658. * Adds gamepad input support to the FreeCameraInputsManager.
  96659. * @returns the FreeCameraInputsManager
  96660. */
  96661. addGamepad(): FreeCameraInputsManager;
  96662. }
  96663. /**
  96664. * Interface representing an arc rotate camera inputs manager
  96665. */
  96666. interface ArcRotateCameraInputsManager {
  96667. /**
  96668. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96669. * @returns the camera inputs manager
  96670. */
  96671. addGamepad(): ArcRotateCameraInputsManager;
  96672. }
  96673. /**
  96674. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96675. */
  96676. export class GamepadSystemSceneComponent implements ISceneComponent {
  96677. /**
  96678. * The component name helpfull to identify the component in the list of scene components.
  96679. */
  96680. readonly name: string;
  96681. /**
  96682. * The scene the component belongs to.
  96683. */
  96684. scene: Scene;
  96685. /**
  96686. * Creates a new instance of the component for the given scene
  96687. * @param scene Defines the scene to register the component in
  96688. */
  96689. constructor(scene: Scene);
  96690. /**
  96691. * Registers the component in a given scene
  96692. */
  96693. register(): void;
  96694. /**
  96695. * Rebuilds the elements related to this component in case of
  96696. * context lost for instance.
  96697. */
  96698. rebuild(): void;
  96699. /**
  96700. * Disposes the component and the associated ressources
  96701. */
  96702. dispose(): void;
  96703. private _beforeCameraUpdate;
  96704. }
  96705. }
  96706. declare module BABYLON {
  96707. /**
  96708. * Options to modify the vr teleportation behavior.
  96709. */
  96710. export interface VRTeleportationOptions {
  96711. /**
  96712. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96713. */
  96714. floorMeshName?: string;
  96715. /**
  96716. * A list of meshes to be used as the teleportation floor. (default: empty)
  96717. */
  96718. floorMeshes?: Mesh[];
  96719. }
  96720. /**
  96721. * Options to modify the vr experience helper's behavior.
  96722. */
  96723. export interface VRExperienceHelperOptions extends WebVROptions {
  96724. /**
  96725. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96726. */
  96727. createDeviceOrientationCamera?: boolean;
  96728. /**
  96729. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96730. */
  96731. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96732. /**
  96733. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96734. */
  96735. laserToggle?: boolean;
  96736. /**
  96737. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96738. */
  96739. floorMeshes?: Mesh[];
  96740. /**
  96741. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96742. */
  96743. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96744. }
  96745. /**
  96746. * Event containing information after VR has been entered
  96747. */
  96748. export class OnAfterEnteringVRObservableEvent {
  96749. /**
  96750. * If entering vr was successful
  96751. */
  96752. success: boolean;
  96753. }
  96754. /**
  96755. * Helps to quickly add VR support to an existing scene.
  96756. * See http://doc.babylonjs.com/how_to/webvr_helper
  96757. */
  96758. export class VRExperienceHelper {
  96759. /** Options to modify the vr experience helper's behavior. */
  96760. webVROptions: VRExperienceHelperOptions;
  96761. private _scene;
  96762. private _position;
  96763. private _btnVR;
  96764. private _btnVRDisplayed;
  96765. private _webVRsupported;
  96766. private _webVRready;
  96767. private _webVRrequesting;
  96768. private _webVRpresenting;
  96769. private _hasEnteredVR;
  96770. private _fullscreenVRpresenting;
  96771. private _canvas;
  96772. private _webVRCamera;
  96773. private _vrDeviceOrientationCamera;
  96774. private _deviceOrientationCamera;
  96775. private _existingCamera;
  96776. private _onKeyDown;
  96777. private _onVrDisplayPresentChange;
  96778. private _onVRDisplayChanged;
  96779. private _onVRRequestPresentStart;
  96780. private _onVRRequestPresentComplete;
  96781. /**
  96782. * Observable raised right before entering VR.
  96783. */
  96784. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96785. /**
  96786. * Observable raised when entering VR has completed.
  96787. */
  96788. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96789. /**
  96790. * Observable raised when exiting VR.
  96791. */
  96792. onExitingVRObservable: Observable<VRExperienceHelper>;
  96793. /**
  96794. * Observable raised when controller mesh is loaded.
  96795. */
  96796. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96797. /** Return this.onEnteringVRObservable
  96798. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96799. */
  96800. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96801. /** Return this.onExitingVRObservable
  96802. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96803. */
  96804. readonly onExitingVR: Observable<VRExperienceHelper>;
  96805. /** Return this.onControllerMeshLoadedObservable
  96806. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96807. */
  96808. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96809. private _rayLength;
  96810. private _useCustomVRButton;
  96811. private _teleportationRequested;
  96812. private _teleportActive;
  96813. private _floorMeshName;
  96814. private _floorMeshesCollection;
  96815. private _rotationAllowed;
  96816. private _teleportBackwardsVector;
  96817. private _teleportationTarget;
  96818. private _isDefaultTeleportationTarget;
  96819. private _postProcessMove;
  96820. private _teleportationFillColor;
  96821. private _teleportationBorderColor;
  96822. private _rotationAngle;
  96823. private _haloCenter;
  96824. private _cameraGazer;
  96825. private _padSensibilityUp;
  96826. private _padSensibilityDown;
  96827. private _leftController;
  96828. private _rightController;
  96829. /**
  96830. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96831. */
  96832. onNewMeshSelected: Observable<AbstractMesh>;
  96833. /**
  96834. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96835. */
  96836. onNewMeshPicked: Observable<PickingInfo>;
  96837. private _circleEase;
  96838. /**
  96839. * Observable raised before camera teleportation
  96840. */
  96841. onBeforeCameraTeleport: Observable<Vector3>;
  96842. /**
  96843. * Observable raised after camera teleportation
  96844. */
  96845. onAfterCameraTeleport: Observable<Vector3>;
  96846. /**
  96847. * Observable raised when current selected mesh gets unselected
  96848. */
  96849. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96850. private _raySelectionPredicate;
  96851. /**
  96852. * To be optionaly changed by user to define custom ray selection
  96853. */
  96854. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96855. /**
  96856. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96857. */
  96858. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96859. /**
  96860. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96861. */
  96862. teleportationEnabled: boolean;
  96863. private _defaultHeight;
  96864. private _teleportationInitialized;
  96865. private _interactionsEnabled;
  96866. private _interactionsRequested;
  96867. private _displayGaze;
  96868. private _displayLaserPointer;
  96869. /**
  96870. * The mesh used to display where the user is going to teleport.
  96871. */
  96872. /**
  96873. * Sets the mesh to be used to display where the user is going to teleport.
  96874. */
  96875. teleportationTarget: Mesh;
  96876. /**
  96877. * 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
  96878. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96879. * See http://doc.babylonjs.com/resources/baking_transformations
  96880. */
  96881. gazeTrackerMesh: Mesh;
  96882. /**
  96883. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96884. */
  96885. updateGazeTrackerScale: boolean;
  96886. /**
  96887. * If the gaze trackers color should be updated when selecting meshes
  96888. */
  96889. updateGazeTrackerColor: boolean;
  96890. /**
  96891. * The gaze tracking mesh corresponding to the left controller
  96892. */
  96893. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96894. /**
  96895. * The gaze tracking mesh corresponding to the right controller
  96896. */
  96897. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96898. /**
  96899. * If the ray of the gaze should be displayed.
  96900. */
  96901. /**
  96902. * Sets if the ray of the gaze should be displayed.
  96903. */
  96904. displayGaze: boolean;
  96905. /**
  96906. * If the ray of the LaserPointer should be displayed.
  96907. */
  96908. /**
  96909. * Sets if the ray of the LaserPointer should be displayed.
  96910. */
  96911. displayLaserPointer: boolean;
  96912. /**
  96913. * The deviceOrientationCamera used as the camera when not in VR.
  96914. */
  96915. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96916. /**
  96917. * Based on the current WebVR support, returns the current VR camera used.
  96918. */
  96919. readonly currentVRCamera: Nullable<Camera>;
  96920. /**
  96921. * The webVRCamera which is used when in VR.
  96922. */
  96923. readonly webVRCamera: WebVRFreeCamera;
  96924. /**
  96925. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96926. */
  96927. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96928. private readonly _teleportationRequestInitiated;
  96929. /**
  96930. * Defines wether or not Pointer lock should be requested when switching to
  96931. * full screen.
  96932. */
  96933. requestPointerLockOnFullScreen: boolean;
  96934. /**
  96935. * Instantiates a VRExperienceHelper.
  96936. * Helps to quickly add VR support to an existing scene.
  96937. * @param scene The scene the VRExperienceHelper belongs to.
  96938. * @param webVROptions Options to modify the vr experience helper's behavior.
  96939. */
  96940. constructor(scene: Scene,
  96941. /** Options to modify the vr experience helper's behavior. */
  96942. webVROptions?: VRExperienceHelperOptions);
  96943. private _onDefaultMeshLoaded;
  96944. private _onResize;
  96945. private _onFullscreenChange;
  96946. /**
  96947. * Gets a value indicating if we are currently in VR mode.
  96948. */
  96949. readonly isInVRMode: boolean;
  96950. private onVrDisplayPresentChange;
  96951. private onVRDisplayChanged;
  96952. private moveButtonToBottomRight;
  96953. private displayVRButton;
  96954. private updateButtonVisibility;
  96955. private _cachedAngularSensibility;
  96956. /**
  96957. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96958. * Otherwise, will use the fullscreen API.
  96959. */
  96960. enterVR(): void;
  96961. /**
  96962. * Attempt to exit VR, or fullscreen.
  96963. */
  96964. exitVR(): void;
  96965. /**
  96966. * The position of the vr experience helper.
  96967. */
  96968. /**
  96969. * Sets the position of the vr experience helper.
  96970. */
  96971. position: Vector3;
  96972. /**
  96973. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96974. */
  96975. enableInteractions(): void;
  96976. private readonly _noControllerIsActive;
  96977. private beforeRender;
  96978. private _isTeleportationFloor;
  96979. /**
  96980. * Adds a floor mesh to be used for teleportation.
  96981. * @param floorMesh the mesh to be used for teleportation.
  96982. */
  96983. addFloorMesh(floorMesh: Mesh): void;
  96984. /**
  96985. * Removes a floor mesh from being used for teleportation.
  96986. * @param floorMesh the mesh to be removed.
  96987. */
  96988. removeFloorMesh(floorMesh: Mesh): void;
  96989. /**
  96990. * Enables interactions and teleportation using the VR controllers and gaze.
  96991. * @param vrTeleportationOptions options to modify teleportation behavior.
  96992. */
  96993. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96994. private _onNewGamepadConnected;
  96995. private _tryEnableInteractionOnController;
  96996. private _onNewGamepadDisconnected;
  96997. private _enableInteractionOnController;
  96998. private _checkTeleportWithRay;
  96999. private _checkRotate;
  97000. private _checkTeleportBackwards;
  97001. private _enableTeleportationOnController;
  97002. private _createTeleportationCircles;
  97003. private _displayTeleportationTarget;
  97004. private _hideTeleportationTarget;
  97005. private _rotateCamera;
  97006. private _moveTeleportationSelectorTo;
  97007. private _workingVector;
  97008. private _workingQuaternion;
  97009. private _workingMatrix;
  97010. /**
  97011. * Teleports the users feet to the desired location
  97012. * @param location The location where the user's feet should be placed
  97013. */
  97014. teleportCamera(location: Vector3): void;
  97015. private _convertNormalToDirectionOfRay;
  97016. private _castRayAndSelectObject;
  97017. private _notifySelectedMeshUnselected;
  97018. /**
  97019. * Sets the color of the laser ray from the vr controllers.
  97020. * @param color new color for the ray.
  97021. */
  97022. changeLaserColor(color: Color3): void;
  97023. /**
  97024. * Sets the color of the ray from the vr headsets gaze.
  97025. * @param color new color for the ray.
  97026. */
  97027. changeGazeColor(color: Color3): void;
  97028. /**
  97029. * Exits VR and disposes of the vr experience helper
  97030. */
  97031. dispose(): void;
  97032. /**
  97033. * Gets the name of the VRExperienceHelper class
  97034. * @returns "VRExperienceHelper"
  97035. */
  97036. getClassName(): string;
  97037. }
  97038. }
  97039. declare module BABYLON {
  97040. /**
  97041. * Manages an XRSession
  97042. * @see https://doc.babylonjs.com/how_to/webxr
  97043. */
  97044. export class WebXRSessionManager implements IDisposable {
  97045. private scene;
  97046. /**
  97047. * Fires every time a new xrFrame arrives which can be used to update the camera
  97048. */
  97049. onXRFrameObservable: Observable<any>;
  97050. /**
  97051. * Fires when the xr session is ended either by the device or manually done
  97052. */
  97053. onXRSessionEnded: Observable<any>;
  97054. /** @hidden */
  97055. _xrSession: XRSession;
  97056. /** @hidden */
  97057. _frameOfReference: XRFrameOfReference;
  97058. /** @hidden */
  97059. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  97060. /** @hidden */
  97061. _currentXRFrame: Nullable<XRFrame>;
  97062. private _xrNavigator;
  97063. private _xrDevice;
  97064. private _tmpMatrix;
  97065. /**
  97066. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  97067. * @param scene The scene which the session should be created for
  97068. */
  97069. constructor(scene: Scene);
  97070. /**
  97071. * Initializes the manager
  97072. * After initialization enterXR can be called to start an XR session
  97073. * @returns Promise which resolves after it is initialized
  97074. */
  97075. initializeAsync(): Promise<void>;
  97076. /**
  97077. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  97078. * @param sessionCreationOptions xr options to create the session with
  97079. * @param frameOfReferenceType option to configure how the xr pose is expressed
  97080. * @returns Promise which resolves after it enters XR
  97081. */
  97082. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  97083. /**
  97084. * Stops the xrSession and restores the renderloop
  97085. * @returns Promise which resolves after it exits XR
  97086. */
  97087. exitXRAsync(): Promise<void>;
  97088. /**
  97089. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97090. * @param ray ray to cast into the environment
  97091. * @returns Promise which resolves with a collision point in the environment if it exists
  97092. */
  97093. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97094. /**
  97095. * Checks if a session would be supported for the creation options specified
  97096. * @param options creation options to check if they are supported
  97097. * @returns true if supported
  97098. */
  97099. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97100. /**
  97101. * @hidden
  97102. * Converts the render layer of xrSession to a render target
  97103. * @param session session to create render target for
  97104. * @param scene scene the new render target should be created for
  97105. */
  97106. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  97107. /**
  97108. * Disposes of the session manager
  97109. */
  97110. dispose(): void;
  97111. }
  97112. }
  97113. declare module BABYLON {
  97114. /**
  97115. * WebXR Camera which holds the views for the xrSession
  97116. * @see https://doc.babylonjs.com/how_to/webxr
  97117. */
  97118. export class WebXRCamera extends FreeCamera {
  97119. private static _TmpMatrix;
  97120. /**
  97121. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  97122. * @param name the name of the camera
  97123. * @param scene the scene to add the camera to
  97124. */
  97125. constructor(name: string, scene: Scene);
  97126. private _updateNumberOfRigCameras;
  97127. /** @hidden */
  97128. _updateForDualEyeDebugging(pupilDistance?: number): void;
  97129. /**
  97130. * Updates the cameras position from the current pose information of the XR session
  97131. * @param xrSessionManager the session containing pose information
  97132. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  97133. */
  97134. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  97135. }
  97136. }
  97137. declare module BABYLON {
  97138. /**
  97139. * States of the webXR experience
  97140. */
  97141. export enum WebXRState {
  97142. /**
  97143. * Transitioning to being in XR mode
  97144. */
  97145. ENTERING_XR = 0,
  97146. /**
  97147. * Transitioning to non XR mode
  97148. */
  97149. EXITING_XR = 1,
  97150. /**
  97151. * In XR mode and presenting
  97152. */
  97153. IN_XR = 2,
  97154. /**
  97155. * Not entered XR mode
  97156. */
  97157. NOT_IN_XR = 3
  97158. }
  97159. /**
  97160. * Helper class used to enable XR
  97161. * @see https://doc.babylonjs.com/how_to/webxr
  97162. */
  97163. export class WebXRExperienceHelper implements IDisposable {
  97164. private scene;
  97165. /**
  97166. * 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
  97167. */
  97168. container: AbstractMesh;
  97169. /**
  97170. * Camera used to render xr content
  97171. */
  97172. camera: WebXRCamera;
  97173. /**
  97174. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  97175. */
  97176. state: WebXRState;
  97177. private _setState;
  97178. private static _TmpVector;
  97179. /**
  97180. * Fires when the state of the experience helper has changed
  97181. */
  97182. onStateChangedObservable: Observable<WebXRState>;
  97183. /** @hidden */
  97184. _sessionManager: WebXRSessionManager;
  97185. private _nonVRCamera;
  97186. private _originalSceneAutoClear;
  97187. private _supported;
  97188. /**
  97189. * Creates the experience helper
  97190. * @param scene the scene to attach the experience helper to
  97191. * @returns a promise for the experience helper
  97192. */
  97193. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  97194. /**
  97195. * Creates a WebXRExperienceHelper
  97196. * @param scene The scene the helper should be created in
  97197. */
  97198. private constructor();
  97199. /**
  97200. * Exits XR mode and returns the scene to its original state
  97201. * @returns promise that resolves after xr mode has exited
  97202. */
  97203. exitXRAsync(): Promise<void>;
  97204. /**
  97205. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  97206. * @param sessionCreationOptions options for the XR session
  97207. * @param frameOfReference frame of reference of the XR session
  97208. * @returns promise that resolves after xr mode has entered
  97209. */
  97210. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  97211. /**
  97212. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97213. * @param ray ray to cast into the environment
  97214. * @returns Promise which resolves with a collision point in the environment if it exists
  97215. */
  97216. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97217. /**
  97218. * Updates the global position of the camera by moving the camera's container
  97219. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  97220. * @param position The desired global position of the camera
  97221. */
  97222. setPositionOfCameraUsingContainer(position: Vector3): void;
  97223. /**
  97224. * Rotates the xr camera by rotating the camera's container around the camera's position
  97225. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  97226. * @param rotation the desired quaternion rotation to apply to the camera
  97227. */
  97228. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  97229. /**
  97230. * Checks if the creation options are supported by the xr session
  97231. * @param options creation options
  97232. * @returns true if supported
  97233. */
  97234. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97235. /**
  97236. * Disposes of the experience helper
  97237. */
  97238. dispose(): void;
  97239. }
  97240. }
  97241. declare module BABYLON {
  97242. /**
  97243. * Button which can be used to enter a different mode of XR
  97244. */
  97245. export class WebXREnterExitUIButton {
  97246. /** button element */
  97247. element: HTMLElement;
  97248. /** XR initialization options for the button */
  97249. initializationOptions: XRSessionCreationOptions;
  97250. /**
  97251. * Creates a WebXREnterExitUIButton
  97252. * @param element button element
  97253. * @param initializationOptions XR initialization options for the button
  97254. */
  97255. constructor(
  97256. /** button element */
  97257. element: HTMLElement,
  97258. /** XR initialization options for the button */
  97259. initializationOptions: XRSessionCreationOptions);
  97260. /**
  97261. * Overwritable function which can be used to update the button's visuals when the state changes
  97262. * @param activeButton the current active button in the UI
  97263. */
  97264. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  97265. }
  97266. /**
  97267. * Options to create the webXR UI
  97268. */
  97269. export class WebXREnterExitUIOptions {
  97270. /**
  97271. * Context to enter xr with
  97272. */
  97273. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  97274. /**
  97275. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  97276. */
  97277. customButtons?: Array<WebXREnterExitUIButton>;
  97278. }
  97279. /**
  97280. * UI to allow the user to enter/exit XR mode
  97281. */
  97282. export class WebXREnterExitUI implements IDisposable {
  97283. private scene;
  97284. private _overlay;
  97285. private _buttons;
  97286. private _activeButton;
  97287. /**
  97288. * Fired every time the active button is changed.
  97289. *
  97290. * When xr is entered via a button that launches xr that button will be the callback parameter
  97291. *
  97292. * When exiting xr the callback parameter will be null)
  97293. */
  97294. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  97295. /**
  97296. * Creates UI to allow the user to enter/exit XR mode
  97297. * @param scene the scene to add the ui to
  97298. * @param helper the xr experience helper to enter/exit xr with
  97299. * @param options options to configure the UI
  97300. * @returns the created ui
  97301. */
  97302. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  97303. private constructor();
  97304. private _updateButtons;
  97305. /**
  97306. * Disposes of the object
  97307. */
  97308. dispose(): void;
  97309. }
  97310. }
  97311. declare module BABYLON {
  97312. /**
  97313. * Represents an XR input
  97314. */
  97315. export class WebXRController {
  97316. /**
  97317. * 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
  97318. */
  97319. grip?: AbstractMesh;
  97320. /**
  97321. * Pointer which can be used to select objects or attach a visible laser to
  97322. */
  97323. pointer: AbstractMesh;
  97324. /**
  97325. * Creates the controller
  97326. * @see https://doc.babylonjs.com/how_to/webxr
  97327. * @param scene the scene which the controller should be associated to
  97328. */
  97329. constructor(scene: Scene);
  97330. /**
  97331. * Disposes of the object
  97332. */
  97333. dispose(): void;
  97334. }
  97335. /**
  97336. * XR input used to track XR inputs such as controllers/rays
  97337. */
  97338. export class WebXRInput implements IDisposable {
  97339. private helper;
  97340. /**
  97341. * XR controllers being tracked
  97342. */
  97343. controllers: Array<WebXRController>;
  97344. private _tmpMatrix;
  97345. private _frameObserver;
  97346. /**
  97347. * Initializes the WebXRInput
  97348. * @param helper experience helper which the input should be created for
  97349. */
  97350. constructor(helper: WebXRExperienceHelper);
  97351. /**
  97352. * Disposes of the object
  97353. */
  97354. dispose(): void;
  97355. }
  97356. }
  97357. declare module BABYLON {
  97358. /**
  97359. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  97360. */
  97361. export class WebXRManagedOutputCanvas implements IDisposable {
  97362. private _canvas;
  97363. /**
  97364. * xrpresent context of the canvas which can be used to display/mirror xr content
  97365. */
  97366. canvasContext: Nullable<WebGLRenderingContext>;
  97367. /**
  97368. * Initializes the canvas to be added/removed upon entering/exiting xr
  97369. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  97370. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  97371. */
  97372. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  97373. /**
  97374. * Disposes of the object
  97375. */
  97376. dispose(): void;
  97377. private _setManagedOutputCanvas;
  97378. private _addCanvas;
  97379. private _removeCanvas;
  97380. }
  97381. }
  97382. declare module BABYLON {
  97383. /**
  97384. * Contains an array of blocks representing the octree
  97385. */
  97386. export interface IOctreeContainer<T> {
  97387. /**
  97388. * Blocks within the octree
  97389. */
  97390. blocks: Array<OctreeBlock<T>>;
  97391. }
  97392. /**
  97393. * Class used to store a cell in an octree
  97394. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97395. */
  97396. export class OctreeBlock<T> {
  97397. /**
  97398. * Gets the content of the current block
  97399. */
  97400. entries: T[];
  97401. /**
  97402. * Gets the list of block children
  97403. */
  97404. blocks: Array<OctreeBlock<T>>;
  97405. private _depth;
  97406. private _maxDepth;
  97407. private _capacity;
  97408. private _minPoint;
  97409. private _maxPoint;
  97410. private _boundingVectors;
  97411. private _creationFunc;
  97412. /**
  97413. * Creates a new block
  97414. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  97415. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  97416. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97417. * @param depth defines the current depth of this block in the octree
  97418. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  97419. * @param creationFunc defines a callback to call when an element is added to the block
  97420. */
  97421. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  97422. /**
  97423. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97424. */
  97425. readonly capacity: number;
  97426. /**
  97427. * Gets the minimum vector (in world space) of the block's bounding box
  97428. */
  97429. readonly minPoint: Vector3;
  97430. /**
  97431. * Gets the maximum vector (in world space) of the block's bounding box
  97432. */
  97433. readonly maxPoint: Vector3;
  97434. /**
  97435. * Add a new element to this block
  97436. * @param entry defines the element to add
  97437. */
  97438. addEntry(entry: T): void;
  97439. /**
  97440. * Remove an element from this block
  97441. * @param entry defines the element to remove
  97442. */
  97443. removeEntry(entry: T): void;
  97444. /**
  97445. * Add an array of elements to this block
  97446. * @param entries defines the array of elements to add
  97447. */
  97448. addEntries(entries: T[]): void;
  97449. /**
  97450. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  97451. * @param frustumPlanes defines the frustum planes to test
  97452. * @param selection defines the array to store current content if selection is positive
  97453. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97454. */
  97455. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97456. /**
  97457. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  97458. * @param sphereCenter defines the bounding sphere center
  97459. * @param sphereRadius defines the bounding sphere radius
  97460. * @param selection defines the array to store current content if selection is positive
  97461. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97462. */
  97463. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97464. /**
  97465. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  97466. * @param ray defines the ray to test with
  97467. * @param selection defines the array to store current content if selection is positive
  97468. */
  97469. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  97470. /**
  97471. * Subdivide the content into child blocks (this block will then be empty)
  97472. */
  97473. createInnerBlocks(): void;
  97474. /**
  97475. * @hidden
  97476. */
  97477. 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;
  97478. }
  97479. }
  97480. declare module BABYLON {
  97481. /**
  97482. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  97483. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97484. */
  97485. export class Octree<T> {
  97486. /** 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.) */
  97487. maxDepth: number;
  97488. /**
  97489. * Blocks within the octree containing objects
  97490. */
  97491. blocks: Array<OctreeBlock<T>>;
  97492. /**
  97493. * Content stored in the octree
  97494. */
  97495. dynamicContent: T[];
  97496. private _maxBlockCapacity;
  97497. private _selectionContent;
  97498. private _creationFunc;
  97499. /**
  97500. * Creates a octree
  97501. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97502. * @param creationFunc function to be used to instatiate the octree
  97503. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  97504. * @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.)
  97505. */
  97506. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  97507. /** 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.) */
  97508. maxDepth?: number);
  97509. /**
  97510. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  97511. * @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);
  97512. * @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);
  97513. * @param entries meshes to be added to the octree blocks
  97514. */
  97515. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  97516. /**
  97517. * Adds a mesh to the octree
  97518. * @param entry Mesh to add to the octree
  97519. */
  97520. addMesh(entry: T): void;
  97521. /**
  97522. * Remove an element from the octree
  97523. * @param entry defines the element to remove
  97524. */
  97525. removeMesh(entry: T): void;
  97526. /**
  97527. * Selects an array of meshes within the frustum
  97528. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  97529. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  97530. * @returns array of meshes within the frustum
  97531. */
  97532. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  97533. /**
  97534. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  97535. * @param sphereCenter defines the bounding sphere center
  97536. * @param sphereRadius defines the bounding sphere radius
  97537. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97538. * @returns an array of objects that intersect the sphere
  97539. */
  97540. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  97541. /**
  97542. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  97543. * @param ray defines the ray to test with
  97544. * @returns array of intersected objects
  97545. */
  97546. intersectsRay(ray: Ray): SmartArray<T>;
  97547. /**
  97548. * Adds a mesh into the octree block if it intersects the block
  97549. */
  97550. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  97551. /**
  97552. * Adds a submesh into the octree block if it intersects the block
  97553. */
  97554. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  97555. }
  97556. }
  97557. declare module BABYLON {
  97558. interface Scene {
  97559. /**
  97560. * @hidden
  97561. * Backing Filed
  97562. */
  97563. _selectionOctree: Octree<AbstractMesh>;
  97564. /**
  97565. * Gets the octree used to boost mesh selection (picking)
  97566. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97567. */
  97568. selectionOctree: Octree<AbstractMesh>;
  97569. /**
  97570. * Creates or updates the octree used to boost selection (picking)
  97571. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97572. * @param maxCapacity defines the maximum capacity per leaf
  97573. * @param maxDepth defines the maximum depth of the octree
  97574. * @returns an octree of AbstractMesh
  97575. */
  97576. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  97577. }
  97578. interface AbstractMesh {
  97579. /**
  97580. * @hidden
  97581. * Backing Field
  97582. */
  97583. _submeshesOctree: Octree<SubMesh>;
  97584. /**
  97585. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  97586. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97587. * @param maxCapacity defines the maximum size of each block (64 by default)
  97588. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  97589. * @returns the new octree
  97590. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  97591. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97592. */
  97593. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  97594. }
  97595. /**
  97596. * Defines the octree scene component responsible to manage any octrees
  97597. * in a given scene.
  97598. */
  97599. export class OctreeSceneComponent {
  97600. /**
  97601. * The component name helpfull to identify the component in the list of scene components.
  97602. */
  97603. readonly name: string;
  97604. /**
  97605. * The scene the component belongs to.
  97606. */
  97607. scene: Scene;
  97608. /**
  97609. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97610. */
  97611. readonly checksIsEnabled: boolean;
  97612. /**
  97613. * Creates a new instance of the component for the given scene
  97614. * @param scene Defines the scene to register the component in
  97615. */
  97616. constructor(scene: Scene);
  97617. /**
  97618. * Registers the component in a given scene
  97619. */
  97620. register(): void;
  97621. /**
  97622. * Return the list of active meshes
  97623. * @returns the list of active meshes
  97624. */
  97625. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97626. /**
  97627. * Return the list of active sub meshes
  97628. * @param mesh The mesh to get the candidates sub meshes from
  97629. * @returns the list of active sub meshes
  97630. */
  97631. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97632. private _tempRay;
  97633. /**
  97634. * Return the list of sub meshes intersecting with a given local ray
  97635. * @param mesh defines the mesh to find the submesh for
  97636. * @param localRay defines the ray in local space
  97637. * @returns the list of intersecting sub meshes
  97638. */
  97639. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97640. /**
  97641. * Return the list of sub meshes colliding with a collider
  97642. * @param mesh defines the mesh to find the submesh for
  97643. * @param collider defines the collider to evaluate the collision against
  97644. * @returns the list of colliding sub meshes
  97645. */
  97646. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97647. /**
  97648. * Rebuilds the elements related to this component in case of
  97649. * context lost for instance.
  97650. */
  97651. rebuild(): void;
  97652. /**
  97653. * Disposes the component and the associated ressources.
  97654. */
  97655. dispose(): void;
  97656. }
  97657. }
  97658. declare module BABYLON {
  97659. /**
  97660. * Class containing static functions to help procedurally build meshes
  97661. */
  97662. export class LinesBuilder {
  97663. /**
  97664. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97665. * * 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
  97666. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97667. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97668. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97669. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97670. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97671. * * 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
  97672. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97675. * @param name defines the name of the new line system
  97676. * @param options defines the options used to create the line system
  97677. * @param scene defines the hosting scene
  97678. * @returns a new line system mesh
  97679. */
  97680. static CreateLineSystem(name: string, options: {
  97681. lines: Vector3[][];
  97682. updatable?: boolean;
  97683. instance?: Nullable<LinesMesh>;
  97684. colors?: Nullable<Color4[][]>;
  97685. useVertexAlpha?: boolean;
  97686. }, scene: Nullable<Scene>): LinesMesh;
  97687. /**
  97688. * Creates a line mesh
  97689. * 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
  97690. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97691. * * The parameter `points` is an array successive Vector3
  97692. * * 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
  97693. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97694. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97695. * * When updating an instance, remember that only point positions can change, not the number of points
  97696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97698. * @param name defines the name of the new line system
  97699. * @param options defines the options used to create the line system
  97700. * @param scene defines the hosting scene
  97701. * @returns a new line mesh
  97702. */
  97703. static CreateLines(name: string, options: {
  97704. points: Vector3[];
  97705. updatable?: boolean;
  97706. instance?: Nullable<LinesMesh>;
  97707. colors?: Color4[];
  97708. useVertexAlpha?: boolean;
  97709. }, scene?: Nullable<Scene>): LinesMesh;
  97710. /**
  97711. * Creates a dashed line mesh
  97712. * * 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
  97713. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97714. * * The parameter `points` is an array successive Vector3
  97715. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97716. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97717. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97718. * * 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
  97719. * * When updating an instance, remember that only point positions can change, not the number of points
  97720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97721. * @param name defines the name of the mesh
  97722. * @param options defines the options used to create the mesh
  97723. * @param scene defines the hosting scene
  97724. * @returns the dashed line mesh
  97725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97726. */
  97727. static CreateDashedLines(name: string, options: {
  97728. points: Vector3[];
  97729. dashSize?: number;
  97730. gapSize?: number;
  97731. dashNb?: number;
  97732. updatable?: boolean;
  97733. instance?: LinesMesh;
  97734. }, scene?: Nullable<Scene>): LinesMesh;
  97735. }
  97736. }
  97737. declare module BABYLON {
  97738. /**
  97739. * Renders a layer on top of an existing scene
  97740. */
  97741. export class UtilityLayerRenderer implements IDisposable {
  97742. /** the original scene that will be rendered on top of */
  97743. originalScene: Scene;
  97744. private _pointerCaptures;
  97745. private _lastPointerEvents;
  97746. private static _DefaultUtilityLayer;
  97747. private static _DefaultKeepDepthUtilityLayer;
  97748. /**
  97749. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97750. */
  97751. pickUtilitySceneFirst: boolean;
  97752. /**
  97753. * 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)
  97754. */
  97755. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97756. /**
  97757. * 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)
  97758. */
  97759. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97760. /**
  97761. * The scene that is rendered on top of the original scene
  97762. */
  97763. utilityLayerScene: Scene;
  97764. /**
  97765. * If the utility layer should automatically be rendered on top of existing scene
  97766. */
  97767. shouldRender: boolean;
  97768. /**
  97769. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97770. */
  97771. onlyCheckPointerDownEvents: boolean;
  97772. /**
  97773. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97774. */
  97775. processAllEvents: boolean;
  97776. /**
  97777. * Observable raised when the pointer move from the utility layer scene to the main scene
  97778. */
  97779. onPointerOutObservable: Observable<number>;
  97780. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97781. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97782. private _afterRenderObserver;
  97783. private _sceneDisposeObserver;
  97784. private _originalPointerObserver;
  97785. /**
  97786. * Instantiates a UtilityLayerRenderer
  97787. * @param originalScene the original scene that will be rendered on top of
  97788. * @param handleEvents boolean indicating if the utility layer should handle events
  97789. */
  97790. constructor(
  97791. /** the original scene that will be rendered on top of */
  97792. originalScene: Scene, handleEvents?: boolean);
  97793. private _notifyObservers;
  97794. /**
  97795. * Renders the utility layers scene on top of the original scene
  97796. */
  97797. render(): void;
  97798. /**
  97799. * Disposes of the renderer
  97800. */
  97801. dispose(): void;
  97802. private _updateCamera;
  97803. }
  97804. }
  97805. declare module BABYLON {
  97806. /**
  97807. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97808. */
  97809. export class Gizmo implements IDisposable {
  97810. /** The utility layer the gizmo will be added to */
  97811. gizmoLayer: UtilityLayerRenderer;
  97812. /**
  97813. * The root mesh of the gizmo
  97814. */
  97815. _rootMesh: Mesh;
  97816. private _attachedMesh;
  97817. /**
  97818. * Ratio for the scale of the gizmo (Default: 1)
  97819. */
  97820. scaleRatio: number;
  97821. private _tmpMatrix;
  97822. /**
  97823. * If a custom mesh has been set (Default: false)
  97824. */
  97825. protected _customMeshSet: boolean;
  97826. /**
  97827. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97828. * * When set, interactions will be enabled
  97829. */
  97830. attachedMesh: Nullable<AbstractMesh>;
  97831. /**
  97832. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97833. * @param mesh The mesh to replace the default mesh of the gizmo
  97834. */
  97835. setCustomMesh(mesh: Mesh): void;
  97836. /**
  97837. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97838. */
  97839. updateGizmoRotationToMatchAttachedMesh: boolean;
  97840. /**
  97841. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97842. */
  97843. updateGizmoPositionToMatchAttachedMesh: boolean;
  97844. /**
  97845. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97846. */
  97847. protected _updateScale: boolean;
  97848. protected _interactionsEnabled: boolean;
  97849. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97850. private _beforeRenderObserver;
  97851. /**
  97852. * Creates a gizmo
  97853. * @param gizmoLayer The utility layer the gizmo will be added to
  97854. */
  97855. constructor(
  97856. /** The utility layer the gizmo will be added to */
  97857. gizmoLayer?: UtilityLayerRenderer);
  97858. private _tempVector;
  97859. /**
  97860. * @hidden
  97861. * Updates the gizmo to match the attached mesh's position/rotation
  97862. */
  97863. protected _update(): void;
  97864. /**
  97865. * Disposes of the gizmo
  97866. */
  97867. dispose(): void;
  97868. }
  97869. }
  97870. declare module BABYLON {
  97871. /**
  97872. * Single axis drag gizmo
  97873. */
  97874. export class AxisDragGizmo extends Gizmo {
  97875. /**
  97876. * Drag behavior responsible for the gizmos dragging interactions
  97877. */
  97878. dragBehavior: PointerDragBehavior;
  97879. private _pointerObserver;
  97880. /**
  97881. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97882. */
  97883. snapDistance: number;
  97884. /**
  97885. * Event that fires each time the gizmo snaps to a new location.
  97886. * * snapDistance is the the change in distance
  97887. */
  97888. onSnapObservable: Observable<{
  97889. snapDistance: number;
  97890. }>;
  97891. /** @hidden */
  97892. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97893. /** @hidden */
  97894. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97895. /**
  97896. * Creates an AxisDragGizmo
  97897. * @param gizmoLayer The utility layer the gizmo will be added to
  97898. * @param dragAxis The axis which the gizmo will be able to drag on
  97899. * @param color The color of the gizmo
  97900. */
  97901. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97902. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97903. /**
  97904. * Disposes of the gizmo
  97905. */
  97906. dispose(): void;
  97907. }
  97908. }
  97909. declare module BABYLON.Debug {
  97910. /**
  97911. * The Axes viewer will show 3 axes in a specific point in space
  97912. */
  97913. export class AxesViewer {
  97914. private _xAxis;
  97915. private _yAxis;
  97916. private _zAxis;
  97917. private _scaleLinesFactor;
  97918. private _instanced;
  97919. /**
  97920. * Gets the hosting scene
  97921. */
  97922. scene: Scene;
  97923. /**
  97924. * Gets or sets a number used to scale line length
  97925. */
  97926. scaleLines: number;
  97927. /** Gets the node hierarchy used to render x-axis */
  97928. readonly xAxis: TransformNode;
  97929. /** Gets the node hierarchy used to render y-axis */
  97930. readonly yAxis: TransformNode;
  97931. /** Gets the node hierarchy used to render z-axis */
  97932. readonly zAxis: TransformNode;
  97933. /**
  97934. * Creates a new AxesViewer
  97935. * @param scene defines the hosting scene
  97936. * @param scaleLines defines a number used to scale line length (1 by default)
  97937. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97938. * @param xAxis defines the node hierarchy used to render the x-axis
  97939. * @param yAxis defines the node hierarchy used to render the y-axis
  97940. * @param zAxis defines the node hierarchy used to render the z-axis
  97941. */
  97942. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97943. /**
  97944. * Force the viewer to update
  97945. * @param position defines the position of the viewer
  97946. * @param xaxis defines the x axis of the viewer
  97947. * @param yaxis defines the y axis of the viewer
  97948. * @param zaxis defines the z axis of the viewer
  97949. */
  97950. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97951. /**
  97952. * Creates an instance of this axes viewer.
  97953. * @returns a new axes viewer with instanced meshes
  97954. */
  97955. createInstance(): AxesViewer;
  97956. /** Releases resources */
  97957. dispose(): void;
  97958. private static _SetRenderingGroupId;
  97959. }
  97960. }
  97961. declare module BABYLON.Debug {
  97962. /**
  97963. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97964. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97965. */
  97966. export class BoneAxesViewer extends AxesViewer {
  97967. /**
  97968. * Gets or sets the target mesh where to display the axes viewer
  97969. */
  97970. mesh: Nullable<Mesh>;
  97971. /**
  97972. * Gets or sets the target bone where to display the axes viewer
  97973. */
  97974. bone: Nullable<Bone>;
  97975. /** Gets current position */
  97976. pos: Vector3;
  97977. /** Gets direction of X axis */
  97978. xaxis: Vector3;
  97979. /** Gets direction of Y axis */
  97980. yaxis: Vector3;
  97981. /** Gets direction of Z axis */
  97982. zaxis: Vector3;
  97983. /**
  97984. * Creates a new BoneAxesViewer
  97985. * @param scene defines the hosting scene
  97986. * @param bone defines the target bone
  97987. * @param mesh defines the target mesh
  97988. * @param scaleLines defines a scaling factor for line length (1 by default)
  97989. */
  97990. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97991. /**
  97992. * Force the viewer to update
  97993. */
  97994. update(): void;
  97995. /** Releases resources */
  97996. dispose(): void;
  97997. }
  97998. }
  97999. declare module BABYLON {
  98000. /**
  98001. * Interface used to define scene explorer extensibility option
  98002. */
  98003. export interface IExplorerExtensibilityOption {
  98004. /**
  98005. * Define the option label
  98006. */
  98007. label: string;
  98008. /**
  98009. * Defines the action to execute on click
  98010. */
  98011. action: (entity: any) => void;
  98012. }
  98013. /**
  98014. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  98015. */
  98016. export interface IExplorerExtensibilityGroup {
  98017. /**
  98018. * Defines a predicate to test if a given type mut be extended
  98019. */
  98020. predicate: (entity: any) => boolean;
  98021. /**
  98022. * Gets the list of options added to a type
  98023. */
  98024. entries: IExplorerExtensibilityOption[];
  98025. }
  98026. /**
  98027. * Interface used to define the options to use to create the Inspector
  98028. */
  98029. export interface IInspectorOptions {
  98030. /**
  98031. * Display in overlay mode (default: false)
  98032. */
  98033. overlay?: boolean;
  98034. /**
  98035. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  98036. */
  98037. globalRoot?: HTMLElement;
  98038. /**
  98039. * Display the Scene explorer
  98040. */
  98041. showExplorer?: boolean;
  98042. /**
  98043. * Display the property inspector
  98044. */
  98045. showInspector?: boolean;
  98046. /**
  98047. * Display in embed mode (both panes on the right)
  98048. */
  98049. embedMode?: boolean;
  98050. /**
  98051. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  98052. */
  98053. handleResize?: boolean;
  98054. /**
  98055. * Allow the panes to popup (default: true)
  98056. */
  98057. enablePopup?: boolean;
  98058. /**
  98059. * Allow the panes to be closed by users (default: true)
  98060. */
  98061. enableClose?: boolean;
  98062. /**
  98063. * Optional list of extensibility entries
  98064. */
  98065. explorerExtensibility?: IExplorerExtensibilityGroup[];
  98066. /**
  98067. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  98068. */
  98069. inspectorURL?: string;
  98070. }
  98071. interface Scene {
  98072. /**
  98073. * @hidden
  98074. * Backing field
  98075. */
  98076. _debugLayer: DebugLayer;
  98077. /**
  98078. * Gets the debug layer (aka Inspector) associated with the scene
  98079. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98080. */
  98081. debugLayer: DebugLayer;
  98082. }
  98083. /**
  98084. * The debug layer (aka Inspector) is the go to tool in order to better understand
  98085. * what is happening in your scene
  98086. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98087. */
  98088. export class DebugLayer {
  98089. /**
  98090. * Define the url to get the inspector script from.
  98091. * By default it uses the babylonjs CDN.
  98092. * @ignoreNaming
  98093. */
  98094. static InspectorURL: string;
  98095. private _scene;
  98096. private BJSINSPECTOR;
  98097. /**
  98098. * Observable triggered when a property is changed through the inspector.
  98099. */
  98100. onPropertyChangedObservable: Observable<{
  98101. object: any;
  98102. property: string;
  98103. value: any;
  98104. initialValue: any;
  98105. }>;
  98106. /**
  98107. * Instantiates a new debug layer.
  98108. * The debug layer (aka Inspector) is the go to tool in order to better understand
  98109. * what is happening in your scene
  98110. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98111. * @param scene Defines the scene to inspect
  98112. */
  98113. constructor(scene: Scene);
  98114. /** Creates the inspector window. */
  98115. private _createInspector;
  98116. /**
  98117. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  98118. * @param entity defines the entity to select
  98119. * @param lineContainerTitle defines the specific block to highlight
  98120. */
  98121. select(entity: any, lineContainerTitle?: string): void;
  98122. /** Get the inspector from bundle or global */
  98123. private _getGlobalInspector;
  98124. /**
  98125. * Get if the inspector is visible or not.
  98126. * @returns true if visible otherwise, false
  98127. */
  98128. isVisible(): boolean;
  98129. /**
  98130. * Hide the inspector and close its window.
  98131. */
  98132. hide(): void;
  98133. /**
  98134. * Launch the debugLayer.
  98135. * @param config Define the configuration of the inspector
  98136. * @return a promise fulfilled when the debug layer is visible
  98137. */
  98138. show(config?: IInspectorOptions): Promise<DebugLayer>;
  98139. }
  98140. }
  98141. declare module BABYLON {
  98142. /**
  98143. * Class containing static functions to help procedurally build meshes
  98144. */
  98145. export class BoxBuilder {
  98146. /**
  98147. * Creates a box mesh
  98148. * * The parameter `size` sets the size (float) of each box side (default 1)
  98149. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  98150. * * 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)
  98151. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  98152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98155. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  98156. * @param name defines the name of the mesh
  98157. * @param options defines the options used to create the mesh
  98158. * @param scene defines the hosting scene
  98159. * @returns the box mesh
  98160. */
  98161. static CreateBox(name: string, options: {
  98162. size?: number;
  98163. width?: number;
  98164. height?: number;
  98165. depth?: number;
  98166. faceUV?: Vector4[];
  98167. faceColors?: Color4[];
  98168. sideOrientation?: number;
  98169. frontUVs?: Vector4;
  98170. backUVs?: Vector4;
  98171. updatable?: boolean;
  98172. }, scene?: Nullable<Scene>): Mesh;
  98173. }
  98174. }
  98175. declare module BABYLON {
  98176. /**
  98177. * Class containing static functions to help procedurally build meshes
  98178. */
  98179. export class SphereBuilder {
  98180. /**
  98181. * Creates a sphere mesh
  98182. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  98183. * * 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`)
  98184. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  98185. * * 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
  98186. * * 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)
  98187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98190. * @param name defines the name of the mesh
  98191. * @param options defines the options used to create the mesh
  98192. * @param scene defines the hosting scene
  98193. * @returns the sphere mesh
  98194. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  98195. */
  98196. static CreateSphere(name: string, options: {
  98197. segments?: number;
  98198. diameter?: number;
  98199. diameterX?: number;
  98200. diameterY?: number;
  98201. diameterZ?: number;
  98202. arc?: number;
  98203. slice?: number;
  98204. sideOrientation?: number;
  98205. frontUVs?: Vector4;
  98206. backUVs?: Vector4;
  98207. updatable?: boolean;
  98208. }, scene: any): Mesh;
  98209. }
  98210. }
  98211. declare module BABYLON.Debug {
  98212. /**
  98213. * Used to show the physics impostor around the specific mesh
  98214. */
  98215. export class PhysicsViewer {
  98216. /** @hidden */
  98217. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  98218. /** @hidden */
  98219. protected _meshes: Array<Nullable<AbstractMesh>>;
  98220. /** @hidden */
  98221. protected _scene: Nullable<Scene>;
  98222. /** @hidden */
  98223. protected _numMeshes: number;
  98224. /** @hidden */
  98225. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  98226. private _renderFunction;
  98227. private _utilityLayer;
  98228. private _debugBoxMesh;
  98229. private _debugSphereMesh;
  98230. private _debugMaterial;
  98231. /**
  98232. * Creates a new PhysicsViewer
  98233. * @param scene defines the hosting scene
  98234. */
  98235. constructor(scene: Scene);
  98236. /** @hidden */
  98237. protected _updateDebugMeshes(): void;
  98238. /**
  98239. * Renders a specified physic impostor
  98240. * @param impostor defines the impostor to render
  98241. * @returns the new debug mesh used to render the impostor
  98242. */
  98243. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  98244. /**
  98245. * Hides a specified physic impostor
  98246. * @param impostor defines the impostor to hide
  98247. */
  98248. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  98249. private _getDebugMaterial;
  98250. private _getDebugBoxMesh;
  98251. private _getDebugSphereMesh;
  98252. private _getDebugMesh;
  98253. /** Releases all resources */
  98254. dispose(): void;
  98255. }
  98256. }
  98257. declare module BABYLON {
  98258. /**
  98259. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  98260. * in order to better appreciate the issue one might have.
  98261. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  98262. */
  98263. export class RayHelper {
  98264. /**
  98265. * Defines the ray we are currently tryin to visualize.
  98266. */
  98267. ray: Nullable<Ray>;
  98268. private _renderPoints;
  98269. private _renderLine;
  98270. private _renderFunction;
  98271. private _scene;
  98272. private _updateToMeshFunction;
  98273. private _attachedToMesh;
  98274. private _meshSpaceDirection;
  98275. private _meshSpaceOrigin;
  98276. /**
  98277. * Helper function to create a colored helper in a scene in one line.
  98278. * @param ray Defines the ray we are currently tryin to visualize
  98279. * @param scene Defines the scene the ray is used in
  98280. * @param color Defines the color we want to see the ray in
  98281. * @returns The newly created ray helper.
  98282. */
  98283. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  98284. /**
  98285. * Instantiate a new ray helper.
  98286. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  98287. * in order to better appreciate the issue one might have.
  98288. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  98289. * @param ray Defines the ray we are currently tryin to visualize
  98290. */
  98291. constructor(ray: Ray);
  98292. /**
  98293. * Shows the ray we are willing to debug.
  98294. * @param scene Defines the scene the ray needs to be rendered in
  98295. * @param color Defines the color the ray needs to be rendered in
  98296. */
  98297. show(scene: Scene, color?: Color3): void;
  98298. /**
  98299. * Hides the ray we are debugging.
  98300. */
  98301. hide(): void;
  98302. private _render;
  98303. /**
  98304. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  98305. * @param mesh Defines the mesh we want the helper attached to
  98306. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  98307. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  98308. * @param length Defines the length of the ray
  98309. */
  98310. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  98311. /**
  98312. * Detach the ray helper from the mesh it has previously been attached to.
  98313. */
  98314. detachFromMesh(): void;
  98315. private _updateToMesh;
  98316. /**
  98317. * Dispose the helper and release its associated resources.
  98318. */
  98319. dispose(): void;
  98320. }
  98321. }
  98322. declare module BABYLON.Debug {
  98323. /**
  98324. * Class used to render a debug view of a given skeleton
  98325. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  98326. */
  98327. export class SkeletonViewer {
  98328. /** defines the skeleton to render */
  98329. skeleton: Skeleton;
  98330. /** defines the mesh attached to the skeleton */
  98331. mesh: AbstractMesh;
  98332. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98333. autoUpdateBonesMatrices: boolean;
  98334. /** defines the rendering group id to use with the viewer */
  98335. renderingGroupId: number;
  98336. /** Gets or sets the color used to render the skeleton */
  98337. color: Color3;
  98338. private _scene;
  98339. private _debugLines;
  98340. private _debugMesh;
  98341. private _isEnabled;
  98342. private _renderFunction;
  98343. private _utilityLayer;
  98344. /**
  98345. * Returns the mesh used to render the bones
  98346. */
  98347. readonly debugMesh: Nullable<LinesMesh>;
  98348. /**
  98349. * Creates a new SkeletonViewer
  98350. * @param skeleton defines the skeleton to render
  98351. * @param mesh defines the mesh attached to the skeleton
  98352. * @param scene defines the hosting scene
  98353. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  98354. * @param renderingGroupId defines the rendering group id to use with the viewer
  98355. */
  98356. constructor(
  98357. /** defines the skeleton to render */
  98358. skeleton: Skeleton,
  98359. /** defines the mesh attached to the skeleton */
  98360. mesh: AbstractMesh, scene: Scene,
  98361. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98362. autoUpdateBonesMatrices?: boolean,
  98363. /** defines the rendering group id to use with the viewer */
  98364. renderingGroupId?: number);
  98365. /** Gets or sets a boolean indicating if the viewer is enabled */
  98366. isEnabled: boolean;
  98367. private _getBonePosition;
  98368. private _getLinesForBonesWithLength;
  98369. private _getLinesForBonesNoLength;
  98370. /** Update the viewer to sync with current skeleton state */
  98371. update(): void;
  98372. /** Release associated resources */
  98373. dispose(): void;
  98374. }
  98375. }
  98376. declare module BABYLON {
  98377. /**
  98378. * Options to create the null engine
  98379. */
  98380. export class NullEngineOptions {
  98381. /**
  98382. * Render width (Default: 512)
  98383. */
  98384. renderWidth: number;
  98385. /**
  98386. * Render height (Default: 256)
  98387. */
  98388. renderHeight: number;
  98389. /**
  98390. * Texture size (Default: 512)
  98391. */
  98392. textureSize: number;
  98393. /**
  98394. * If delta time between frames should be constant
  98395. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98396. */
  98397. deterministicLockstep: boolean;
  98398. /**
  98399. * Maximum about of steps between frames (Default: 4)
  98400. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98401. */
  98402. lockstepMaxSteps: number;
  98403. }
  98404. /**
  98405. * The null engine class provides support for headless version of babylon.js.
  98406. * This can be used in server side scenario or for testing purposes
  98407. */
  98408. export class NullEngine extends Engine {
  98409. private _options;
  98410. /**
  98411. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98412. */
  98413. isDeterministicLockStep(): boolean;
  98414. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  98415. getLockstepMaxSteps(): number;
  98416. /**
  98417. * Sets hardware scaling, used to save performance if needed
  98418. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98419. */
  98420. getHardwareScalingLevel(): number;
  98421. constructor(options?: NullEngineOptions);
  98422. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98423. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  98424. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98425. getRenderWidth(useScreen?: boolean): number;
  98426. getRenderHeight(useScreen?: boolean): number;
  98427. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  98428. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  98429. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  98430. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  98431. bindSamplers(effect: Effect): void;
  98432. enableEffect(effect: Effect): void;
  98433. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98434. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  98435. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  98436. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  98437. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  98438. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  98439. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  98440. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  98441. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  98442. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  98443. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  98444. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  98445. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  98446. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  98447. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  98448. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98449. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98450. setFloat(uniform: WebGLUniformLocation, value: number): void;
  98451. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  98452. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  98453. setBool(uniform: WebGLUniformLocation, bool: number): void;
  98454. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  98455. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  98456. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  98457. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98458. bindBuffers(vertexBuffers: {
  98459. [key: string]: VertexBuffer;
  98460. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  98461. wipeCaches(bruteForce?: boolean): void;
  98462. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98463. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98464. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98465. /** @hidden */
  98466. _createTexture(): WebGLTexture;
  98467. /** @hidden */
  98468. _releaseTexture(texture: InternalTexture): void;
  98469. 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;
  98470. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98471. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98472. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  98473. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98474. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98475. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  98476. areAllEffectsReady(): boolean;
  98477. /**
  98478. * @hidden
  98479. * Get the current error code of the webGL context
  98480. * @returns the error code
  98481. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98482. */
  98483. getError(): number;
  98484. /** @hidden */
  98485. _getUnpackAlignement(): number;
  98486. /** @hidden */
  98487. _unpackFlipY(value: boolean): void;
  98488. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  98489. /**
  98490. * Updates a dynamic vertex buffer.
  98491. * @param vertexBuffer the vertex buffer to update
  98492. * @param data the data used to update the vertex buffer
  98493. * @param byteOffset the byte offset of the data (optional)
  98494. * @param byteLength the byte length of the data (optional)
  98495. */
  98496. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  98497. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  98498. /** @hidden */
  98499. _bindTexture(channel: number, texture: InternalTexture): void;
  98500. /** @hidden */
  98501. _releaseBuffer(buffer: WebGLBuffer): boolean;
  98502. releaseEffects(): void;
  98503. displayLoadingUI(): void;
  98504. hideLoadingUI(): void;
  98505. /** @hidden */
  98506. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98507. /** @hidden */
  98508. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98509. /** @hidden */
  98510. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98511. /** @hidden */
  98512. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  98513. }
  98514. }
  98515. declare module BABYLON {
  98516. /** @hidden */
  98517. export class _OcclusionDataStorage {
  98518. /** @hidden */
  98519. occlusionInternalRetryCounter: number;
  98520. /** @hidden */
  98521. isOcclusionQueryInProgress: boolean;
  98522. /** @hidden */
  98523. isOccluded: boolean;
  98524. /** @hidden */
  98525. occlusionRetryCount: number;
  98526. /** @hidden */
  98527. occlusionType: number;
  98528. /** @hidden */
  98529. occlusionQueryAlgorithmType: number;
  98530. }
  98531. interface Engine {
  98532. /**
  98533. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  98534. * @return the new query
  98535. */
  98536. createQuery(): WebGLQuery;
  98537. /**
  98538. * Delete and release a webGL query
  98539. * @param query defines the query to delete
  98540. * @return the current engine
  98541. */
  98542. deleteQuery(query: WebGLQuery): Engine;
  98543. /**
  98544. * Check if a given query has resolved and got its value
  98545. * @param query defines the query to check
  98546. * @returns true if the query got its value
  98547. */
  98548. isQueryResultAvailable(query: WebGLQuery): boolean;
  98549. /**
  98550. * Gets the value of a given query
  98551. * @param query defines the query to check
  98552. * @returns the value of the query
  98553. */
  98554. getQueryResult(query: WebGLQuery): number;
  98555. /**
  98556. * Initiates an occlusion query
  98557. * @param algorithmType defines the algorithm to use
  98558. * @param query defines the query to use
  98559. * @returns the current engine
  98560. * @see http://doc.babylonjs.com/features/occlusionquery
  98561. */
  98562. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  98563. /**
  98564. * Ends an occlusion query
  98565. * @see http://doc.babylonjs.com/features/occlusionquery
  98566. * @param algorithmType defines the algorithm to use
  98567. * @returns the current engine
  98568. */
  98569. endOcclusionQuery(algorithmType: number): Engine;
  98570. /**
  98571. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  98572. * Please note that only one query can be issued at a time
  98573. * @returns a time token used to track the time span
  98574. */
  98575. startTimeQuery(): Nullable<_TimeToken>;
  98576. /**
  98577. * Ends a time query
  98578. * @param token defines the token used to measure the time span
  98579. * @returns the time spent (in ns)
  98580. */
  98581. endTimeQuery(token: _TimeToken): int;
  98582. /** @hidden */
  98583. _currentNonTimestampToken: Nullable<_TimeToken>;
  98584. /** @hidden */
  98585. _createTimeQuery(): WebGLQuery;
  98586. /** @hidden */
  98587. _deleteTimeQuery(query: WebGLQuery): void;
  98588. /** @hidden */
  98589. _getGlAlgorithmType(algorithmType: number): number;
  98590. /** @hidden */
  98591. _getTimeQueryResult(query: WebGLQuery): any;
  98592. /** @hidden */
  98593. _getTimeQueryAvailability(query: WebGLQuery): any;
  98594. }
  98595. interface AbstractMesh {
  98596. /**
  98597. * Backing filed
  98598. * @hidden
  98599. */
  98600. __occlusionDataStorage: _OcclusionDataStorage;
  98601. /**
  98602. * Access property
  98603. * @hidden
  98604. */
  98605. _occlusionDataStorage: _OcclusionDataStorage;
  98606. /**
  98607. * 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.
  98608. * The default value is -1 which means don't break the query and wait till the result
  98609. * @see http://doc.babylonjs.com/features/occlusionquery
  98610. */
  98611. occlusionRetryCount: number;
  98612. /**
  98613. * 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:
  98614. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98615. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98616. * * 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.
  98617. * @see http://doc.babylonjs.com/features/occlusionquery
  98618. */
  98619. occlusionType: number;
  98620. /**
  98621. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98622. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98623. * * 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.
  98624. * @see http://doc.babylonjs.com/features/occlusionquery
  98625. */
  98626. occlusionQueryAlgorithmType: number;
  98627. /**
  98628. * 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
  98629. * @see http://doc.babylonjs.com/features/occlusionquery
  98630. */
  98631. isOccluded: boolean;
  98632. /**
  98633. * Flag to check the progress status of the query
  98634. * @see http://doc.babylonjs.com/features/occlusionquery
  98635. */
  98636. isOcclusionQueryInProgress: boolean;
  98637. }
  98638. }
  98639. declare module BABYLON {
  98640. /** @hidden */
  98641. export var _forceTransformFeedbackToBundle: boolean;
  98642. interface Engine {
  98643. /**
  98644. * Creates a webGL transform feedback object
  98645. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98646. * @returns the webGL transform feedback object
  98647. */
  98648. createTransformFeedback(): WebGLTransformFeedback;
  98649. /**
  98650. * Delete a webGL transform feedback object
  98651. * @param value defines the webGL transform feedback object to delete
  98652. */
  98653. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98654. /**
  98655. * Bind a webGL transform feedback object to the webgl context
  98656. * @param value defines the webGL transform feedback object to bind
  98657. */
  98658. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98659. /**
  98660. * Begins a transform feedback operation
  98661. * @param usePoints defines if points or triangles must be used
  98662. */
  98663. beginTransformFeedback(usePoints: boolean): void;
  98664. /**
  98665. * Ends a transform feedback operation
  98666. */
  98667. endTransformFeedback(): void;
  98668. /**
  98669. * Specify the varyings to use with transform feedback
  98670. * @param program defines the associated webGL program
  98671. * @param value defines the list of strings representing the varying names
  98672. */
  98673. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98674. /**
  98675. * Bind a webGL buffer for a transform feedback operation
  98676. * @param value defines the webGL buffer to bind
  98677. */
  98678. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98679. }
  98680. }
  98681. declare module BABYLON {
  98682. /**
  98683. * Gather the list of clipboard event types as constants.
  98684. */
  98685. export class ClipboardEventTypes {
  98686. /**
  98687. * The clipboard event is fired when a copy command is active (pressed).
  98688. */
  98689. static readonly COPY: number;
  98690. /**
  98691. * The clipboard event is fired when a cut command is active (pressed).
  98692. */
  98693. static readonly CUT: number;
  98694. /**
  98695. * The clipboard event is fired when a paste command is active (pressed).
  98696. */
  98697. static readonly PASTE: number;
  98698. }
  98699. /**
  98700. * This class is used to store clipboard related info for the onClipboardObservable event.
  98701. */
  98702. export class ClipboardInfo {
  98703. /**
  98704. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98705. */
  98706. type: number;
  98707. /**
  98708. * Defines the related dom event
  98709. */
  98710. event: ClipboardEvent;
  98711. /**
  98712. *Creates an instance of ClipboardInfo.
  98713. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98714. * @param event Defines the related dom event
  98715. */
  98716. constructor(
  98717. /**
  98718. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98719. */
  98720. type: number,
  98721. /**
  98722. * Defines the related dom event
  98723. */
  98724. event: ClipboardEvent);
  98725. /**
  98726. * Get the clipboard event's type from the keycode.
  98727. * @param keyCode Defines the keyCode for the current keyboard event.
  98728. * @return {number}
  98729. */
  98730. static GetTypeFromCharacter(keyCode: number): number;
  98731. }
  98732. }
  98733. declare module BABYLON {
  98734. /**
  98735. * Class used to represent data loading progression
  98736. */
  98737. export class SceneLoaderProgressEvent {
  98738. /** defines if data length to load can be evaluated */
  98739. readonly lengthComputable: boolean;
  98740. /** defines the loaded data length */
  98741. readonly loaded: number;
  98742. /** defines the data length to load */
  98743. readonly total: number;
  98744. /**
  98745. * Create a new progress event
  98746. * @param lengthComputable defines if data length to load can be evaluated
  98747. * @param loaded defines the loaded data length
  98748. * @param total defines the data length to load
  98749. */
  98750. constructor(
  98751. /** defines if data length to load can be evaluated */
  98752. lengthComputable: boolean,
  98753. /** defines the loaded data length */
  98754. loaded: number,
  98755. /** defines the data length to load */
  98756. total: number);
  98757. /**
  98758. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98759. * @param event defines the source event
  98760. * @returns a new SceneLoaderProgressEvent
  98761. */
  98762. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98763. }
  98764. /**
  98765. * Interface used by SceneLoader plugins to define supported file extensions
  98766. */
  98767. export interface ISceneLoaderPluginExtensions {
  98768. /**
  98769. * Defines the list of supported extensions
  98770. */
  98771. [extension: string]: {
  98772. isBinary: boolean;
  98773. };
  98774. }
  98775. /**
  98776. * Interface used by SceneLoader plugin factory
  98777. */
  98778. export interface ISceneLoaderPluginFactory {
  98779. /**
  98780. * Defines the name of the factory
  98781. */
  98782. name: string;
  98783. /**
  98784. * Function called to create a new plugin
  98785. * @return the new plugin
  98786. */
  98787. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98788. /**
  98789. * Boolean indicating if the plugin can direct load specific data
  98790. */
  98791. canDirectLoad?: (data: string) => boolean;
  98792. }
  98793. /**
  98794. * Interface used to define a SceneLoader plugin
  98795. */
  98796. export interface ISceneLoaderPlugin {
  98797. /**
  98798. * The friendly name of this plugin.
  98799. */
  98800. name: string;
  98801. /**
  98802. * The file extensions supported by this plugin.
  98803. */
  98804. extensions: string | ISceneLoaderPluginExtensions;
  98805. /**
  98806. * Import meshes into a scene.
  98807. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98808. * @param scene The scene to import into
  98809. * @param data The data to import
  98810. * @param rootUrl The root url for scene and resources
  98811. * @param meshes The meshes array to import into
  98812. * @param particleSystems The particle systems array to import into
  98813. * @param skeletons The skeletons array to import into
  98814. * @param onError The callback when import fails
  98815. * @returns True if successful or false otherwise
  98816. */
  98817. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98818. /**
  98819. * Load into a scene.
  98820. * @param scene The scene to load into
  98821. * @param data The data to import
  98822. * @param rootUrl The root url for scene and resources
  98823. * @param onError The callback when import fails
  98824. * @returns true if successful or false otherwise
  98825. */
  98826. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98827. /**
  98828. * The callback that returns true if the data can be directly loaded.
  98829. */
  98830. canDirectLoad?: (data: string) => boolean;
  98831. /**
  98832. * The callback that allows custom handling of the root url based on the response url.
  98833. */
  98834. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98835. /**
  98836. * Load into an asset container.
  98837. * @param scene The scene to load into
  98838. * @param data The data to import
  98839. * @param rootUrl The root url for scene and resources
  98840. * @param onError The callback when import fails
  98841. * @returns The loaded asset container
  98842. */
  98843. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98844. }
  98845. /**
  98846. * Interface used to define an async SceneLoader plugin
  98847. */
  98848. export interface ISceneLoaderPluginAsync {
  98849. /**
  98850. * The friendly name of this plugin.
  98851. */
  98852. name: string;
  98853. /**
  98854. * The file extensions supported by this plugin.
  98855. */
  98856. extensions: string | ISceneLoaderPluginExtensions;
  98857. /**
  98858. * Import meshes into a scene.
  98859. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98860. * @param scene The scene to import into
  98861. * @param data The data to import
  98862. * @param rootUrl The root url for scene and resources
  98863. * @param onProgress The callback when the load progresses
  98864. * @param fileName Defines the name of the file to load
  98865. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98866. */
  98867. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98868. meshes: AbstractMesh[];
  98869. particleSystems: IParticleSystem[];
  98870. skeletons: Skeleton[];
  98871. animationGroups: AnimationGroup[];
  98872. }>;
  98873. /**
  98874. * Load into a scene.
  98875. * @param scene The scene to load into
  98876. * @param data The data to import
  98877. * @param rootUrl The root url for scene and resources
  98878. * @param onProgress The callback when the load progresses
  98879. * @param fileName Defines the name of the file to load
  98880. * @returns Nothing
  98881. */
  98882. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98883. /**
  98884. * The callback that returns true if the data can be directly loaded.
  98885. */
  98886. canDirectLoad?: (data: string) => boolean;
  98887. /**
  98888. * The callback that allows custom handling of the root url based on the response url.
  98889. */
  98890. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98891. /**
  98892. * Load into an asset container.
  98893. * @param scene The scene to load into
  98894. * @param data The data to import
  98895. * @param rootUrl The root url for scene and resources
  98896. * @param onProgress The callback when the load progresses
  98897. * @param fileName Defines the name of the file to load
  98898. * @returns The loaded asset container
  98899. */
  98900. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98901. }
  98902. /**
  98903. * Class used to load scene from various file formats using registered plugins
  98904. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98905. */
  98906. export class SceneLoader {
  98907. /**
  98908. * No logging while loading
  98909. */
  98910. static readonly NO_LOGGING: number;
  98911. /**
  98912. * Minimal logging while loading
  98913. */
  98914. static readonly MINIMAL_LOGGING: number;
  98915. /**
  98916. * Summary logging while loading
  98917. */
  98918. static readonly SUMMARY_LOGGING: number;
  98919. /**
  98920. * Detailled logging while loading
  98921. */
  98922. static readonly DETAILED_LOGGING: number;
  98923. /**
  98924. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98925. */
  98926. static ForceFullSceneLoadingForIncremental: boolean;
  98927. /**
  98928. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98929. */
  98930. static ShowLoadingScreen: boolean;
  98931. /**
  98932. * Defines the current logging level (while loading the scene)
  98933. * @ignorenaming
  98934. */
  98935. static loggingLevel: number;
  98936. /**
  98937. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98938. */
  98939. static CleanBoneMatrixWeights: boolean;
  98940. /**
  98941. * Event raised when a plugin is used to load a scene
  98942. */
  98943. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98944. private static _registeredPlugins;
  98945. private static _getDefaultPlugin;
  98946. private static _getPluginForExtension;
  98947. private static _getPluginForDirectLoad;
  98948. private static _getPluginForFilename;
  98949. private static _getDirectLoad;
  98950. private static _loadData;
  98951. private static _getFileInfo;
  98952. /**
  98953. * Gets a plugin that can load the given extension
  98954. * @param extension defines the extension to load
  98955. * @returns a plugin or null if none works
  98956. */
  98957. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98958. /**
  98959. * Gets a boolean indicating that the given extension can be loaded
  98960. * @param extension defines the extension to load
  98961. * @returns true if the extension is supported
  98962. */
  98963. static IsPluginForExtensionAvailable(extension: string): boolean;
  98964. /**
  98965. * Adds a new plugin to the list of registered plugins
  98966. * @param plugin defines the plugin to add
  98967. */
  98968. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98969. /**
  98970. * Import meshes into a scene
  98971. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98972. * @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)
  98973. * @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)
  98974. * @param scene the instance of BABYLON.Scene to append to
  98975. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98976. * @param onProgress a callback with a progress event for each file being loaded
  98977. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98978. * @param pluginExtension the extension used to determine the plugin
  98979. * @returns The loaded plugin
  98980. */
  98981. 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>;
  98982. /**
  98983. * Import meshes into a scene
  98984. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98985. * @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)
  98986. * @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)
  98987. * @param scene the instance of BABYLON.Scene to append to
  98988. * @param onProgress a callback with a progress event for each file being loaded
  98989. * @param pluginExtension the extension used to determine the plugin
  98990. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98991. */
  98992. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98993. meshes: AbstractMesh[];
  98994. particleSystems: IParticleSystem[];
  98995. skeletons: Skeleton[];
  98996. animationGroups: AnimationGroup[];
  98997. }>;
  98998. /**
  98999. * Load a scene
  99000. * @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)
  99001. * @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)
  99002. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99003. * @param onSuccess a callback with the scene when import succeeds
  99004. * @param onProgress a callback with a progress event for each file being loaded
  99005. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99006. * @param pluginExtension the extension used to determine the plugin
  99007. * @returns The loaded plugin
  99008. */
  99009. 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>;
  99010. /**
  99011. * Load a scene
  99012. * @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)
  99013. * @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)
  99014. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99015. * @param onProgress a callback with a progress event for each file being loaded
  99016. * @param pluginExtension the extension used to determine the plugin
  99017. * @returns The loaded scene
  99018. */
  99019. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99020. /**
  99021. * Append a scene
  99022. * @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)
  99023. * @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)
  99024. * @param scene is the instance of BABYLON.Scene to append to
  99025. * @param onSuccess a callback with the scene when import succeeds
  99026. * @param onProgress a callback with a progress event for each file being loaded
  99027. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99028. * @param pluginExtension the extension used to determine the plugin
  99029. * @returns The loaded plugin
  99030. */
  99031. 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>;
  99032. /**
  99033. * Append a scene
  99034. * @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)
  99035. * @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)
  99036. * @param scene is the instance of BABYLON.Scene to append to
  99037. * @param onProgress a callback with a progress event for each file being loaded
  99038. * @param pluginExtension the extension used to determine the plugin
  99039. * @returns The given scene
  99040. */
  99041. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99042. /**
  99043. * Load a scene into an asset container
  99044. * @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)
  99045. * @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)
  99046. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  99047. * @param onSuccess a callback with the scene when import succeeds
  99048. * @param onProgress a callback with a progress event for each file being loaded
  99049. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99050. * @param pluginExtension the extension used to determine the plugin
  99051. * @returns The loaded plugin
  99052. */
  99053. 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>;
  99054. /**
  99055. * Load a scene into an asset container
  99056. * @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)
  99057. * @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)
  99058. * @param scene is the instance of Scene to append to
  99059. * @param onProgress a callback with a progress event for each file being loaded
  99060. * @param pluginExtension the extension used to determine the plugin
  99061. * @returns The loaded asset container
  99062. */
  99063. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  99064. }
  99065. }
  99066. declare module BABYLON {
  99067. /**
  99068. * Google Daydream controller
  99069. */
  99070. export class DaydreamController extends WebVRController {
  99071. /**
  99072. * Base Url for the controller model.
  99073. */
  99074. static MODEL_BASE_URL: string;
  99075. /**
  99076. * File name for the controller model.
  99077. */
  99078. static MODEL_FILENAME: string;
  99079. /**
  99080. * Gamepad Id prefix used to identify Daydream Controller.
  99081. */
  99082. static readonly GAMEPAD_ID_PREFIX: string;
  99083. /**
  99084. * Creates a new DaydreamController from a gamepad
  99085. * @param vrGamepad the gamepad that the controller should be created from
  99086. */
  99087. constructor(vrGamepad: any);
  99088. /**
  99089. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99090. * @param scene scene in which to add meshes
  99091. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99092. */
  99093. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99094. /**
  99095. * Called once for each button that changed state since the last frame
  99096. * @param buttonIdx Which button index changed
  99097. * @param state New state of the button
  99098. * @param changes Which properties on the state changed since last frame
  99099. */
  99100. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99101. }
  99102. }
  99103. declare module BABYLON {
  99104. /**
  99105. * Gear VR Controller
  99106. */
  99107. export class GearVRController extends WebVRController {
  99108. /**
  99109. * Base Url for the controller model.
  99110. */
  99111. static MODEL_BASE_URL: string;
  99112. /**
  99113. * File name for the controller model.
  99114. */
  99115. static MODEL_FILENAME: string;
  99116. /**
  99117. * Gamepad Id prefix used to identify this controller.
  99118. */
  99119. static readonly GAMEPAD_ID_PREFIX: string;
  99120. private readonly _buttonIndexToObservableNameMap;
  99121. /**
  99122. * Creates a new GearVRController from a gamepad
  99123. * @param vrGamepad the gamepad that the controller should be created from
  99124. */
  99125. constructor(vrGamepad: any);
  99126. /**
  99127. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99128. * @param scene scene in which to add meshes
  99129. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99130. */
  99131. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99132. /**
  99133. * Called once for each button that changed state since the last frame
  99134. * @param buttonIdx Which button index changed
  99135. * @param state New state of the button
  99136. * @param changes Which properties on the state changed since last frame
  99137. */
  99138. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99139. }
  99140. }
  99141. declare module BABYLON {
  99142. /**
  99143. * Generic Controller
  99144. */
  99145. export class GenericController extends WebVRController {
  99146. /**
  99147. * Base Url for the controller model.
  99148. */
  99149. static readonly MODEL_BASE_URL: string;
  99150. /**
  99151. * File name for the controller model.
  99152. */
  99153. static readonly MODEL_FILENAME: string;
  99154. /**
  99155. * Creates a new GenericController from a gamepad
  99156. * @param vrGamepad the gamepad that the controller should be created from
  99157. */
  99158. constructor(vrGamepad: any);
  99159. /**
  99160. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99161. * @param scene scene in which to add meshes
  99162. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99163. */
  99164. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99165. /**
  99166. * Called once for each button that changed state since the last frame
  99167. * @param buttonIdx Which button index changed
  99168. * @param state New state of the button
  99169. * @param changes Which properties on the state changed since last frame
  99170. */
  99171. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99172. }
  99173. }
  99174. declare module BABYLON {
  99175. /**
  99176. * Oculus Touch Controller
  99177. */
  99178. export class OculusTouchController extends WebVRController {
  99179. /**
  99180. * Base Url for the controller model.
  99181. */
  99182. static MODEL_BASE_URL: string;
  99183. /**
  99184. * File name for the left controller model.
  99185. */
  99186. static MODEL_LEFT_FILENAME: string;
  99187. /**
  99188. * File name for the right controller model.
  99189. */
  99190. static MODEL_RIGHT_FILENAME: string;
  99191. /**
  99192. * Fired when the secondary trigger on this controller is modified
  99193. */
  99194. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99195. /**
  99196. * Fired when the thumb rest on this controller is modified
  99197. */
  99198. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  99199. /**
  99200. * Creates a new OculusTouchController from a gamepad
  99201. * @param vrGamepad the gamepad that the controller should be created from
  99202. */
  99203. constructor(vrGamepad: any);
  99204. /**
  99205. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99206. * @param scene scene in which to add meshes
  99207. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99208. */
  99209. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99210. /**
  99211. * Fired when the A button on this controller is modified
  99212. */
  99213. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99214. /**
  99215. * Fired when the B button on this controller is modified
  99216. */
  99217. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99218. /**
  99219. * Fired when the X button on this controller is modified
  99220. */
  99221. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99222. /**
  99223. * Fired when the Y button on this controller is modified
  99224. */
  99225. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99226. /**
  99227. * Called once for each button that changed state since the last frame
  99228. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  99229. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  99230. * 2) secondary trigger (same)
  99231. * 3) A (right) X (left), touch, pressed = value
  99232. * 4) B / Y
  99233. * 5) thumb rest
  99234. * @param buttonIdx Which button index changed
  99235. * @param state New state of the button
  99236. * @param changes Which properties on the state changed since last frame
  99237. */
  99238. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99239. }
  99240. }
  99241. declare module BABYLON {
  99242. /**
  99243. * Vive Controller
  99244. */
  99245. export class ViveController extends WebVRController {
  99246. /**
  99247. * Base Url for the controller model.
  99248. */
  99249. static MODEL_BASE_URL: string;
  99250. /**
  99251. * File name for the controller model.
  99252. */
  99253. static MODEL_FILENAME: string;
  99254. /**
  99255. * Creates a new ViveController from a gamepad
  99256. * @param vrGamepad the gamepad that the controller should be created from
  99257. */
  99258. constructor(vrGamepad: any);
  99259. /**
  99260. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99261. * @param scene scene in which to add meshes
  99262. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99263. */
  99264. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99265. /**
  99266. * Fired when the left button on this controller is modified
  99267. */
  99268. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99269. /**
  99270. * Fired when the right button on this controller is modified
  99271. */
  99272. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99273. /**
  99274. * Fired when the menu button on this controller is modified
  99275. */
  99276. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99277. /**
  99278. * Called once for each button that changed state since the last frame
  99279. * Vive mapping:
  99280. * 0: touchpad
  99281. * 1: trigger
  99282. * 2: left AND right buttons
  99283. * 3: menu button
  99284. * @param buttonIdx Which button index changed
  99285. * @param state New state of the button
  99286. * @param changes Which properties on the state changed since last frame
  99287. */
  99288. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99289. }
  99290. }
  99291. declare module BABYLON {
  99292. /**
  99293. * Defines the WindowsMotionController object that the state of the windows motion controller
  99294. */
  99295. export class WindowsMotionController extends WebVRController {
  99296. /**
  99297. * The base url used to load the left and right controller models
  99298. */
  99299. static MODEL_BASE_URL: string;
  99300. /**
  99301. * The name of the left controller model file
  99302. */
  99303. static MODEL_LEFT_FILENAME: string;
  99304. /**
  99305. * The name of the right controller model file
  99306. */
  99307. static MODEL_RIGHT_FILENAME: string;
  99308. /**
  99309. * The controller name prefix for this controller type
  99310. */
  99311. static readonly GAMEPAD_ID_PREFIX: string;
  99312. /**
  99313. * The controller id pattern for this controller type
  99314. */
  99315. private static readonly GAMEPAD_ID_PATTERN;
  99316. private _loadedMeshInfo;
  99317. private readonly _mapping;
  99318. /**
  99319. * Fired when the trackpad on this controller is clicked
  99320. */
  99321. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  99322. /**
  99323. * Fired when the trackpad on this controller is modified
  99324. */
  99325. onTrackpadValuesChangedObservable: Observable<StickValues>;
  99326. /**
  99327. * The current x and y values of this controller's trackpad
  99328. */
  99329. trackpad: StickValues;
  99330. /**
  99331. * Creates a new WindowsMotionController from a gamepad
  99332. * @param vrGamepad the gamepad that the controller should be created from
  99333. */
  99334. constructor(vrGamepad: any);
  99335. /**
  99336. * Fired when the trigger on this controller is modified
  99337. */
  99338. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99339. /**
  99340. * Fired when the menu button on this controller is modified
  99341. */
  99342. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99343. /**
  99344. * Fired when the grip button on this controller is modified
  99345. */
  99346. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99347. /**
  99348. * Fired when the thumbstick button on this controller is modified
  99349. */
  99350. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99351. /**
  99352. * Fired when the touchpad button on this controller is modified
  99353. */
  99354. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99355. /**
  99356. * Fired when the touchpad values on this controller are modified
  99357. */
  99358. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  99359. private _updateTrackpad;
  99360. /**
  99361. * Called once per frame by the engine.
  99362. */
  99363. update(): void;
  99364. /**
  99365. * Called once for each button that changed state since the last frame
  99366. * @param buttonIdx Which button index changed
  99367. * @param state New state of the button
  99368. * @param changes Which properties on the state changed since last frame
  99369. */
  99370. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99371. /**
  99372. * Moves the buttons on the controller mesh based on their current state
  99373. * @param buttonName the name of the button to move
  99374. * @param buttonValue the value of the button which determines the buttons new position
  99375. */
  99376. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  99377. /**
  99378. * Moves the axis on the controller mesh based on its current state
  99379. * @param axis the index of the axis
  99380. * @param axisValue the value of the axis which determines the meshes new position
  99381. * @hidden
  99382. */
  99383. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  99384. /**
  99385. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99386. * @param scene scene in which to add meshes
  99387. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99388. */
  99389. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  99390. /**
  99391. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  99392. * can be transformed by button presses and axes values, based on this._mapping.
  99393. *
  99394. * @param scene scene in which the meshes exist
  99395. * @param meshes list of meshes that make up the controller model to process
  99396. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  99397. */
  99398. private processModel;
  99399. private createMeshInfo;
  99400. /**
  99401. * Gets the ray of the controller in the direction the controller is pointing
  99402. * @param length the length the resulting ray should be
  99403. * @returns a ray in the direction the controller is pointing
  99404. */
  99405. getForwardRay(length?: number): Ray;
  99406. /**
  99407. * Disposes of the controller
  99408. */
  99409. dispose(): void;
  99410. }
  99411. }
  99412. declare module BABYLON {
  99413. /**
  99414. * Single axis scale gizmo
  99415. */
  99416. export class AxisScaleGizmo extends Gizmo {
  99417. private _coloredMaterial;
  99418. /**
  99419. * Drag behavior responsible for the gizmos dragging interactions
  99420. */
  99421. dragBehavior: PointerDragBehavior;
  99422. private _pointerObserver;
  99423. /**
  99424. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99425. */
  99426. snapDistance: number;
  99427. /**
  99428. * Event that fires each time the gizmo snaps to a new location.
  99429. * * snapDistance is the the change in distance
  99430. */
  99431. onSnapObservable: Observable<{
  99432. snapDistance: number;
  99433. }>;
  99434. /**
  99435. * If the scaling operation should be done on all axis (default: false)
  99436. */
  99437. uniformScaling: boolean;
  99438. /**
  99439. * Creates an AxisScaleGizmo
  99440. * @param gizmoLayer The utility layer the gizmo will be added to
  99441. * @param dragAxis The axis which the gizmo will be able to scale on
  99442. * @param color The color of the gizmo
  99443. */
  99444. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99445. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99446. /**
  99447. * Disposes of the gizmo
  99448. */
  99449. dispose(): void;
  99450. /**
  99451. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99452. * @param mesh The mesh to replace the default mesh of the gizmo
  99453. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  99454. */
  99455. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  99456. }
  99457. }
  99458. declare module BABYLON {
  99459. /**
  99460. * Bounding box gizmo
  99461. */
  99462. export class BoundingBoxGizmo extends Gizmo {
  99463. private _lineBoundingBox;
  99464. private _rotateSpheresParent;
  99465. private _scaleBoxesParent;
  99466. private _boundingDimensions;
  99467. private _renderObserver;
  99468. private _pointerObserver;
  99469. private _scaleDragSpeed;
  99470. private _tmpQuaternion;
  99471. private _tmpVector;
  99472. private _tmpRotationMatrix;
  99473. /**
  99474. * 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)
  99475. */
  99476. ignoreChildren: boolean;
  99477. /**
  99478. * 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)
  99479. */
  99480. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  99481. /**
  99482. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  99483. */
  99484. rotationSphereSize: number;
  99485. /**
  99486. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  99487. */
  99488. scaleBoxSize: number;
  99489. /**
  99490. * 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)
  99491. */
  99492. fixedDragMeshScreenSize: boolean;
  99493. /**
  99494. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  99495. */
  99496. fixedDragMeshScreenSizeDistanceFactor: number;
  99497. /**
  99498. * Fired when a rotation sphere or scale box is dragged
  99499. */
  99500. onDragStartObservable: Observable<{}>;
  99501. /**
  99502. * Fired when a scale box is dragged
  99503. */
  99504. onScaleBoxDragObservable: Observable<{}>;
  99505. /**
  99506. * Fired when a scale box drag is ended
  99507. */
  99508. onScaleBoxDragEndObservable: Observable<{}>;
  99509. /**
  99510. * Fired when a rotation sphere is dragged
  99511. */
  99512. onRotationSphereDragObservable: Observable<{}>;
  99513. /**
  99514. * Fired when a rotation sphere drag is ended
  99515. */
  99516. onRotationSphereDragEndObservable: Observable<{}>;
  99517. /**
  99518. * 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)
  99519. */
  99520. scalePivot: Nullable<Vector3>;
  99521. private _anchorMesh;
  99522. private _existingMeshScale;
  99523. private _dragMesh;
  99524. private pointerDragBehavior;
  99525. private coloredMaterial;
  99526. private hoverColoredMaterial;
  99527. /**
  99528. * Sets the color of the bounding box gizmo
  99529. * @param color the color to set
  99530. */
  99531. setColor(color: Color3): void;
  99532. /**
  99533. * Creates an BoundingBoxGizmo
  99534. * @param gizmoLayer The utility layer the gizmo will be added to
  99535. * @param color The color of the gizmo
  99536. */
  99537. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99538. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99539. private _selectNode;
  99540. /**
  99541. * Updates the bounding box information for the Gizmo
  99542. */
  99543. updateBoundingBox(): void;
  99544. private _updateRotationSpheres;
  99545. private _updateScaleBoxes;
  99546. /**
  99547. * Enables rotation on the specified axis and disables rotation on the others
  99548. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  99549. */
  99550. setEnabledRotationAxis(axis: string): void;
  99551. /**
  99552. * Enables/disables scaling
  99553. * @param enable if scaling should be enabled
  99554. */
  99555. setEnabledScaling(enable: boolean): void;
  99556. private _updateDummy;
  99557. /**
  99558. * Enables a pointer drag behavior on the bounding box of the gizmo
  99559. */
  99560. enableDragBehavior(): void;
  99561. /**
  99562. * Disposes of the gizmo
  99563. */
  99564. dispose(): void;
  99565. /**
  99566. * 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)
  99567. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  99568. * @returns the bounding box mesh with the passed in mesh as a child
  99569. */
  99570. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  99571. /**
  99572. * CustomMeshes are not supported by this gizmo
  99573. * @param mesh The mesh to replace the default mesh of the gizmo
  99574. */
  99575. setCustomMesh(mesh: Mesh): void;
  99576. }
  99577. }
  99578. declare module BABYLON {
  99579. /**
  99580. * Single plane rotation gizmo
  99581. */
  99582. export class PlaneRotationGizmo extends Gizmo {
  99583. /**
  99584. * Drag behavior responsible for the gizmos dragging interactions
  99585. */
  99586. dragBehavior: PointerDragBehavior;
  99587. private _pointerObserver;
  99588. /**
  99589. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  99590. */
  99591. snapDistance: number;
  99592. /**
  99593. * Event that fires each time the gizmo snaps to a new location.
  99594. * * snapDistance is the the change in distance
  99595. */
  99596. onSnapObservable: Observable<{
  99597. snapDistance: number;
  99598. }>;
  99599. /**
  99600. * Creates a PlaneRotationGizmo
  99601. * @param gizmoLayer The utility layer the gizmo will be added to
  99602. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99603. * @param color The color of the gizmo
  99604. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99605. */
  99606. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99607. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99608. /**
  99609. * Disposes of the gizmo
  99610. */
  99611. dispose(): void;
  99612. }
  99613. }
  99614. declare module BABYLON {
  99615. /**
  99616. * Gizmo that enables rotating a mesh along 3 axis
  99617. */
  99618. export class RotationGizmo extends Gizmo {
  99619. /**
  99620. * Internal gizmo used for interactions on the x axis
  99621. */
  99622. xGizmo: PlaneRotationGizmo;
  99623. /**
  99624. * Internal gizmo used for interactions on the y axis
  99625. */
  99626. yGizmo: PlaneRotationGizmo;
  99627. /**
  99628. * Internal gizmo used for interactions on the z axis
  99629. */
  99630. zGizmo: PlaneRotationGizmo;
  99631. /** Fires an event when any of it's sub gizmos are dragged */
  99632. onDragStartObservable: Observable<{}>;
  99633. /** Fires an event when any of it's sub gizmos are released from dragging */
  99634. onDragEndObservable: Observable<{}>;
  99635. attachedMesh: Nullable<AbstractMesh>;
  99636. /**
  99637. * Creates a RotationGizmo
  99638. * @param gizmoLayer The utility layer the gizmo will be added to
  99639. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99640. */
  99641. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99642. updateGizmoRotationToMatchAttachedMesh: boolean;
  99643. /**
  99644. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99645. */
  99646. snapDistance: number;
  99647. /**
  99648. * Ratio for the scale of the gizmo (Default: 1)
  99649. */
  99650. scaleRatio: number;
  99651. /**
  99652. * Disposes of the gizmo
  99653. */
  99654. dispose(): void;
  99655. /**
  99656. * CustomMeshes are not supported by this gizmo
  99657. * @param mesh The mesh to replace the default mesh of the gizmo
  99658. */
  99659. setCustomMesh(mesh: Mesh): void;
  99660. }
  99661. }
  99662. declare module BABYLON {
  99663. /**
  99664. * Gizmo that enables dragging a mesh along 3 axis
  99665. */
  99666. export class PositionGizmo extends Gizmo {
  99667. /**
  99668. * Internal gizmo used for interactions on the x axis
  99669. */
  99670. xGizmo: AxisDragGizmo;
  99671. /**
  99672. * Internal gizmo used for interactions on the y axis
  99673. */
  99674. yGizmo: AxisDragGizmo;
  99675. /**
  99676. * Internal gizmo used for interactions on the z axis
  99677. */
  99678. zGizmo: AxisDragGizmo;
  99679. /** Fires an event when any of it's sub gizmos are dragged */
  99680. onDragStartObservable: Observable<{}>;
  99681. /** Fires an event when any of it's sub gizmos are released from dragging */
  99682. onDragEndObservable: Observable<{}>;
  99683. attachedMesh: Nullable<AbstractMesh>;
  99684. /**
  99685. * Creates a PositionGizmo
  99686. * @param gizmoLayer The utility layer the gizmo will be added to
  99687. */
  99688. constructor(gizmoLayer?: UtilityLayerRenderer);
  99689. updateGizmoRotationToMatchAttachedMesh: boolean;
  99690. /**
  99691. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99692. */
  99693. snapDistance: number;
  99694. /**
  99695. * Ratio for the scale of the gizmo (Default: 1)
  99696. */
  99697. scaleRatio: number;
  99698. /**
  99699. * Disposes of the gizmo
  99700. */
  99701. dispose(): void;
  99702. /**
  99703. * CustomMeshes are not supported by this gizmo
  99704. * @param mesh The mesh to replace the default mesh of the gizmo
  99705. */
  99706. setCustomMesh(mesh: Mesh): void;
  99707. }
  99708. }
  99709. declare module BABYLON {
  99710. /**
  99711. * Class containing static functions to help procedurally build meshes
  99712. */
  99713. export class PolyhedronBuilder {
  99714. /**
  99715. * Creates a polyhedron mesh
  99716. * * 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
  99717. * * The parameter `size` (positive float, default 1) sets the polygon size
  99718. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99719. * * 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`
  99720. * * 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
  99721. * * 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)`)
  99722. * * 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
  99723. * * 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
  99724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99727. * @param name defines the name of the mesh
  99728. * @param options defines the options used to create the mesh
  99729. * @param scene defines the hosting scene
  99730. * @returns the polyhedron mesh
  99731. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99732. */
  99733. static CreatePolyhedron(name: string, options: {
  99734. type?: number;
  99735. size?: number;
  99736. sizeX?: number;
  99737. sizeY?: number;
  99738. sizeZ?: number;
  99739. custom?: any;
  99740. faceUV?: Vector4[];
  99741. faceColors?: Color4[];
  99742. flat?: boolean;
  99743. updatable?: boolean;
  99744. sideOrientation?: number;
  99745. frontUVs?: Vector4;
  99746. backUVs?: Vector4;
  99747. }, scene: Scene): Mesh;
  99748. }
  99749. }
  99750. declare module BABYLON {
  99751. /**
  99752. * Gizmo that enables scaling a mesh along 3 axis
  99753. */
  99754. export class ScaleGizmo extends Gizmo {
  99755. /**
  99756. * Internal gizmo used for interactions on the x axis
  99757. */
  99758. xGizmo: AxisScaleGizmo;
  99759. /**
  99760. * Internal gizmo used for interactions on the y axis
  99761. */
  99762. yGizmo: AxisScaleGizmo;
  99763. /**
  99764. * Internal gizmo used for interactions on the z axis
  99765. */
  99766. zGizmo: AxisScaleGizmo;
  99767. /**
  99768. * Internal gizmo used to scale all axis equally
  99769. */
  99770. uniformScaleGizmo: AxisScaleGizmo;
  99771. /** Fires an event when any of it's sub gizmos are dragged */
  99772. onDragStartObservable: Observable<{}>;
  99773. /** Fires an event when any of it's sub gizmos are released from dragging */
  99774. onDragEndObservable: Observable<{}>;
  99775. attachedMesh: Nullable<AbstractMesh>;
  99776. /**
  99777. * Creates a ScaleGizmo
  99778. * @param gizmoLayer The utility layer the gizmo will be added to
  99779. */
  99780. constructor(gizmoLayer?: UtilityLayerRenderer);
  99781. updateGizmoRotationToMatchAttachedMesh: boolean;
  99782. /**
  99783. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99784. */
  99785. snapDistance: number;
  99786. /**
  99787. * Ratio for the scale of the gizmo (Default: 1)
  99788. */
  99789. scaleRatio: number;
  99790. /**
  99791. * Disposes of the gizmo
  99792. */
  99793. dispose(): void;
  99794. }
  99795. }
  99796. declare module BABYLON {
  99797. /**
  99798. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99799. */
  99800. export class GizmoManager implements IDisposable {
  99801. private scene;
  99802. /**
  99803. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99804. */
  99805. gizmos: {
  99806. positionGizmo: Nullable<PositionGizmo>;
  99807. rotationGizmo: Nullable<RotationGizmo>;
  99808. scaleGizmo: Nullable<ScaleGizmo>;
  99809. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99810. };
  99811. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99812. clearGizmoOnEmptyPointerEvent: boolean;
  99813. /** Fires an event when the manager is attached to a mesh */
  99814. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99815. private _gizmosEnabled;
  99816. private _pointerObserver;
  99817. private _attachedMesh;
  99818. private _boundingBoxColor;
  99819. private _defaultUtilityLayer;
  99820. private _defaultKeepDepthUtilityLayer;
  99821. /**
  99822. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99823. */
  99824. boundingBoxDragBehavior: SixDofDragBehavior;
  99825. /**
  99826. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99827. */
  99828. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99829. /**
  99830. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99831. */
  99832. usePointerToAttachGizmos: boolean;
  99833. /**
  99834. * Instatiates a gizmo manager
  99835. * @param scene the scene to overlay the gizmos on top of
  99836. */
  99837. constructor(scene: Scene);
  99838. /**
  99839. * Attaches a set of gizmos to the specified mesh
  99840. * @param mesh The mesh the gizmo's should be attached to
  99841. */
  99842. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99843. /**
  99844. * If the position gizmo is enabled
  99845. */
  99846. positionGizmoEnabled: boolean;
  99847. /**
  99848. * If the rotation gizmo is enabled
  99849. */
  99850. rotationGizmoEnabled: boolean;
  99851. /**
  99852. * If the scale gizmo is enabled
  99853. */
  99854. scaleGizmoEnabled: boolean;
  99855. /**
  99856. * If the boundingBox gizmo is enabled
  99857. */
  99858. boundingBoxGizmoEnabled: boolean;
  99859. /**
  99860. * Disposes of the gizmo manager
  99861. */
  99862. dispose(): void;
  99863. }
  99864. }
  99865. declare module BABYLON {
  99866. /**
  99867. * Gizmo that enables viewing a light
  99868. */
  99869. export class LightGizmo extends Gizmo {
  99870. private _box;
  99871. /**
  99872. * Creates a LightGizmo
  99873. * @param gizmoLayer The utility layer the gizmo will be added to
  99874. */
  99875. constructor(gizmoLayer?: UtilityLayerRenderer);
  99876. private _light;
  99877. /**
  99878. * The light that the gizmo is attached to
  99879. */
  99880. light: Nullable<Light>;
  99881. /**
  99882. * @hidden
  99883. * Updates the gizmo to match the attached mesh's position/rotation
  99884. */
  99885. protected _update(): void;
  99886. }
  99887. }
  99888. declare module BABYLON {
  99889. /** @hidden */
  99890. export var backgroundFragmentDeclaration: {
  99891. name: string;
  99892. shader: string;
  99893. };
  99894. }
  99895. declare module BABYLON {
  99896. /** @hidden */
  99897. export var backgroundUboDeclaration: {
  99898. name: string;
  99899. shader: string;
  99900. };
  99901. }
  99902. declare module BABYLON {
  99903. /** @hidden */
  99904. export var backgroundPixelShader: {
  99905. name: string;
  99906. shader: string;
  99907. };
  99908. }
  99909. declare module BABYLON {
  99910. /** @hidden */
  99911. export var backgroundVertexDeclaration: {
  99912. name: string;
  99913. shader: string;
  99914. };
  99915. }
  99916. declare module BABYLON {
  99917. /** @hidden */
  99918. export var backgroundVertexShader: {
  99919. name: string;
  99920. shader: string;
  99921. };
  99922. }
  99923. declare module BABYLON {
  99924. /**
  99925. * Background material used to create an efficient environement around your scene.
  99926. */
  99927. export class BackgroundMaterial extends PushMaterial {
  99928. /**
  99929. * Standard reflectance value at parallel view angle.
  99930. */
  99931. static StandardReflectance0: number;
  99932. /**
  99933. * Standard reflectance value at grazing angle.
  99934. */
  99935. static StandardReflectance90: number;
  99936. protected _primaryColor: Color3;
  99937. /**
  99938. * Key light Color (multiply against the environement texture)
  99939. */
  99940. primaryColor: Color3;
  99941. protected __perceptualColor: Nullable<Color3>;
  99942. /**
  99943. * Experimental Internal Use Only.
  99944. *
  99945. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99946. * This acts as a helper to set the primary color to a more "human friendly" value.
  99947. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99948. * output color as close as possible from the chosen value.
  99949. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99950. * part of lighting setup.)
  99951. */
  99952. _perceptualColor: Nullable<Color3>;
  99953. protected _primaryColorShadowLevel: float;
  99954. /**
  99955. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99956. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99957. */
  99958. primaryColorShadowLevel: float;
  99959. protected _primaryColorHighlightLevel: float;
  99960. /**
  99961. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99962. * The primary color is used at the level chosen to define what the white area would look.
  99963. */
  99964. primaryColorHighlightLevel: float;
  99965. protected _reflectionTexture: Nullable<BaseTexture>;
  99966. /**
  99967. * Reflection Texture used in the material.
  99968. * Should be author in a specific way for the best result (refer to the documentation).
  99969. */
  99970. reflectionTexture: Nullable<BaseTexture>;
  99971. protected _reflectionBlur: float;
  99972. /**
  99973. * Reflection Texture level of blur.
  99974. *
  99975. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99976. * texture twice.
  99977. */
  99978. reflectionBlur: float;
  99979. protected _diffuseTexture: Nullable<BaseTexture>;
  99980. /**
  99981. * Diffuse Texture used in the material.
  99982. * Should be author in a specific way for the best result (refer to the documentation).
  99983. */
  99984. diffuseTexture: Nullable<BaseTexture>;
  99985. protected _shadowLights: Nullable<IShadowLight[]>;
  99986. /**
  99987. * Specify the list of lights casting shadow on the material.
  99988. * All scene shadow lights will be included if null.
  99989. */
  99990. shadowLights: Nullable<IShadowLight[]>;
  99991. protected _shadowLevel: float;
  99992. /**
  99993. * Helps adjusting the shadow to a softer level if required.
  99994. * 0 means black shadows and 1 means no shadows.
  99995. */
  99996. shadowLevel: float;
  99997. protected _sceneCenter: Vector3;
  99998. /**
  99999. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  100000. * It is usually zero but might be interesting to modify according to your setup.
  100001. */
  100002. sceneCenter: Vector3;
  100003. protected _opacityFresnel: boolean;
  100004. /**
  100005. * This helps specifying that the material is falling off to the sky box at grazing angle.
  100006. * This helps ensuring a nice transition when the camera goes under the ground.
  100007. */
  100008. opacityFresnel: boolean;
  100009. protected _reflectionFresnel: boolean;
  100010. /**
  100011. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  100012. * This helps adding a mirror texture on the ground.
  100013. */
  100014. reflectionFresnel: boolean;
  100015. protected _reflectionFalloffDistance: number;
  100016. /**
  100017. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  100018. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  100019. */
  100020. reflectionFalloffDistance: number;
  100021. protected _reflectionAmount: number;
  100022. /**
  100023. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  100024. */
  100025. reflectionAmount: number;
  100026. protected _reflectionReflectance0: number;
  100027. /**
  100028. * This specifies the weight of the reflection at grazing angle.
  100029. */
  100030. reflectionReflectance0: number;
  100031. protected _reflectionReflectance90: number;
  100032. /**
  100033. * This specifies the weight of the reflection at a perpendicular point of view.
  100034. */
  100035. reflectionReflectance90: number;
  100036. /**
  100037. * Sets the reflection reflectance fresnel values according to the default standard
  100038. * empirically know to work well :-)
  100039. */
  100040. reflectionStandardFresnelWeight: number;
  100041. protected _useRGBColor: boolean;
  100042. /**
  100043. * Helps to directly use the maps channels instead of their level.
  100044. */
  100045. useRGBColor: boolean;
  100046. protected _enableNoise: boolean;
  100047. /**
  100048. * This helps reducing the banding effect that could occur on the background.
  100049. */
  100050. enableNoise: boolean;
  100051. /**
  100052. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100053. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  100054. * Recommended to be keep at 1.0 except for special cases.
  100055. */
  100056. fovMultiplier: number;
  100057. private _fovMultiplier;
  100058. /**
  100059. * Enable the FOV adjustment feature controlled by fovMultiplier.
  100060. */
  100061. useEquirectangularFOV: boolean;
  100062. private _maxSimultaneousLights;
  100063. /**
  100064. * Number of Simultaneous lights allowed on the material.
  100065. */
  100066. maxSimultaneousLights: int;
  100067. /**
  100068. * Default configuration related to image processing available in the Background Material.
  100069. */
  100070. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100071. /**
  100072. * Keep track of the image processing observer to allow dispose and replace.
  100073. */
  100074. private _imageProcessingObserver;
  100075. /**
  100076. * Attaches a new image processing configuration to the PBR Material.
  100077. * @param configuration (if null the scene configuration will be use)
  100078. */
  100079. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100080. /**
  100081. * Gets the image processing configuration used either in this material.
  100082. */
  100083. /**
  100084. * Sets the Default image processing configuration used either in the this material.
  100085. *
  100086. * If sets to null, the scene one is in use.
  100087. */
  100088. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  100089. /**
  100090. * Gets wether the color curves effect is enabled.
  100091. */
  100092. /**
  100093. * Sets wether the color curves effect is enabled.
  100094. */
  100095. cameraColorCurvesEnabled: boolean;
  100096. /**
  100097. * Gets wether the color grading effect is enabled.
  100098. */
  100099. /**
  100100. * Gets wether the color grading effect is enabled.
  100101. */
  100102. cameraColorGradingEnabled: boolean;
  100103. /**
  100104. * Gets wether tonemapping is enabled or not.
  100105. */
  100106. /**
  100107. * Sets wether tonemapping is enabled or not
  100108. */
  100109. cameraToneMappingEnabled: boolean;
  100110. /**
  100111. * The camera exposure used on this material.
  100112. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100113. * This corresponds to a photographic exposure.
  100114. */
  100115. /**
  100116. * The camera exposure used on this material.
  100117. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100118. * This corresponds to a photographic exposure.
  100119. */
  100120. cameraExposure: float;
  100121. /**
  100122. * Gets The camera contrast used on this material.
  100123. */
  100124. /**
  100125. * Sets The camera contrast used on this material.
  100126. */
  100127. cameraContrast: float;
  100128. /**
  100129. * Gets the Color Grading 2D Lookup Texture.
  100130. */
  100131. /**
  100132. * Sets the Color Grading 2D Lookup Texture.
  100133. */
  100134. cameraColorGradingTexture: Nullable<BaseTexture>;
  100135. /**
  100136. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100137. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100138. * 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;
  100139. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100140. */
  100141. /**
  100142. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100143. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100144. * 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;
  100145. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100146. */
  100147. cameraColorCurves: Nullable<ColorCurves>;
  100148. /**
  100149. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  100150. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  100151. */
  100152. switchToBGR: boolean;
  100153. private _renderTargets;
  100154. private _reflectionControls;
  100155. private _white;
  100156. private _primaryShadowColor;
  100157. private _primaryHighlightColor;
  100158. /**
  100159. * Instantiates a Background Material in the given scene
  100160. * @param name The friendly name of the material
  100161. * @param scene The scene to add the material to
  100162. */
  100163. constructor(name: string, scene: Scene);
  100164. /**
  100165. * Gets a boolean indicating that current material needs to register RTT
  100166. */
  100167. readonly hasRenderTargetTextures: boolean;
  100168. /**
  100169. * The entire material has been created in order to prevent overdraw.
  100170. * @returns false
  100171. */
  100172. needAlphaTesting(): boolean;
  100173. /**
  100174. * The entire material has been created in order to prevent overdraw.
  100175. * @returns true if blending is enable
  100176. */
  100177. needAlphaBlending(): boolean;
  100178. /**
  100179. * Checks wether the material is ready to be rendered for a given mesh.
  100180. * @param mesh The mesh to render
  100181. * @param subMesh The submesh to check against
  100182. * @param useInstances Specify wether or not the material is used with instances
  100183. * @returns true if all the dependencies are ready (Textures, Effects...)
  100184. */
  100185. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100186. /**
  100187. * Compute the primary color according to the chosen perceptual color.
  100188. */
  100189. private _computePrimaryColorFromPerceptualColor;
  100190. /**
  100191. * Compute the highlights and shadow colors according to their chosen levels.
  100192. */
  100193. private _computePrimaryColors;
  100194. /**
  100195. * Build the uniform buffer used in the material.
  100196. */
  100197. buildUniformLayout(): void;
  100198. /**
  100199. * Unbind the material.
  100200. */
  100201. unbind(): void;
  100202. /**
  100203. * Bind only the world matrix to the material.
  100204. * @param world The world matrix to bind.
  100205. */
  100206. bindOnlyWorldMatrix(world: Matrix): void;
  100207. /**
  100208. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  100209. * @param world The world matrix to bind.
  100210. * @param subMesh The submesh to bind for.
  100211. */
  100212. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100213. /**
  100214. * Dispose the material.
  100215. * @param forceDisposeEffect Force disposal of the associated effect.
  100216. * @param forceDisposeTextures Force disposal of the associated textures.
  100217. */
  100218. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100219. /**
  100220. * Clones the material.
  100221. * @param name The cloned name.
  100222. * @returns The cloned material.
  100223. */
  100224. clone(name: string): BackgroundMaterial;
  100225. /**
  100226. * Serializes the current material to its JSON representation.
  100227. * @returns The JSON representation.
  100228. */
  100229. serialize(): any;
  100230. /**
  100231. * Gets the class name of the material
  100232. * @returns "BackgroundMaterial"
  100233. */
  100234. getClassName(): string;
  100235. /**
  100236. * Parse a JSON input to create back a background material.
  100237. * @param source The JSON data to parse
  100238. * @param scene The scene to create the parsed material in
  100239. * @param rootUrl The root url of the assets the material depends upon
  100240. * @returns the instantiated BackgroundMaterial.
  100241. */
  100242. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  100243. }
  100244. }
  100245. declare module BABYLON {
  100246. /**
  100247. * Represents the different options available during the creation of
  100248. * a Environment helper.
  100249. *
  100250. * This can control the default ground, skybox and image processing setup of your scene.
  100251. */
  100252. export interface IEnvironmentHelperOptions {
  100253. /**
  100254. * Specifies wether or not to create a ground.
  100255. * True by default.
  100256. */
  100257. createGround: boolean;
  100258. /**
  100259. * Specifies the ground size.
  100260. * 15 by default.
  100261. */
  100262. groundSize: number;
  100263. /**
  100264. * The texture used on the ground for the main color.
  100265. * Comes from the BabylonJS CDN by default.
  100266. *
  100267. * Remarks: Can be either a texture or a url.
  100268. */
  100269. groundTexture: string | BaseTexture;
  100270. /**
  100271. * The color mixed in the ground texture by default.
  100272. * BabylonJS clearColor by default.
  100273. */
  100274. groundColor: Color3;
  100275. /**
  100276. * Specifies the ground opacity.
  100277. * 1 by default.
  100278. */
  100279. groundOpacity: number;
  100280. /**
  100281. * Enables the ground to receive shadows.
  100282. * True by default.
  100283. */
  100284. enableGroundShadow: boolean;
  100285. /**
  100286. * Helps preventing the shadow to be fully black on the ground.
  100287. * 0.5 by default.
  100288. */
  100289. groundShadowLevel: number;
  100290. /**
  100291. * Creates a mirror texture attach to the ground.
  100292. * false by default.
  100293. */
  100294. enableGroundMirror: boolean;
  100295. /**
  100296. * Specifies the ground mirror size ratio.
  100297. * 0.3 by default as the default kernel is 64.
  100298. */
  100299. groundMirrorSizeRatio: number;
  100300. /**
  100301. * Specifies the ground mirror blur kernel size.
  100302. * 64 by default.
  100303. */
  100304. groundMirrorBlurKernel: number;
  100305. /**
  100306. * Specifies the ground mirror visibility amount.
  100307. * 1 by default
  100308. */
  100309. groundMirrorAmount: number;
  100310. /**
  100311. * Specifies the ground mirror reflectance weight.
  100312. * This uses the standard weight of the background material to setup the fresnel effect
  100313. * of the mirror.
  100314. * 1 by default.
  100315. */
  100316. groundMirrorFresnelWeight: number;
  100317. /**
  100318. * Specifies the ground mirror Falloff distance.
  100319. * This can helps reducing the size of the reflection.
  100320. * 0 by Default.
  100321. */
  100322. groundMirrorFallOffDistance: number;
  100323. /**
  100324. * Specifies the ground mirror texture type.
  100325. * Unsigned Int by Default.
  100326. */
  100327. groundMirrorTextureType: number;
  100328. /**
  100329. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  100330. * the shown objects.
  100331. */
  100332. groundYBias: number;
  100333. /**
  100334. * Specifies wether or not to create a skybox.
  100335. * True by default.
  100336. */
  100337. createSkybox: boolean;
  100338. /**
  100339. * Specifies the skybox size.
  100340. * 20 by default.
  100341. */
  100342. skyboxSize: number;
  100343. /**
  100344. * The texture used on the skybox for the main color.
  100345. * Comes from the BabylonJS CDN by default.
  100346. *
  100347. * Remarks: Can be either a texture or a url.
  100348. */
  100349. skyboxTexture: string | BaseTexture;
  100350. /**
  100351. * The color mixed in the skybox texture by default.
  100352. * BabylonJS clearColor by default.
  100353. */
  100354. skyboxColor: Color3;
  100355. /**
  100356. * The background rotation around the Y axis of the scene.
  100357. * This helps aligning the key lights of your scene with the background.
  100358. * 0 by default.
  100359. */
  100360. backgroundYRotation: number;
  100361. /**
  100362. * Compute automatically the size of the elements to best fit with the scene.
  100363. */
  100364. sizeAuto: boolean;
  100365. /**
  100366. * Default position of the rootMesh if autoSize is not true.
  100367. */
  100368. rootPosition: Vector3;
  100369. /**
  100370. * Sets up the image processing in the scene.
  100371. * true by default.
  100372. */
  100373. setupImageProcessing: boolean;
  100374. /**
  100375. * The texture used as your environment texture in the scene.
  100376. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  100377. *
  100378. * Remarks: Can be either a texture or a url.
  100379. */
  100380. environmentTexture: string | BaseTexture;
  100381. /**
  100382. * The value of the exposure to apply to the scene.
  100383. * 0.6 by default if setupImageProcessing is true.
  100384. */
  100385. cameraExposure: number;
  100386. /**
  100387. * The value of the contrast to apply to the scene.
  100388. * 1.6 by default if setupImageProcessing is true.
  100389. */
  100390. cameraContrast: number;
  100391. /**
  100392. * Specifies wether or not tonemapping should be enabled in the scene.
  100393. * true by default if setupImageProcessing is true.
  100394. */
  100395. toneMappingEnabled: boolean;
  100396. }
  100397. /**
  100398. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  100399. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  100400. * It also helps with the default setup of your imageProcessing configuration.
  100401. */
  100402. export class EnvironmentHelper {
  100403. /**
  100404. * Default ground texture URL.
  100405. */
  100406. private static _groundTextureCDNUrl;
  100407. /**
  100408. * Default skybox texture URL.
  100409. */
  100410. private static _skyboxTextureCDNUrl;
  100411. /**
  100412. * Default environment texture URL.
  100413. */
  100414. private static _environmentTextureCDNUrl;
  100415. /**
  100416. * Creates the default options for the helper.
  100417. */
  100418. private static _getDefaultOptions;
  100419. private _rootMesh;
  100420. /**
  100421. * Gets the root mesh created by the helper.
  100422. */
  100423. readonly rootMesh: Mesh;
  100424. private _skybox;
  100425. /**
  100426. * Gets the skybox created by the helper.
  100427. */
  100428. readonly skybox: Nullable<Mesh>;
  100429. private _skyboxTexture;
  100430. /**
  100431. * Gets the skybox texture created by the helper.
  100432. */
  100433. readonly skyboxTexture: Nullable<BaseTexture>;
  100434. private _skyboxMaterial;
  100435. /**
  100436. * Gets the skybox material created by the helper.
  100437. */
  100438. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  100439. private _ground;
  100440. /**
  100441. * Gets the ground mesh created by the helper.
  100442. */
  100443. readonly ground: Nullable<Mesh>;
  100444. private _groundTexture;
  100445. /**
  100446. * Gets the ground texture created by the helper.
  100447. */
  100448. readonly groundTexture: Nullable<BaseTexture>;
  100449. private _groundMirror;
  100450. /**
  100451. * Gets the ground mirror created by the helper.
  100452. */
  100453. readonly groundMirror: Nullable<MirrorTexture>;
  100454. /**
  100455. * Gets the ground mirror render list to helps pushing the meshes
  100456. * you wish in the ground reflection.
  100457. */
  100458. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  100459. private _groundMaterial;
  100460. /**
  100461. * Gets the ground material created by the helper.
  100462. */
  100463. readonly groundMaterial: Nullable<BackgroundMaterial>;
  100464. /**
  100465. * Stores the creation options.
  100466. */
  100467. private readonly _scene;
  100468. private _options;
  100469. /**
  100470. * This observable will be notified with any error during the creation of the environment,
  100471. * mainly texture creation errors.
  100472. */
  100473. onErrorObservable: Observable<{
  100474. message?: string;
  100475. exception?: any;
  100476. }>;
  100477. /**
  100478. * constructor
  100479. * @param options Defines the options we want to customize the helper
  100480. * @param scene The scene to add the material to
  100481. */
  100482. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  100483. /**
  100484. * Updates the background according to the new options
  100485. * @param options
  100486. */
  100487. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  100488. /**
  100489. * Sets the primary color of all the available elements.
  100490. * @param color the main color to affect to the ground and the background
  100491. */
  100492. setMainColor(color: Color3): void;
  100493. /**
  100494. * Setup the image processing according to the specified options.
  100495. */
  100496. private _setupImageProcessing;
  100497. /**
  100498. * Setup the environment texture according to the specified options.
  100499. */
  100500. private _setupEnvironmentTexture;
  100501. /**
  100502. * Setup the background according to the specified options.
  100503. */
  100504. private _setupBackground;
  100505. /**
  100506. * Get the scene sizes according to the setup.
  100507. */
  100508. private _getSceneSize;
  100509. /**
  100510. * Setup the ground according to the specified options.
  100511. */
  100512. private _setupGround;
  100513. /**
  100514. * Setup the ground material according to the specified options.
  100515. */
  100516. private _setupGroundMaterial;
  100517. /**
  100518. * Setup the ground diffuse texture according to the specified options.
  100519. */
  100520. private _setupGroundDiffuseTexture;
  100521. /**
  100522. * Setup the ground mirror texture according to the specified options.
  100523. */
  100524. private _setupGroundMirrorTexture;
  100525. /**
  100526. * Setup the ground to receive the mirror texture.
  100527. */
  100528. private _setupMirrorInGroundMaterial;
  100529. /**
  100530. * Setup the skybox according to the specified options.
  100531. */
  100532. private _setupSkybox;
  100533. /**
  100534. * Setup the skybox material according to the specified options.
  100535. */
  100536. private _setupSkyboxMaterial;
  100537. /**
  100538. * Setup the skybox reflection texture according to the specified options.
  100539. */
  100540. private _setupSkyboxReflectionTexture;
  100541. private _errorHandler;
  100542. /**
  100543. * Dispose all the elements created by the Helper.
  100544. */
  100545. dispose(): void;
  100546. }
  100547. }
  100548. declare module BABYLON {
  100549. /**
  100550. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  100551. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  100552. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  100553. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100554. */
  100555. export class PhotoDome extends TransformNode {
  100556. private _useDirectMapping;
  100557. /**
  100558. * The texture being displayed on the sphere
  100559. */
  100560. protected _photoTexture: Texture;
  100561. /**
  100562. * Gets or sets the texture being displayed on the sphere
  100563. */
  100564. photoTexture: Texture;
  100565. /**
  100566. * Observable raised when an error occured while loading the 360 image
  100567. */
  100568. onLoadErrorObservable: Observable<string>;
  100569. /**
  100570. * The skybox material
  100571. */
  100572. protected _material: BackgroundMaterial;
  100573. /**
  100574. * The surface used for the skybox
  100575. */
  100576. protected _mesh: Mesh;
  100577. /**
  100578. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100579. * Also see the options.resolution property.
  100580. */
  100581. fovMultiplier: number;
  100582. /**
  100583. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  100584. * @param name Element's name, child elements will append suffixes for their own names.
  100585. * @param urlsOfPhoto defines the url of the photo to display
  100586. * @param options defines an object containing optional or exposed sub element properties
  100587. * @param onError defines a callback called when an error occured while loading the texture
  100588. */
  100589. constructor(name: string, urlOfPhoto: string, options: {
  100590. resolution?: number;
  100591. size?: number;
  100592. useDirectMapping?: boolean;
  100593. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  100594. /**
  100595. * Releases resources associated with this node.
  100596. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100597. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100598. */
  100599. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100600. }
  100601. }
  100602. declare module BABYLON {
  100603. /**
  100604. * Class used to host texture specific utilities
  100605. */
  100606. export class TextureTools {
  100607. /**
  100608. * Uses the GPU to create a copy texture rescaled at a given size
  100609. * @param texture Texture to copy from
  100610. * @param width defines the desired width
  100611. * @param height defines the desired height
  100612. * @param useBilinearMode defines if bilinear mode has to be used
  100613. * @return the generated texture
  100614. */
  100615. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100616. /**
  100617. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100618. * @param scene defines the hosting scene
  100619. * @returns the environment BRDF texture
  100620. */
  100621. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100622. private static _environmentBRDFBase64Texture;
  100623. }
  100624. }
  100625. declare module BABYLON {
  100626. /**
  100627. * @hidden
  100628. */
  100629. export interface IMaterialClearCoatDefines {
  100630. CLEARCOAT: boolean;
  100631. CLEARCOAT_DEFAULTIOR: boolean;
  100632. CLEARCOAT_TEXTURE: boolean;
  100633. CLEARCOAT_TEXTUREDIRECTUV: number;
  100634. CLEARCOAT_BUMP: boolean;
  100635. CLEARCOAT_BUMPDIRECTUV: number;
  100636. CLEARCOAT_TINT: boolean;
  100637. CLEARCOAT_TINT_TEXTURE: boolean;
  100638. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100639. /** @hidden */
  100640. _areTexturesDirty: boolean;
  100641. }
  100642. /**
  100643. * Define the code related to the clear coat parameters of the pbr material.
  100644. */
  100645. export class PBRClearCoatConfiguration {
  100646. /**
  100647. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100648. * The default fits with a polyurethane material.
  100649. */
  100650. private static readonly _DefaultIndiceOfRefraction;
  100651. private _isEnabled;
  100652. /**
  100653. * Defines if the clear coat is enabled in the material.
  100654. */
  100655. isEnabled: boolean;
  100656. /**
  100657. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100658. */
  100659. intensity: number;
  100660. /**
  100661. * Defines the clear coat layer roughness.
  100662. */
  100663. roughness: number;
  100664. private _indiceOfRefraction;
  100665. /**
  100666. * Defines the indice of refraction of the clear coat.
  100667. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100668. * The default fits with a polyurethane material.
  100669. * Changing the default value is more performance intensive.
  100670. */
  100671. indiceOfRefraction: number;
  100672. private _texture;
  100673. /**
  100674. * Stores the clear coat values in a texture.
  100675. */
  100676. texture: Nullable<BaseTexture>;
  100677. private _bumpTexture;
  100678. /**
  100679. * Define the clear coat specific bump texture.
  100680. */
  100681. bumpTexture: Nullable<BaseTexture>;
  100682. private _isTintEnabled;
  100683. /**
  100684. * Defines if the clear coat tint is enabled in the material.
  100685. */
  100686. isTintEnabled: boolean;
  100687. /**
  100688. * Defines if the clear coat tint is enabled in the material.
  100689. * This is only use if tint is enabled
  100690. */
  100691. tintColor: Color3;
  100692. /**
  100693. * Defines if the distance at which the tint color should be found in the
  100694. * clear coat media.
  100695. * This is only use if tint is enabled
  100696. */
  100697. tintColorAtDistance: number;
  100698. /**
  100699. * Defines the clear coat layer thickness.
  100700. * This is only use if tint is enabled
  100701. */
  100702. tintThickness: number;
  100703. private _tintTexture;
  100704. /**
  100705. * Stores the clear tint values in a texture.
  100706. * rgb is tint
  100707. * a is a thickness factor
  100708. */
  100709. tintTexture: Nullable<BaseTexture>;
  100710. /** @hidden */
  100711. private _internalMarkAllSubMeshesAsTexturesDirty;
  100712. /** @hidden */
  100713. _markAllSubMeshesAsTexturesDirty(): void;
  100714. /**
  100715. * Instantiate a new istance of clear coat configuration.
  100716. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100717. */
  100718. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100719. /**
  100720. * Specifies that the submesh is ready to be used.
  100721. * @param defines the list of "defines" to update.
  100722. * @param scene defines the scene the material belongs to.
  100723. * @param engine defines the engine the material belongs to.
  100724. * @param disableBumpMap defines wether the material disables bump or not.
  100725. * @returns - boolean indicating that the submesh is ready or not.
  100726. */
  100727. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100728. /**
  100729. * Checks to see if a texture is used in the material.
  100730. * @param defines the list of "defines" to update.
  100731. * @param scene defines the scene to the material belongs to.
  100732. */
  100733. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100734. /**
  100735. * Binds the material data.
  100736. * @param uniformBuffer defines the Uniform buffer to fill in.
  100737. * @param scene defines the scene the material belongs to.
  100738. * @param engine defines the engine the material belongs to.
  100739. * @param disableBumpMap defines wether the material disables bump or not.
  100740. * @param isFrozen defines wether the material is frozen or not.
  100741. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100742. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100743. */
  100744. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100745. /**
  100746. * Checks to see if a texture is used in the material.
  100747. * @param texture - Base texture to use.
  100748. * @returns - Boolean specifying if a texture is used in the material.
  100749. */
  100750. hasTexture(texture: BaseTexture): boolean;
  100751. /**
  100752. * Returns an array of the actively used textures.
  100753. * @param activeTextures Array of BaseTextures
  100754. */
  100755. getActiveTextures(activeTextures: BaseTexture[]): void;
  100756. /**
  100757. * Returns the animatable textures.
  100758. * @param animatables Array of animatable textures.
  100759. */
  100760. getAnimatables(animatables: IAnimatable[]): void;
  100761. /**
  100762. * Disposes the resources of the material.
  100763. * @param forceDisposeTextures - Forces the disposal of all textures.
  100764. */
  100765. dispose(forceDisposeTextures?: boolean): void;
  100766. /**
  100767. * Get the current class name of the texture useful for serialization or dynamic coding.
  100768. * @returns "PBRClearCoatConfiguration"
  100769. */
  100770. getClassName(): string;
  100771. /**
  100772. * Add fallbacks to the effect fallbacks list.
  100773. * @param defines defines the Base texture to use.
  100774. * @param fallbacks defines the current fallback list.
  100775. * @param currentRank defines the current fallback rank.
  100776. * @returns the new fallback rank.
  100777. */
  100778. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100779. /**
  100780. * Add the required uniforms to the current list.
  100781. * @param uniforms defines the current uniform list.
  100782. */
  100783. static AddUniforms(uniforms: string[]): void;
  100784. /**
  100785. * Add the required samplers to the current list.
  100786. * @param samplers defines the current sampler list.
  100787. */
  100788. static AddSamplers(samplers: string[]): void;
  100789. /**
  100790. * Add the required uniforms to the current buffer.
  100791. * @param uniformBuffer defines the current uniform buffer.
  100792. */
  100793. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100794. /**
  100795. * Makes a duplicate of the current configuration into another one.
  100796. * @param clearCoatConfiguration define the config where to copy the info
  100797. */
  100798. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100799. /**
  100800. * Serializes this clear coat configuration.
  100801. * @returns - An object with the serialized config.
  100802. */
  100803. serialize(): any;
  100804. /**
  100805. * Parses a Clear Coat Configuration from a serialized object.
  100806. * @param source - Serialized object.
  100807. */
  100808. parse(source: any): void;
  100809. }
  100810. }
  100811. declare module BABYLON {
  100812. /**
  100813. * @hidden
  100814. */
  100815. export interface IMaterialAnisotropicDefines {
  100816. ANISOTROPIC: boolean;
  100817. ANISOTROPIC_TEXTURE: boolean;
  100818. ANISOTROPIC_TEXTUREDIRECTUV: number;
  100819. MAINUV1: boolean;
  100820. _areTexturesDirty: boolean;
  100821. _needUVs: boolean;
  100822. }
  100823. /**
  100824. * Define the code related to the anisotropic parameters of the pbr material.
  100825. */
  100826. export class PBRAnisotropicConfiguration {
  100827. private _isEnabled;
  100828. /**
  100829. * Defines if the anisotropy is enabled in the material.
  100830. */
  100831. isEnabled: boolean;
  100832. /**
  100833. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100834. */
  100835. intensity: number;
  100836. /**
  100837. * Defines if the effect is along the tangents, bitangents or in between.
  100838. * By default, the effect is "strectching" the highlights along the tangents.
  100839. */
  100840. direction: Vector2;
  100841. private _texture;
  100842. /**
  100843. * Stores the anisotropy values in a texture.
  100844. * rg is direction (like normal from -1 to 1)
  100845. * b is a intensity
  100846. */
  100847. texture: Nullable<BaseTexture>;
  100848. /** @hidden */
  100849. private _internalMarkAllSubMeshesAsTexturesDirty;
  100850. /** @hidden */
  100851. _markAllSubMeshesAsTexturesDirty(): void;
  100852. /**
  100853. * Instantiate a new istance of anisotropy configuration.
  100854. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100855. */
  100856. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100857. /**
  100858. * Specifies that the submesh is ready to be used.
  100859. * @param defines the list of "defines" to update.
  100860. * @param scene defines the scene the material belongs to.
  100861. * @returns - boolean indicating that the submesh is ready or not.
  100862. */
  100863. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  100864. /**
  100865. * Checks to see if a texture is used in the material.
  100866. * @param defines the list of "defines" to update.
  100867. * @param mesh the mesh we are preparing the defines for.
  100868. * @param scene defines the scene the material belongs to.
  100869. */
  100870. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  100871. /**
  100872. * Binds the material data.
  100873. * @param uniformBuffer defines the Uniform buffer to fill in.
  100874. * @param scene defines the scene the material belongs to.
  100875. * @param isFrozen defines wether the material is frozen or not.
  100876. */
  100877. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100878. /**
  100879. * Checks to see if a texture is used in the material.
  100880. * @param texture - Base texture to use.
  100881. * @returns - Boolean specifying if a texture is used in the material.
  100882. */
  100883. hasTexture(texture: BaseTexture): boolean;
  100884. /**
  100885. * Returns an array of the actively used textures.
  100886. * @param activeTextures Array of BaseTextures
  100887. */
  100888. getActiveTextures(activeTextures: BaseTexture[]): void;
  100889. /**
  100890. * Returns the animatable textures.
  100891. * @param animatables Array of animatable textures.
  100892. */
  100893. getAnimatables(animatables: IAnimatable[]): void;
  100894. /**
  100895. * Disposes the resources of the material.
  100896. * @param forceDisposeTextures - Forces the disposal of all textures.
  100897. */
  100898. dispose(forceDisposeTextures?: boolean): void;
  100899. /**
  100900. * Get the current class name of the texture useful for serialization or dynamic coding.
  100901. * @returns "PBRAnisotropicConfiguration"
  100902. */
  100903. getClassName(): string;
  100904. /**
  100905. * Add fallbacks to the effect fallbacks list.
  100906. * @param defines defines the Base texture to use.
  100907. * @param fallbacks defines the current fallback list.
  100908. * @param currentRank defines the current fallback rank.
  100909. * @returns the new fallback rank.
  100910. */
  100911. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100912. /**
  100913. * Add the required uniforms to the current list.
  100914. * @param uniforms defines the current uniform list.
  100915. */
  100916. static AddUniforms(uniforms: string[]): void;
  100917. /**
  100918. * Add the required uniforms to the current buffer.
  100919. * @param uniformBuffer defines the current uniform buffer.
  100920. */
  100921. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100922. /**
  100923. * Add the required samplers to the current list.
  100924. * @param samplers defines the current sampler list.
  100925. */
  100926. static AddSamplers(samplers: string[]): void;
  100927. /**
  100928. * Makes a duplicate of the current configuration into another one.
  100929. * @param anisotropicConfiguration define the config where to copy the info
  100930. */
  100931. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100932. /**
  100933. * Serializes this anisotropy configuration.
  100934. * @returns - An object with the serialized config.
  100935. */
  100936. serialize(): any;
  100937. /**
  100938. * Parses a anisotropy Configuration from a serialized object.
  100939. * @param source - Serialized object.
  100940. */
  100941. parse(source: any): void;
  100942. }
  100943. }
  100944. declare module BABYLON {
  100945. /**
  100946. * @hidden
  100947. */
  100948. export interface IMaterialBRDFDefines {
  100949. BRDF_V_HEIGHT_CORRELATED: boolean;
  100950. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100951. /** @hidden */
  100952. _areMiscDirty: boolean;
  100953. }
  100954. /**
  100955. * Define the code related to the BRDF parameters of the pbr material.
  100956. */
  100957. export class PBRBRDFConfiguration {
  100958. private _useEnergyConservation;
  100959. /**
  100960. * Defines if the material uses energy conservation.
  100961. */
  100962. useEnergyConservation: boolean;
  100963. private _useSmithVisibilityHeightCorrelated;
  100964. /**
  100965. * LEGACY Mode set to false
  100966. * Defines if the material uses height smith correlated visibility term.
  100967. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100968. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100969. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100970. * Not relying on height correlated will also disable energy conservation.
  100971. */
  100972. useSmithVisibilityHeightCorrelated: boolean;
  100973. /** @hidden */
  100974. private _internalMarkAllSubMeshesAsMiscDirty;
  100975. /** @hidden */
  100976. _markAllSubMeshesAsMiscDirty(): void;
  100977. /**
  100978. * Instantiate a new istance of clear coat configuration.
  100979. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100980. */
  100981. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100982. /**
  100983. * Checks to see if a texture is used in the material.
  100984. * @param defines the list of "defines" to update.
  100985. */
  100986. prepareDefines(defines: IMaterialBRDFDefines): void;
  100987. /**
  100988. * Get the current class name of the texture useful for serialization or dynamic coding.
  100989. * @returns "PBRClearCoatConfiguration"
  100990. */
  100991. getClassName(): string;
  100992. /**
  100993. * Makes a duplicate of the current configuration into another one.
  100994. * @param brdfConfiguration define the config where to copy the info
  100995. */
  100996. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100997. /**
  100998. * Serializes this BRDF configuration.
  100999. * @returns - An object with the serialized config.
  101000. */
  101001. serialize(): any;
  101002. /**
  101003. * Parses a BRDF Configuration from a serialized object.
  101004. * @param source - Serialized object.
  101005. */
  101006. parse(source: any): void;
  101007. }
  101008. }
  101009. declare module BABYLON {
  101010. /**
  101011. * @hidden
  101012. */
  101013. export interface IMaterialSheenDefines {
  101014. SHEEN: boolean;
  101015. SHEEN_TEXTURE: boolean;
  101016. SHEEN_TEXTUREDIRECTUV: number;
  101017. SHEEN_LINKWITHALBEDO: boolean;
  101018. /** @hidden */
  101019. _areTexturesDirty: boolean;
  101020. }
  101021. /**
  101022. * Define the code related to the Sheen parameters of the pbr material.
  101023. */
  101024. export class PBRSheenConfiguration {
  101025. private _isEnabled;
  101026. /**
  101027. * Defines if the material uses sheen.
  101028. */
  101029. isEnabled: boolean;
  101030. private _linkSheenWithAlbedo;
  101031. /**
  101032. * Defines if the sheen is linked to the sheen color.
  101033. */
  101034. linkSheenWithAlbedo: boolean;
  101035. /**
  101036. * Defines the sheen intensity.
  101037. */
  101038. intensity: number;
  101039. /**
  101040. * Defines the sheen color.
  101041. */
  101042. color: Color3;
  101043. private _texture;
  101044. /**
  101045. * Stores the sheen tint values in a texture.
  101046. * rgb is tint
  101047. * a is a intensity
  101048. */
  101049. texture: Nullable<BaseTexture>;
  101050. /** @hidden */
  101051. private _internalMarkAllSubMeshesAsTexturesDirty;
  101052. /** @hidden */
  101053. _markAllSubMeshesAsTexturesDirty(): void;
  101054. /**
  101055. * Instantiate a new istance of clear coat configuration.
  101056. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101057. */
  101058. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101059. /**
  101060. * Specifies that the submesh is ready to be used.
  101061. * @param defines the list of "defines" to update.
  101062. * @param scene defines the scene the material belongs to.
  101063. * @returns - boolean indicating that the submesh is ready or not.
  101064. */
  101065. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101066. /**
  101067. * Checks to see if a texture is used in the material.
  101068. * @param defines the list of "defines" to update.
  101069. * @param scene defines the scene the material belongs to.
  101070. */
  101071. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101072. /**
  101073. * Binds the material data.
  101074. * @param uniformBuffer defines the Uniform buffer to fill in.
  101075. * @param scene defines the scene the material belongs to.
  101076. * @param isFrozen defines wether the material is frozen or not.
  101077. */
  101078. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101079. /**
  101080. * Checks to see if a texture is used in the material.
  101081. * @param texture - Base texture to use.
  101082. * @returns - Boolean specifying if a texture is used in the material.
  101083. */
  101084. hasTexture(texture: BaseTexture): boolean;
  101085. /**
  101086. * Returns an array of the actively used textures.
  101087. * @param activeTextures Array of BaseTextures
  101088. */
  101089. getActiveTextures(activeTextures: BaseTexture[]): void;
  101090. /**
  101091. * Returns the animatable textures.
  101092. * @param animatables Array of animatable textures.
  101093. */
  101094. getAnimatables(animatables: IAnimatable[]): void;
  101095. /**
  101096. * Disposes the resources of the material.
  101097. * @param forceDisposeTextures - Forces the disposal of all textures.
  101098. */
  101099. dispose(forceDisposeTextures?: boolean): void;
  101100. /**
  101101. * Get the current class name of the texture useful for serialization or dynamic coding.
  101102. * @returns "PBRSheenConfiguration"
  101103. */
  101104. getClassName(): string;
  101105. /**
  101106. * Add fallbacks to the effect fallbacks list.
  101107. * @param defines defines the Base texture to use.
  101108. * @param fallbacks defines the current fallback list.
  101109. * @param currentRank defines the current fallback rank.
  101110. * @returns the new fallback rank.
  101111. */
  101112. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101113. /**
  101114. * Add the required uniforms to the current list.
  101115. * @param uniforms defines the current uniform list.
  101116. */
  101117. static AddUniforms(uniforms: string[]): void;
  101118. /**
  101119. * Add the required uniforms to the current buffer.
  101120. * @param uniformBuffer defines the current uniform buffer.
  101121. */
  101122. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101123. /**
  101124. * Add the required samplers to the current list.
  101125. * @param samplers defines the current sampler list.
  101126. */
  101127. static AddSamplers(samplers: string[]): void;
  101128. /**
  101129. * Makes a duplicate of the current configuration into another one.
  101130. * @param sheenConfiguration define the config where to copy the info
  101131. */
  101132. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101133. /**
  101134. * Serializes this BRDF configuration.
  101135. * @returns - An object with the serialized config.
  101136. */
  101137. serialize(): any;
  101138. /**
  101139. * Parses a Sheen Configuration from a serialized object.
  101140. * @param source - Serialized object.
  101141. */
  101142. parse(source: any): void;
  101143. }
  101144. }
  101145. declare module BABYLON {
  101146. /** @hidden */
  101147. export var pbrFragmentDeclaration: {
  101148. name: string;
  101149. shader: string;
  101150. };
  101151. }
  101152. declare module BABYLON {
  101153. /** @hidden */
  101154. export var pbrUboDeclaration: {
  101155. name: string;
  101156. shader: string;
  101157. };
  101158. }
  101159. declare module BABYLON {
  101160. /** @hidden */
  101161. export var pbrFunctions: {
  101162. name: string;
  101163. shader: string;
  101164. };
  101165. }
  101166. declare module BABYLON {
  101167. /** @hidden */
  101168. export var harmonicsFunctions: {
  101169. name: string;
  101170. shader: string;
  101171. };
  101172. }
  101173. declare module BABYLON {
  101174. /** @hidden */
  101175. export var pbrPreLightingFunctions: {
  101176. name: string;
  101177. shader: string;
  101178. };
  101179. }
  101180. declare module BABYLON {
  101181. /** @hidden */
  101182. export var pbrFalloffLightingFunctions: {
  101183. name: string;
  101184. shader: string;
  101185. };
  101186. }
  101187. declare module BABYLON {
  101188. /** @hidden */
  101189. export var pbrLightingFunctions: {
  101190. name: string;
  101191. shader: string;
  101192. };
  101193. }
  101194. declare module BABYLON {
  101195. /** @hidden */
  101196. export var pbrDebug: {
  101197. name: string;
  101198. shader: string;
  101199. };
  101200. }
  101201. declare module BABYLON {
  101202. /** @hidden */
  101203. export var pbrPixelShader: {
  101204. name: string;
  101205. shader: string;
  101206. };
  101207. }
  101208. declare module BABYLON {
  101209. /** @hidden */
  101210. export var pbrVertexDeclaration: {
  101211. name: string;
  101212. shader: string;
  101213. };
  101214. }
  101215. declare module BABYLON {
  101216. /** @hidden */
  101217. export var pbrVertexShader: {
  101218. name: string;
  101219. shader: string;
  101220. };
  101221. }
  101222. declare module BABYLON {
  101223. /**
  101224. * The Physically based material base class of BJS.
  101225. *
  101226. * This offers the main features of a standard PBR material.
  101227. * For more information, please refer to the documentation :
  101228. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101229. */
  101230. export abstract class PBRBaseMaterial extends PushMaterial {
  101231. /**
  101232. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101233. */
  101234. static readonly PBRMATERIAL_OPAQUE: number;
  101235. /**
  101236. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101237. */
  101238. static readonly PBRMATERIAL_ALPHATEST: number;
  101239. /**
  101240. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101241. */
  101242. static readonly PBRMATERIAL_ALPHABLEND: number;
  101243. /**
  101244. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101245. * They are also discarded below the alpha cutoff threshold to improve performances.
  101246. */
  101247. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101248. /**
  101249. * Defines the default value of how much AO map is occluding the analytical lights
  101250. * (point spot...).
  101251. */
  101252. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101253. /**
  101254. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  101255. */
  101256. static readonly LIGHTFALLOFF_PHYSICAL: number;
  101257. /**
  101258. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  101259. * to enhance interoperability with other engines.
  101260. */
  101261. static readonly LIGHTFALLOFF_GLTF: number;
  101262. /**
  101263. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  101264. * to enhance interoperability with other materials.
  101265. */
  101266. static readonly LIGHTFALLOFF_STANDARD: number;
  101267. /**
  101268. * Intensity of the direct lights e.g. the four lights available in your scene.
  101269. * This impacts both the direct diffuse and specular highlights.
  101270. */
  101271. protected _directIntensity: number;
  101272. /**
  101273. * Intensity of the emissive part of the material.
  101274. * This helps controlling the emissive effect without modifying the emissive color.
  101275. */
  101276. protected _emissiveIntensity: number;
  101277. /**
  101278. * Intensity of the environment e.g. how much the environment will light the object
  101279. * either through harmonics for rough material or through the refelction for shiny ones.
  101280. */
  101281. protected _environmentIntensity: number;
  101282. /**
  101283. * This is a special control allowing the reduction of the specular highlights coming from the
  101284. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101285. */
  101286. protected _specularIntensity: number;
  101287. /**
  101288. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  101289. */
  101290. private _lightingInfos;
  101291. /**
  101292. * Debug Control allowing disabling the bump map on this material.
  101293. */
  101294. protected _disableBumpMap: boolean;
  101295. /**
  101296. * AKA Diffuse Texture in standard nomenclature.
  101297. */
  101298. protected _albedoTexture: BaseTexture;
  101299. /**
  101300. * AKA Occlusion Texture in other nomenclature.
  101301. */
  101302. protected _ambientTexture: BaseTexture;
  101303. /**
  101304. * AKA Occlusion Texture Intensity in other nomenclature.
  101305. */
  101306. protected _ambientTextureStrength: number;
  101307. /**
  101308. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101309. * 1 means it completely occludes it
  101310. * 0 mean it has no impact
  101311. */
  101312. protected _ambientTextureImpactOnAnalyticalLights: number;
  101313. /**
  101314. * Stores the alpha values in a texture.
  101315. */
  101316. protected _opacityTexture: BaseTexture;
  101317. /**
  101318. * Stores the reflection values in a texture.
  101319. */
  101320. protected _reflectionTexture: BaseTexture;
  101321. /**
  101322. * Stores the refraction values in a texture.
  101323. */
  101324. protected _refractionTexture: BaseTexture;
  101325. /**
  101326. * Stores the emissive values in a texture.
  101327. */
  101328. protected _emissiveTexture: BaseTexture;
  101329. /**
  101330. * AKA Specular texture in other nomenclature.
  101331. */
  101332. protected _reflectivityTexture: BaseTexture;
  101333. /**
  101334. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101335. */
  101336. protected _metallicTexture: BaseTexture;
  101337. /**
  101338. * Specifies the metallic scalar of the metallic/roughness workflow.
  101339. * Can also be used to scale the metalness values of the metallic texture.
  101340. */
  101341. protected _metallic: Nullable<number>;
  101342. /**
  101343. * Specifies the roughness scalar of the metallic/roughness workflow.
  101344. * Can also be used to scale the roughness values of the metallic texture.
  101345. */
  101346. protected _roughness: Nullable<number>;
  101347. /**
  101348. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101349. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101350. */
  101351. protected _microSurfaceTexture: BaseTexture;
  101352. /**
  101353. * Stores surface normal data used to displace a mesh in a texture.
  101354. */
  101355. protected _bumpTexture: BaseTexture;
  101356. /**
  101357. * Stores the pre-calculated light information of a mesh in a texture.
  101358. */
  101359. protected _lightmapTexture: BaseTexture;
  101360. /**
  101361. * The color of a material in ambient lighting.
  101362. */
  101363. protected _ambientColor: Color3;
  101364. /**
  101365. * AKA Diffuse Color in other nomenclature.
  101366. */
  101367. protected _albedoColor: Color3;
  101368. /**
  101369. * AKA Specular Color in other nomenclature.
  101370. */
  101371. protected _reflectivityColor: Color3;
  101372. /**
  101373. * The color applied when light is reflected from a material.
  101374. */
  101375. protected _reflectionColor: Color3;
  101376. /**
  101377. * The color applied when light is emitted from a material.
  101378. */
  101379. protected _emissiveColor: Color3;
  101380. /**
  101381. * AKA Glossiness in other nomenclature.
  101382. */
  101383. protected _microSurface: number;
  101384. /**
  101385. * source material index of refraction (IOR)' / 'destination material IOR.
  101386. */
  101387. protected _indexOfRefraction: number;
  101388. /**
  101389. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101390. */
  101391. protected _invertRefractionY: boolean;
  101392. /**
  101393. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101394. * Materials half opaque for instance using refraction could benefit from this control.
  101395. */
  101396. protected _linkRefractionWithTransparency: boolean;
  101397. /**
  101398. * Specifies that the material will use the light map as a show map.
  101399. */
  101400. protected _useLightmapAsShadowmap: boolean;
  101401. /**
  101402. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101403. * makes the reflect vector face the model (under horizon).
  101404. */
  101405. protected _useHorizonOcclusion: boolean;
  101406. /**
  101407. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101408. * too much the area relying on ambient texture to define their ambient occlusion.
  101409. */
  101410. protected _useRadianceOcclusion: boolean;
  101411. /**
  101412. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101413. */
  101414. protected _useAlphaFromAlbedoTexture: boolean;
  101415. /**
  101416. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  101417. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101418. */
  101419. protected _useSpecularOverAlpha: boolean;
  101420. /**
  101421. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101422. */
  101423. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101424. /**
  101425. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101426. */
  101427. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  101428. /**
  101429. * Specifies if the metallic texture contains the roughness information in its green channel.
  101430. */
  101431. protected _useRoughnessFromMetallicTextureGreen: boolean;
  101432. /**
  101433. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101434. */
  101435. protected _useMetallnessFromMetallicTextureBlue: boolean;
  101436. /**
  101437. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101438. */
  101439. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  101440. /**
  101441. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101442. */
  101443. protected _useAmbientInGrayScale: boolean;
  101444. /**
  101445. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101446. * The material will try to infer what glossiness each pixel should be.
  101447. */
  101448. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  101449. /**
  101450. * Defines the falloff type used in this material.
  101451. * It by default is Physical.
  101452. */
  101453. protected _lightFalloff: number;
  101454. /**
  101455. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101456. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101457. */
  101458. protected _useRadianceOverAlpha: boolean;
  101459. /**
  101460. * Allows using an object space normal map (instead of tangent space).
  101461. */
  101462. protected _useObjectSpaceNormalMap: boolean;
  101463. /**
  101464. * Allows using the bump map in parallax mode.
  101465. */
  101466. protected _useParallax: boolean;
  101467. /**
  101468. * Allows using the bump map in parallax occlusion mode.
  101469. */
  101470. protected _useParallaxOcclusion: boolean;
  101471. /**
  101472. * Controls the scale bias of the parallax mode.
  101473. */
  101474. protected _parallaxScaleBias: number;
  101475. /**
  101476. * If sets to true, disables all the lights affecting the material.
  101477. */
  101478. protected _disableLighting: boolean;
  101479. /**
  101480. * Number of Simultaneous lights allowed on the material.
  101481. */
  101482. protected _maxSimultaneousLights: number;
  101483. /**
  101484. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101485. */
  101486. protected _invertNormalMapX: boolean;
  101487. /**
  101488. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101489. */
  101490. protected _invertNormalMapY: boolean;
  101491. /**
  101492. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101493. */
  101494. protected _twoSidedLighting: boolean;
  101495. /**
  101496. * Defines the alpha limits in alpha test mode.
  101497. */
  101498. protected _alphaCutOff: number;
  101499. /**
  101500. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101501. */
  101502. protected _forceAlphaTest: boolean;
  101503. /**
  101504. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101505. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101506. */
  101507. protected _useAlphaFresnel: boolean;
  101508. /**
  101509. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101510. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101511. */
  101512. protected _useLinearAlphaFresnel: boolean;
  101513. /**
  101514. * The transparency mode of the material.
  101515. */
  101516. protected _transparencyMode: Nullable<number>;
  101517. /**
  101518. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  101519. * from cos thetav and roughness:
  101520. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  101521. */
  101522. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  101523. /**
  101524. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101525. */
  101526. protected _forceIrradianceInFragment: boolean;
  101527. /**
  101528. * Force normal to face away from face.
  101529. */
  101530. protected _forceNormalForward: boolean;
  101531. /**
  101532. * Enables specular anti aliasing in the PBR shader.
  101533. * It will both interacts on the Geometry for analytical and IBL lighting.
  101534. * It also prefilter the roughness map based on the bump values.
  101535. */
  101536. protected _enableSpecularAntiAliasing: boolean;
  101537. /**
  101538. * Default configuration related to image processing available in the PBR Material.
  101539. */
  101540. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101541. /**
  101542. * Keep track of the image processing observer to allow dispose and replace.
  101543. */
  101544. private _imageProcessingObserver;
  101545. /**
  101546. * Attaches a new image processing configuration to the PBR Material.
  101547. * @param configuration
  101548. */
  101549. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101550. /**
  101551. * Stores the available render targets.
  101552. */
  101553. private _renderTargets;
  101554. /**
  101555. * Sets the global ambient color for the material used in lighting calculations.
  101556. */
  101557. private _globalAmbientColor;
  101558. /**
  101559. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  101560. */
  101561. private _useLogarithmicDepth;
  101562. /**
  101563. * If set to true, no lighting calculations will be applied.
  101564. */
  101565. private _unlit;
  101566. private _debugMode;
  101567. /**
  101568. * @hidden
  101569. * This is reserved for the inspector.
  101570. * Defines the material debug mode.
  101571. * It helps seeing only some components of the material while troubleshooting.
  101572. */
  101573. debugMode: number;
  101574. /**
  101575. * @hidden
  101576. * This is reserved for the inspector.
  101577. * Specify from where on screen the debug mode should start.
  101578. * The value goes from -1 (full screen) to 1 (not visible)
  101579. * It helps with side by side comparison against the final render
  101580. * This defaults to -1
  101581. */
  101582. private debugLimit;
  101583. /**
  101584. * @hidden
  101585. * This is reserved for the inspector.
  101586. * As the default viewing range might not be enough (if the ambient is really small for instance)
  101587. * You can use the factor to better multiply the final value.
  101588. */
  101589. private debugFactor;
  101590. /**
  101591. * Defines the clear coat layer parameters for the material.
  101592. */
  101593. readonly clearCoat: PBRClearCoatConfiguration;
  101594. /**
  101595. * Defines the anisotropic parameters for the material.
  101596. */
  101597. readonly anisotropy: PBRAnisotropicConfiguration;
  101598. /**
  101599. * Defines the BRDF parameters for the material.
  101600. */
  101601. readonly brdf: PBRBRDFConfiguration;
  101602. /**
  101603. * Defines the Sheen parameters for the material.
  101604. */
  101605. readonly sheen: PBRSheenConfiguration;
  101606. /**
  101607. * Instantiates a new PBRMaterial instance.
  101608. *
  101609. * @param name The material name
  101610. * @param scene The scene the material will be use in.
  101611. */
  101612. constructor(name: string, scene: Scene);
  101613. /**
  101614. * Gets a boolean indicating that current material needs to register RTT
  101615. */
  101616. readonly hasRenderTargetTextures: boolean;
  101617. /**
  101618. * Gets the name of the material class.
  101619. */
  101620. getClassName(): string;
  101621. /**
  101622. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101623. */
  101624. /**
  101625. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101626. */
  101627. useLogarithmicDepth: boolean;
  101628. /**
  101629. * Gets the current transparency mode.
  101630. */
  101631. /**
  101632. * Sets the transparency mode of the material.
  101633. *
  101634. * | Value | Type | Description |
  101635. * | ----- | ----------------------------------- | ----------- |
  101636. * | 0 | OPAQUE | |
  101637. * | 1 | ALPHATEST | |
  101638. * | 2 | ALPHABLEND | |
  101639. * | 3 | ALPHATESTANDBLEND | |
  101640. *
  101641. */
  101642. transparencyMode: Nullable<number>;
  101643. /**
  101644. * Returns true if alpha blending should be disabled.
  101645. */
  101646. private readonly _disableAlphaBlending;
  101647. /**
  101648. * Specifies whether or not this material should be rendered in alpha blend mode.
  101649. */
  101650. needAlphaBlending(): boolean;
  101651. /**
  101652. * Specifies if the mesh will require alpha blending.
  101653. * @param mesh - BJS mesh.
  101654. */
  101655. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101656. /**
  101657. * Specifies whether or not this material should be rendered in alpha test mode.
  101658. */
  101659. needAlphaTesting(): boolean;
  101660. /**
  101661. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  101662. */
  101663. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  101664. /**
  101665. * Gets the texture used for the alpha test.
  101666. */
  101667. getAlphaTestTexture(): BaseTexture;
  101668. /**
  101669. * Specifies that the submesh is ready to be used.
  101670. * @param mesh - BJS mesh.
  101671. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  101672. * @param useInstances - Specifies that instances should be used.
  101673. * @returns - boolean indicating that the submesh is ready or not.
  101674. */
  101675. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101676. /**
  101677. * Specifies if the material uses metallic roughness workflow.
  101678. * @returns boolean specifiying if the material uses metallic roughness workflow.
  101679. */
  101680. isMetallicWorkflow(): boolean;
  101681. private _prepareEffect;
  101682. private _prepareDefines;
  101683. /**
  101684. * Force shader compilation
  101685. */
  101686. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  101687. clipPlane: boolean;
  101688. }>): void;
  101689. /**
  101690. * Initializes the uniform buffer layout for the shader.
  101691. */
  101692. buildUniformLayout(): void;
  101693. /**
  101694. * Unbinds the textures.
  101695. */
  101696. unbind(): void;
  101697. /**
  101698. * Binds the submesh data.
  101699. * @param world - The world matrix.
  101700. * @param mesh - The BJS mesh.
  101701. * @param subMesh - A submesh of the BJS mesh.
  101702. */
  101703. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101704. /**
  101705. * Returns the animatable textures.
  101706. * @returns - Array of animatable textures.
  101707. */
  101708. getAnimatables(): IAnimatable[];
  101709. /**
  101710. * Returns the texture used for reflections.
  101711. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  101712. */
  101713. private _getReflectionTexture;
  101714. /**
  101715. * Returns the texture used for refraction or null if none is used.
  101716. * @returns - Refection texture if present. If no refraction texture and refraction
  101717. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101718. */
  101719. private _getRefractionTexture;
  101720. /**
  101721. * Returns an array of the actively used textures.
  101722. * @returns - Array of BaseTextures
  101723. */
  101724. getActiveTextures(): BaseTexture[];
  101725. /**
  101726. * Checks to see if a texture is used in the material.
  101727. * @param texture - Base texture to use.
  101728. * @returns - Boolean specifying if a texture is used in the material.
  101729. */
  101730. hasTexture(texture: BaseTexture): boolean;
  101731. /**
  101732. * Disposes the resources of the material.
  101733. * @param forceDisposeEffect - Forces the disposal of effects.
  101734. * @param forceDisposeTextures - Forces the disposal of all textures.
  101735. */
  101736. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101737. }
  101738. }
  101739. declare module BABYLON {
  101740. /**
  101741. * The Physically based material of BJS.
  101742. *
  101743. * This offers the main features of a standard PBR material.
  101744. * For more information, please refer to the documentation :
  101745. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101746. */
  101747. export class PBRMaterial extends PBRBaseMaterial {
  101748. /**
  101749. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101750. */
  101751. static readonly PBRMATERIAL_OPAQUE: number;
  101752. /**
  101753. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101754. */
  101755. static readonly PBRMATERIAL_ALPHATEST: number;
  101756. /**
  101757. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101758. */
  101759. static readonly PBRMATERIAL_ALPHABLEND: number;
  101760. /**
  101761. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101762. * They are also discarded below the alpha cutoff threshold to improve performances.
  101763. */
  101764. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101765. /**
  101766. * Defines the default value of how much AO map is occluding the analytical lights
  101767. * (point spot...).
  101768. */
  101769. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101770. /**
  101771. * Intensity of the direct lights e.g. the four lights available in your scene.
  101772. * This impacts both the direct diffuse and specular highlights.
  101773. */
  101774. directIntensity: number;
  101775. /**
  101776. * Intensity of the emissive part of the material.
  101777. * This helps controlling the emissive effect without modifying the emissive color.
  101778. */
  101779. emissiveIntensity: number;
  101780. /**
  101781. * Intensity of the environment e.g. how much the environment will light the object
  101782. * either through harmonics for rough material or through the refelction for shiny ones.
  101783. */
  101784. environmentIntensity: number;
  101785. /**
  101786. * This is a special control allowing the reduction of the specular highlights coming from the
  101787. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101788. */
  101789. specularIntensity: number;
  101790. /**
  101791. * Debug Control allowing disabling the bump map on this material.
  101792. */
  101793. disableBumpMap: boolean;
  101794. /**
  101795. * AKA Diffuse Texture in standard nomenclature.
  101796. */
  101797. albedoTexture: BaseTexture;
  101798. /**
  101799. * AKA Occlusion Texture in other nomenclature.
  101800. */
  101801. ambientTexture: BaseTexture;
  101802. /**
  101803. * AKA Occlusion Texture Intensity in other nomenclature.
  101804. */
  101805. ambientTextureStrength: number;
  101806. /**
  101807. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101808. * 1 means it completely occludes it
  101809. * 0 mean it has no impact
  101810. */
  101811. ambientTextureImpactOnAnalyticalLights: number;
  101812. /**
  101813. * Stores the alpha values in a texture.
  101814. */
  101815. opacityTexture: BaseTexture;
  101816. /**
  101817. * Stores the reflection values in a texture.
  101818. */
  101819. reflectionTexture: Nullable<BaseTexture>;
  101820. /**
  101821. * Stores the emissive values in a texture.
  101822. */
  101823. emissiveTexture: BaseTexture;
  101824. /**
  101825. * AKA Specular texture in other nomenclature.
  101826. */
  101827. reflectivityTexture: BaseTexture;
  101828. /**
  101829. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101830. */
  101831. metallicTexture: BaseTexture;
  101832. /**
  101833. * Specifies the metallic scalar of the metallic/roughness workflow.
  101834. * Can also be used to scale the metalness values of the metallic texture.
  101835. */
  101836. metallic: Nullable<number>;
  101837. /**
  101838. * Specifies the roughness scalar of the metallic/roughness workflow.
  101839. * Can also be used to scale the roughness values of the metallic texture.
  101840. */
  101841. roughness: Nullable<number>;
  101842. /**
  101843. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101844. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101845. */
  101846. microSurfaceTexture: BaseTexture;
  101847. /**
  101848. * Stores surface normal data used to displace a mesh in a texture.
  101849. */
  101850. bumpTexture: BaseTexture;
  101851. /**
  101852. * Stores the pre-calculated light information of a mesh in a texture.
  101853. */
  101854. lightmapTexture: BaseTexture;
  101855. /**
  101856. * Stores the refracted light information in a texture.
  101857. */
  101858. refractionTexture: BaseTexture;
  101859. /**
  101860. * The color of a material in ambient lighting.
  101861. */
  101862. ambientColor: Color3;
  101863. /**
  101864. * AKA Diffuse Color in other nomenclature.
  101865. */
  101866. albedoColor: Color3;
  101867. /**
  101868. * AKA Specular Color in other nomenclature.
  101869. */
  101870. reflectivityColor: Color3;
  101871. /**
  101872. * The color reflected from the material.
  101873. */
  101874. reflectionColor: Color3;
  101875. /**
  101876. * The color emitted from the material.
  101877. */
  101878. emissiveColor: Color3;
  101879. /**
  101880. * AKA Glossiness in other nomenclature.
  101881. */
  101882. microSurface: number;
  101883. /**
  101884. * source material index of refraction (IOR)' / 'destination material IOR.
  101885. */
  101886. indexOfRefraction: number;
  101887. /**
  101888. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101889. */
  101890. invertRefractionY: boolean;
  101891. /**
  101892. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101893. * Materials half opaque for instance using refraction could benefit from this control.
  101894. */
  101895. linkRefractionWithTransparency: boolean;
  101896. /**
  101897. * If true, the light map contains occlusion information instead of lighting info.
  101898. */
  101899. useLightmapAsShadowmap: boolean;
  101900. /**
  101901. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101902. */
  101903. useAlphaFromAlbedoTexture: boolean;
  101904. /**
  101905. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101906. */
  101907. forceAlphaTest: boolean;
  101908. /**
  101909. * Defines the alpha limits in alpha test mode.
  101910. */
  101911. alphaCutOff: number;
  101912. /**
  101913. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101914. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101915. */
  101916. useSpecularOverAlpha: boolean;
  101917. /**
  101918. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101919. */
  101920. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101921. /**
  101922. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101923. */
  101924. useRoughnessFromMetallicTextureAlpha: boolean;
  101925. /**
  101926. * Specifies if the metallic texture contains the roughness information in its green channel.
  101927. */
  101928. useRoughnessFromMetallicTextureGreen: boolean;
  101929. /**
  101930. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101931. */
  101932. useMetallnessFromMetallicTextureBlue: boolean;
  101933. /**
  101934. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101935. */
  101936. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101937. /**
  101938. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101939. */
  101940. useAmbientInGrayScale: boolean;
  101941. /**
  101942. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101943. * The material will try to infer what glossiness each pixel should be.
  101944. */
  101945. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101946. /**
  101947. * BJS is using an harcoded light falloff based on a manually sets up range.
  101948. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101949. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101950. */
  101951. /**
  101952. * BJS is using an harcoded light falloff based on a manually sets up range.
  101953. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101954. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101955. */
  101956. usePhysicalLightFalloff: boolean;
  101957. /**
  101958. * In order to support the falloff compatibility with gltf, a special mode has been added
  101959. * to reproduce the gltf light falloff.
  101960. */
  101961. /**
  101962. * In order to support the falloff compatibility with gltf, a special mode has been added
  101963. * to reproduce the gltf light falloff.
  101964. */
  101965. useGLTFLightFalloff: boolean;
  101966. /**
  101967. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101968. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101969. */
  101970. useRadianceOverAlpha: boolean;
  101971. /**
  101972. * Allows using an object space normal map (instead of tangent space).
  101973. */
  101974. useObjectSpaceNormalMap: boolean;
  101975. /**
  101976. * Allows using the bump map in parallax mode.
  101977. */
  101978. useParallax: boolean;
  101979. /**
  101980. * Allows using the bump map in parallax occlusion mode.
  101981. */
  101982. useParallaxOcclusion: boolean;
  101983. /**
  101984. * Controls the scale bias of the parallax mode.
  101985. */
  101986. parallaxScaleBias: number;
  101987. /**
  101988. * If sets to true, disables all the lights affecting the material.
  101989. */
  101990. disableLighting: boolean;
  101991. /**
  101992. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101993. */
  101994. forceIrradianceInFragment: boolean;
  101995. /**
  101996. * Number of Simultaneous lights allowed on the material.
  101997. */
  101998. maxSimultaneousLights: number;
  101999. /**
  102000. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102001. */
  102002. invertNormalMapX: boolean;
  102003. /**
  102004. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102005. */
  102006. invertNormalMapY: boolean;
  102007. /**
  102008. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102009. */
  102010. twoSidedLighting: boolean;
  102011. /**
  102012. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102013. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102014. */
  102015. useAlphaFresnel: boolean;
  102016. /**
  102017. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102018. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102019. */
  102020. useLinearAlphaFresnel: boolean;
  102021. /**
  102022. * Let user defines the brdf lookup texture used for IBL.
  102023. * A default 8bit version is embedded but you could point at :
  102024. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  102025. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  102026. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  102027. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  102028. */
  102029. environmentBRDFTexture: Nullable<BaseTexture>;
  102030. /**
  102031. * Force normal to face away from face.
  102032. */
  102033. forceNormalForward: boolean;
  102034. /**
  102035. * Enables specular anti aliasing in the PBR shader.
  102036. * It will both interacts on the Geometry for analytical and IBL lighting.
  102037. * It also prefilter the roughness map based on the bump values.
  102038. */
  102039. enableSpecularAntiAliasing: boolean;
  102040. /**
  102041. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102042. * makes the reflect vector face the model (under horizon).
  102043. */
  102044. useHorizonOcclusion: boolean;
  102045. /**
  102046. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102047. * too much the area relying on ambient texture to define their ambient occlusion.
  102048. */
  102049. useRadianceOcclusion: boolean;
  102050. /**
  102051. * If set to true, no lighting calculations will be applied.
  102052. */
  102053. unlit: boolean;
  102054. /**
  102055. * Gets the image processing configuration used either in this material.
  102056. */
  102057. /**
  102058. * Sets the Default image processing configuration used either in the this material.
  102059. *
  102060. * If sets to null, the scene one is in use.
  102061. */
  102062. imageProcessingConfiguration: ImageProcessingConfiguration;
  102063. /**
  102064. * Gets wether the color curves effect is enabled.
  102065. */
  102066. /**
  102067. * Sets wether the color curves effect is enabled.
  102068. */
  102069. cameraColorCurvesEnabled: boolean;
  102070. /**
  102071. * Gets wether the color grading effect is enabled.
  102072. */
  102073. /**
  102074. * Gets wether the color grading effect is enabled.
  102075. */
  102076. cameraColorGradingEnabled: boolean;
  102077. /**
  102078. * Gets wether tonemapping is enabled or not.
  102079. */
  102080. /**
  102081. * Sets wether tonemapping is enabled or not
  102082. */
  102083. cameraToneMappingEnabled: boolean;
  102084. /**
  102085. * The camera exposure used on this material.
  102086. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102087. * This corresponds to a photographic exposure.
  102088. */
  102089. /**
  102090. * The camera exposure used on this material.
  102091. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102092. * This corresponds to a photographic exposure.
  102093. */
  102094. cameraExposure: number;
  102095. /**
  102096. * Gets The camera contrast used on this material.
  102097. */
  102098. /**
  102099. * Sets The camera contrast used on this material.
  102100. */
  102101. cameraContrast: number;
  102102. /**
  102103. * Gets the Color Grading 2D Lookup Texture.
  102104. */
  102105. /**
  102106. * Sets the Color Grading 2D Lookup Texture.
  102107. */
  102108. cameraColorGradingTexture: Nullable<BaseTexture>;
  102109. /**
  102110. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102111. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102112. * 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;
  102113. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102114. */
  102115. /**
  102116. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102117. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102118. * 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;
  102119. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102120. */
  102121. cameraColorCurves: Nullable<ColorCurves>;
  102122. /**
  102123. * Instantiates a new PBRMaterial instance.
  102124. *
  102125. * @param name The material name
  102126. * @param scene The scene the material will be use in.
  102127. */
  102128. constructor(name: string, scene: Scene);
  102129. /**
  102130. * Returns the name of this material class.
  102131. */
  102132. getClassName(): string;
  102133. /**
  102134. * Makes a duplicate of the current material.
  102135. * @param name - name to use for the new material.
  102136. */
  102137. clone(name: string): PBRMaterial;
  102138. /**
  102139. * Serializes this PBR Material.
  102140. * @returns - An object with the serialized material.
  102141. */
  102142. serialize(): any;
  102143. /**
  102144. * Parses a PBR Material from a serialized object.
  102145. * @param source - Serialized object.
  102146. * @param scene - BJS scene instance.
  102147. * @param rootUrl - url for the scene object
  102148. * @returns - PBRMaterial
  102149. */
  102150. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  102151. }
  102152. }
  102153. declare module BABYLON {
  102154. /**
  102155. * Direct draw surface info
  102156. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102157. */
  102158. export interface DDSInfo {
  102159. /**
  102160. * Width of the texture
  102161. */
  102162. width: number;
  102163. /**
  102164. * Width of the texture
  102165. */
  102166. height: number;
  102167. /**
  102168. * Number of Mipmaps for the texture
  102169. * @see https://en.wikipedia.org/wiki/Mipmap
  102170. */
  102171. mipmapCount: number;
  102172. /**
  102173. * If the textures format is a known fourCC format
  102174. * @see https://www.fourcc.org/
  102175. */
  102176. isFourCC: boolean;
  102177. /**
  102178. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102179. */
  102180. isRGB: boolean;
  102181. /**
  102182. * If the texture is a lumincance format
  102183. */
  102184. isLuminance: boolean;
  102185. /**
  102186. * If this is a cube texture
  102187. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102188. */
  102189. isCube: boolean;
  102190. /**
  102191. * If the texture is a compressed format eg. FOURCC_DXT1
  102192. */
  102193. isCompressed: boolean;
  102194. /**
  102195. * The dxgiFormat of the texture
  102196. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102197. */
  102198. dxgiFormat: number;
  102199. /**
  102200. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102201. */
  102202. textureType: number;
  102203. /**
  102204. * Sphericle polynomial created for the dds texture
  102205. */
  102206. sphericalPolynomial?: SphericalPolynomial;
  102207. }
  102208. /**
  102209. * Class used to provide DDS decompression tools
  102210. */
  102211. export class DDSTools {
  102212. /**
  102213. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102214. */
  102215. static StoreLODInAlphaChannel: boolean;
  102216. /**
  102217. * Gets DDS information from an array buffer
  102218. * @param arrayBuffer defines the array buffer to read data from
  102219. * @returns the DDS information
  102220. */
  102221. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102222. private static _FloatView;
  102223. private static _Int32View;
  102224. private static _ToHalfFloat;
  102225. private static _FromHalfFloat;
  102226. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102227. private static _GetHalfFloatRGBAArrayBuffer;
  102228. private static _GetFloatRGBAArrayBuffer;
  102229. private static _GetFloatAsUIntRGBAArrayBuffer;
  102230. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102231. private static _GetRGBAArrayBuffer;
  102232. private static _ExtractLongWordOrder;
  102233. private static _GetRGBArrayBuffer;
  102234. private static _GetLuminanceArrayBuffer;
  102235. /**
  102236. * Uploads DDS Levels to a Babylon Texture
  102237. * @hidden
  102238. */
  102239. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102240. }
  102241. interface Engine {
  102242. /**
  102243. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102244. * @param rootUrl defines the url where the file to load is located
  102245. * @param scene defines the current scene
  102246. * @param lodScale defines scale to apply to the mip map selection
  102247. * @param lodOffset defines offset to apply to the mip map selection
  102248. * @param onLoad defines an optional callback raised when the texture is loaded
  102249. * @param onError defines an optional callback raised if there is an issue to load the texture
  102250. * @param format defines the format of the data
  102251. * @param forcedExtension defines the extension to use to pick the right loader
  102252. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102253. * @returns the cube texture as an InternalTexture
  102254. */
  102255. 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;
  102256. }
  102257. }
  102258. declare module BABYLON {
  102259. /**
  102260. * Implementation of the DDS Texture Loader.
  102261. * @hidden
  102262. */
  102263. export class _DDSTextureLoader implements IInternalTextureLoader {
  102264. /**
  102265. * Defines wether the loader supports cascade loading the different faces.
  102266. */
  102267. readonly supportCascades: boolean;
  102268. /**
  102269. * This returns if the loader support the current file information.
  102270. * @param extension defines the file extension of the file being loaded
  102271. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102272. * @param fallback defines the fallback internal texture if any
  102273. * @param isBase64 defines whether the texture is encoded as a base64
  102274. * @param isBuffer defines whether the texture data are stored as a buffer
  102275. * @returns true if the loader can load the specified file
  102276. */
  102277. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102278. /**
  102279. * Transform the url before loading if required.
  102280. * @param rootUrl the url of the texture
  102281. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102282. * @returns the transformed texture
  102283. */
  102284. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102285. /**
  102286. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102287. * @param rootUrl the url of the texture
  102288. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102289. * @returns the fallback texture
  102290. */
  102291. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102292. /**
  102293. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102294. * @param data contains the texture data
  102295. * @param texture defines the BabylonJS internal texture
  102296. * @param createPolynomials will be true if polynomials have been requested
  102297. * @param onLoad defines the callback to trigger once the texture is ready
  102298. * @param onError defines the callback to trigger in case of error
  102299. */
  102300. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102301. /**
  102302. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102303. * @param data contains the texture data
  102304. * @param texture defines the BabylonJS internal texture
  102305. * @param callback defines the method to call once ready to upload
  102306. */
  102307. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102308. }
  102309. }
  102310. declare module BABYLON {
  102311. /** @hidden */
  102312. export var rgbdEncodePixelShader: {
  102313. name: string;
  102314. shader: string;
  102315. };
  102316. }
  102317. declare module BABYLON {
  102318. /** @hidden */
  102319. export var rgbdDecodePixelShader: {
  102320. name: string;
  102321. shader: string;
  102322. };
  102323. }
  102324. declare module BABYLON {
  102325. /**
  102326. * Raw texture data and descriptor sufficient for WebGL texture upload
  102327. */
  102328. export interface EnvironmentTextureInfo {
  102329. /**
  102330. * Version of the environment map
  102331. */
  102332. version: number;
  102333. /**
  102334. * Width of image
  102335. */
  102336. width: number;
  102337. /**
  102338. * Irradiance information stored in the file.
  102339. */
  102340. irradiance: any;
  102341. /**
  102342. * Specular information stored in the file.
  102343. */
  102344. specular: any;
  102345. }
  102346. /**
  102347. * Sets of helpers addressing the serialization and deserialization of environment texture
  102348. * stored in a BabylonJS env file.
  102349. * Those files are usually stored as .env files.
  102350. */
  102351. export class EnvironmentTextureTools {
  102352. /**
  102353. * Magic number identifying the env file.
  102354. */
  102355. private static _MagicBytes;
  102356. /**
  102357. * Gets the environment info from an env file.
  102358. * @param data The array buffer containing the .env bytes.
  102359. * @returns the environment file info (the json header) if successfully parsed.
  102360. */
  102361. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102362. /**
  102363. * Creates an environment texture from a loaded cube texture.
  102364. * @param texture defines the cube texture to convert in env file
  102365. * @return a promise containing the environment data if succesfull.
  102366. */
  102367. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102368. /**
  102369. * Creates a JSON representation of the spherical data.
  102370. * @param texture defines the texture containing the polynomials
  102371. * @return the JSON representation of the spherical info
  102372. */
  102373. private static _CreateEnvTextureIrradiance;
  102374. /**
  102375. * Uploads the texture info contained in the env file to the GPU.
  102376. * @param texture defines the internal texture to upload to
  102377. * @param arrayBuffer defines the buffer cotaining the data to load
  102378. * @param info defines the texture info retrieved through the GetEnvInfo method
  102379. * @returns a promise
  102380. */
  102381. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102382. /**
  102383. * Uploads the levels of image data to the GPU.
  102384. * @param texture defines the internal texture to upload to
  102385. * @param imageData defines the array buffer views of image data [mipmap][face]
  102386. * @returns a promise
  102387. */
  102388. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102389. /**
  102390. * Uploads spherical polynomials information to the texture.
  102391. * @param texture defines the texture we are trying to upload the information to
  102392. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102393. */
  102394. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102395. /** @hidden */
  102396. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102397. }
  102398. }
  102399. declare module BABYLON {
  102400. /**
  102401. * Implementation of the ENV Texture Loader.
  102402. * @hidden
  102403. */
  102404. export class _ENVTextureLoader implements IInternalTextureLoader {
  102405. /**
  102406. * Defines wether the loader supports cascade loading the different faces.
  102407. */
  102408. readonly supportCascades: boolean;
  102409. /**
  102410. * This returns if the loader support the current file information.
  102411. * @param extension defines the file extension of the file being loaded
  102412. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102413. * @param fallback defines the fallback internal texture if any
  102414. * @param isBase64 defines whether the texture is encoded as a base64
  102415. * @param isBuffer defines whether the texture data are stored as a buffer
  102416. * @returns true if the loader can load the specified file
  102417. */
  102418. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102419. /**
  102420. * Transform the url before loading if required.
  102421. * @param rootUrl the url of the texture
  102422. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102423. * @returns the transformed texture
  102424. */
  102425. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102426. /**
  102427. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102428. * @param rootUrl the url of the texture
  102429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102430. * @returns the fallback texture
  102431. */
  102432. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102433. /**
  102434. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102435. * @param data contains the texture data
  102436. * @param texture defines the BabylonJS internal texture
  102437. * @param createPolynomials will be true if polynomials have been requested
  102438. * @param onLoad defines the callback to trigger once the texture is ready
  102439. * @param onError defines the callback to trigger in case of error
  102440. */
  102441. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102442. /**
  102443. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102444. * @param data contains the texture data
  102445. * @param texture defines the BabylonJS internal texture
  102446. * @param callback defines the method to call once ready to upload
  102447. */
  102448. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102449. }
  102450. }
  102451. declare module BABYLON {
  102452. /**
  102453. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102454. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102455. */
  102456. export class KhronosTextureContainer {
  102457. /** contents of the KTX container file */
  102458. arrayBuffer: any;
  102459. private static HEADER_LEN;
  102460. private static COMPRESSED_2D;
  102461. private static COMPRESSED_3D;
  102462. private static TEX_2D;
  102463. private static TEX_3D;
  102464. /**
  102465. * Gets the openGL type
  102466. */
  102467. glType: number;
  102468. /**
  102469. * Gets the openGL type size
  102470. */
  102471. glTypeSize: number;
  102472. /**
  102473. * Gets the openGL format
  102474. */
  102475. glFormat: number;
  102476. /**
  102477. * Gets the openGL internal format
  102478. */
  102479. glInternalFormat: number;
  102480. /**
  102481. * Gets the base internal format
  102482. */
  102483. glBaseInternalFormat: number;
  102484. /**
  102485. * Gets image width in pixel
  102486. */
  102487. pixelWidth: number;
  102488. /**
  102489. * Gets image height in pixel
  102490. */
  102491. pixelHeight: number;
  102492. /**
  102493. * Gets image depth in pixels
  102494. */
  102495. pixelDepth: number;
  102496. /**
  102497. * Gets the number of array elements
  102498. */
  102499. numberOfArrayElements: number;
  102500. /**
  102501. * Gets the number of faces
  102502. */
  102503. numberOfFaces: number;
  102504. /**
  102505. * Gets the number of mipmap levels
  102506. */
  102507. numberOfMipmapLevels: number;
  102508. /**
  102509. * Gets the bytes of key value data
  102510. */
  102511. bytesOfKeyValueData: number;
  102512. /**
  102513. * Gets the load type
  102514. */
  102515. loadType: number;
  102516. /**
  102517. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102518. */
  102519. isInvalid: boolean;
  102520. /**
  102521. * Creates a new KhronosTextureContainer
  102522. * @param arrayBuffer contents of the KTX container file
  102523. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102524. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102525. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102526. */
  102527. constructor(
  102528. /** contents of the KTX container file */
  102529. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102530. /**
  102531. * Uploads KTX content to a Babylon Texture.
  102532. * It is assumed that the texture has already been created & is currently bound
  102533. * @hidden
  102534. */
  102535. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102536. private _upload2DCompressedLevels;
  102537. }
  102538. }
  102539. declare module BABYLON {
  102540. /**
  102541. * Implementation of the KTX Texture Loader.
  102542. * @hidden
  102543. */
  102544. export class _KTXTextureLoader implements IInternalTextureLoader {
  102545. /**
  102546. * Defines wether the loader supports cascade loading the different faces.
  102547. */
  102548. readonly supportCascades: boolean;
  102549. /**
  102550. * This returns if the loader support the current file information.
  102551. * @param extension defines the file extension of the file being loaded
  102552. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102553. * @param fallback defines the fallback internal texture if any
  102554. * @param isBase64 defines whether the texture is encoded as a base64
  102555. * @param isBuffer defines whether the texture data are stored as a buffer
  102556. * @returns true if the loader can load the specified file
  102557. */
  102558. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102559. /**
  102560. * Transform the url before loading if required.
  102561. * @param rootUrl the url of the texture
  102562. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102563. * @returns the transformed texture
  102564. */
  102565. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102566. /**
  102567. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102568. * @param rootUrl the url of the texture
  102569. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102570. * @returns the fallback texture
  102571. */
  102572. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102573. /**
  102574. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102575. * @param data contains the texture data
  102576. * @param texture defines the BabylonJS internal texture
  102577. * @param createPolynomials will be true if polynomials have been requested
  102578. * @param onLoad defines the callback to trigger once the texture is ready
  102579. * @param onError defines the callback to trigger in case of error
  102580. */
  102581. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102582. /**
  102583. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102584. * @param data contains the texture data
  102585. * @param texture defines the BabylonJS internal texture
  102586. * @param callback defines the method to call once ready to upload
  102587. */
  102588. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102589. }
  102590. }
  102591. declare module BABYLON {
  102592. /** @hidden */
  102593. export var _forceSceneHelpersToBundle: boolean;
  102594. interface Scene {
  102595. /**
  102596. * Creates a default light for the scene.
  102597. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  102598. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  102599. */
  102600. createDefaultLight(replace?: boolean): void;
  102601. /**
  102602. * Creates a default camera for the scene.
  102603. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  102604. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102605. * @param replace has default false, when true replaces the active camera in the scene
  102606. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  102607. */
  102608. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102609. /**
  102610. * Creates a default camera and a default light.
  102611. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  102612. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102613. * @param replace has the default false, when true replaces the active camera/light in the scene
  102614. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  102615. */
  102616. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102617. /**
  102618. * Creates a new sky box
  102619. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  102620. * @param environmentTexture defines the texture to use as environment texture
  102621. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  102622. * @param scale defines the overall scale of the skybox
  102623. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  102624. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  102625. * @returns a new mesh holding the sky box
  102626. */
  102627. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  102628. /**
  102629. * Creates a new environment
  102630. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  102631. * @param options defines the options you can use to configure the environment
  102632. * @returns the new EnvironmentHelper
  102633. */
  102634. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  102635. /**
  102636. * Creates a new VREXperienceHelper
  102637. * @see http://doc.babylonjs.com/how_to/webvr_helper
  102638. * @param webVROptions defines the options used to create the new VREXperienceHelper
  102639. * @returns a new VREXperienceHelper
  102640. */
  102641. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  102642. /**
  102643. * Creates a new XREXperienceHelper
  102644. * @see http://doc.babylonjs.com/how_to/webxr
  102645. * @returns a promise for a new XREXperienceHelper
  102646. */
  102647. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  102648. }
  102649. }
  102650. declare module BABYLON {
  102651. /**
  102652. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  102653. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  102654. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  102655. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102656. */
  102657. export class VideoDome extends TransformNode {
  102658. /**
  102659. * Define the video source as a Monoscopic panoramic 360 video.
  102660. */
  102661. static readonly MODE_MONOSCOPIC: number;
  102662. /**
  102663. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102664. */
  102665. static readonly MODE_TOPBOTTOM: number;
  102666. /**
  102667. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102668. */
  102669. static readonly MODE_SIDEBYSIDE: number;
  102670. private _useDirectMapping;
  102671. /**
  102672. * The video texture being displayed on the sphere
  102673. */
  102674. protected _videoTexture: VideoTexture;
  102675. /**
  102676. * Gets the video texture being displayed on the sphere
  102677. */
  102678. readonly videoTexture: VideoTexture;
  102679. /**
  102680. * The skybox material
  102681. */
  102682. protected _material: BackgroundMaterial;
  102683. /**
  102684. * The surface used for the skybox
  102685. */
  102686. protected _mesh: Mesh;
  102687. /**
  102688. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102689. * Also see the options.resolution property.
  102690. */
  102691. fovMultiplier: number;
  102692. private _videoMode;
  102693. /**
  102694. * Gets or set the current video mode for the video. It can be:
  102695. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  102696. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102697. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102698. */
  102699. videoMode: number;
  102700. /**
  102701. * Oberserver used in Stereoscopic VR Mode.
  102702. */
  102703. private _onBeforeCameraRenderObserver;
  102704. /**
  102705. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  102706. * @param name Element's name, child elements will append suffixes for their own names.
  102707. * @param urlsOrVideo defines the url(s) or the video element to use
  102708. * @param options An object containing optional or exposed sub element properties
  102709. */
  102710. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  102711. resolution?: number;
  102712. clickToPlay?: boolean;
  102713. autoPlay?: boolean;
  102714. loop?: boolean;
  102715. size?: number;
  102716. poster?: string;
  102717. useDirectMapping?: boolean;
  102718. }, scene: Scene);
  102719. private _changeVideoMode;
  102720. /**
  102721. * Releases resources associated with this node.
  102722. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102723. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102724. */
  102725. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102726. }
  102727. }
  102728. declare module BABYLON {
  102729. /**
  102730. * This class can be used to get instrumentation data from a Babylon engine
  102731. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102732. */
  102733. export class EngineInstrumentation implements IDisposable {
  102734. /**
  102735. * Define the instrumented engine.
  102736. */
  102737. engine: Engine;
  102738. private _captureGPUFrameTime;
  102739. private _gpuFrameTimeToken;
  102740. private _gpuFrameTime;
  102741. private _captureShaderCompilationTime;
  102742. private _shaderCompilationTime;
  102743. private _onBeginFrameObserver;
  102744. private _onEndFrameObserver;
  102745. private _onBeforeShaderCompilationObserver;
  102746. private _onAfterShaderCompilationObserver;
  102747. /**
  102748. * Gets the perf counter used for GPU frame time
  102749. */
  102750. readonly gpuFrameTimeCounter: PerfCounter;
  102751. /**
  102752. * Gets the GPU frame time capture status
  102753. */
  102754. /**
  102755. * Enable or disable the GPU frame time capture
  102756. */
  102757. captureGPUFrameTime: boolean;
  102758. /**
  102759. * Gets the perf counter used for shader compilation time
  102760. */
  102761. readonly shaderCompilationTimeCounter: PerfCounter;
  102762. /**
  102763. * Gets the shader compilation time capture status
  102764. */
  102765. /**
  102766. * Enable or disable the shader compilation time capture
  102767. */
  102768. captureShaderCompilationTime: boolean;
  102769. /**
  102770. * Instantiates a new engine instrumentation.
  102771. * This class can be used to get instrumentation data from a Babylon engine
  102772. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102773. * @param engine Defines the engine to instrument
  102774. */
  102775. constructor(
  102776. /**
  102777. * Define the instrumented engine.
  102778. */
  102779. engine: Engine);
  102780. /**
  102781. * Dispose and release associated resources.
  102782. */
  102783. dispose(): void;
  102784. }
  102785. }
  102786. declare module BABYLON {
  102787. /**
  102788. * This class can be used to get instrumentation data from a Babylon engine
  102789. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102790. */
  102791. export class SceneInstrumentation implements IDisposable {
  102792. /**
  102793. * Defines the scene to instrument
  102794. */
  102795. scene: Scene;
  102796. private _captureActiveMeshesEvaluationTime;
  102797. private _activeMeshesEvaluationTime;
  102798. private _captureRenderTargetsRenderTime;
  102799. private _renderTargetsRenderTime;
  102800. private _captureFrameTime;
  102801. private _frameTime;
  102802. private _captureRenderTime;
  102803. private _renderTime;
  102804. private _captureInterFrameTime;
  102805. private _interFrameTime;
  102806. private _captureParticlesRenderTime;
  102807. private _particlesRenderTime;
  102808. private _captureSpritesRenderTime;
  102809. private _spritesRenderTime;
  102810. private _capturePhysicsTime;
  102811. private _physicsTime;
  102812. private _captureAnimationsTime;
  102813. private _animationsTime;
  102814. private _captureCameraRenderTime;
  102815. private _cameraRenderTime;
  102816. private _onBeforeActiveMeshesEvaluationObserver;
  102817. private _onAfterActiveMeshesEvaluationObserver;
  102818. private _onBeforeRenderTargetsRenderObserver;
  102819. private _onAfterRenderTargetsRenderObserver;
  102820. private _onAfterRenderObserver;
  102821. private _onBeforeDrawPhaseObserver;
  102822. private _onAfterDrawPhaseObserver;
  102823. private _onBeforeAnimationsObserver;
  102824. private _onBeforeParticlesRenderingObserver;
  102825. private _onAfterParticlesRenderingObserver;
  102826. private _onBeforeSpritesRenderingObserver;
  102827. private _onAfterSpritesRenderingObserver;
  102828. private _onBeforePhysicsObserver;
  102829. private _onAfterPhysicsObserver;
  102830. private _onAfterAnimationsObserver;
  102831. private _onBeforeCameraRenderObserver;
  102832. private _onAfterCameraRenderObserver;
  102833. /**
  102834. * Gets the perf counter used for active meshes evaluation time
  102835. */
  102836. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  102837. /**
  102838. * Gets the active meshes evaluation time capture status
  102839. */
  102840. /**
  102841. * Enable or disable the active meshes evaluation time capture
  102842. */
  102843. captureActiveMeshesEvaluationTime: boolean;
  102844. /**
  102845. * Gets the perf counter used for render targets render time
  102846. */
  102847. readonly renderTargetsRenderTimeCounter: PerfCounter;
  102848. /**
  102849. * Gets the render targets render time capture status
  102850. */
  102851. /**
  102852. * Enable or disable the render targets render time capture
  102853. */
  102854. captureRenderTargetsRenderTime: boolean;
  102855. /**
  102856. * Gets the perf counter used for particles render time
  102857. */
  102858. readonly particlesRenderTimeCounter: PerfCounter;
  102859. /**
  102860. * Gets the particles render time capture status
  102861. */
  102862. /**
  102863. * Enable or disable the particles render time capture
  102864. */
  102865. captureParticlesRenderTime: boolean;
  102866. /**
  102867. * Gets the perf counter used for sprites render time
  102868. */
  102869. readonly spritesRenderTimeCounter: PerfCounter;
  102870. /**
  102871. * Gets the sprites render time capture status
  102872. */
  102873. /**
  102874. * Enable or disable the sprites render time capture
  102875. */
  102876. captureSpritesRenderTime: boolean;
  102877. /**
  102878. * Gets the perf counter used for physics time
  102879. */
  102880. readonly physicsTimeCounter: PerfCounter;
  102881. /**
  102882. * Gets the physics time capture status
  102883. */
  102884. /**
  102885. * Enable or disable the physics time capture
  102886. */
  102887. capturePhysicsTime: boolean;
  102888. /**
  102889. * Gets the perf counter used for animations time
  102890. */
  102891. readonly animationsTimeCounter: PerfCounter;
  102892. /**
  102893. * Gets the animations time capture status
  102894. */
  102895. /**
  102896. * Enable or disable the animations time capture
  102897. */
  102898. captureAnimationsTime: boolean;
  102899. /**
  102900. * Gets the perf counter used for frame time capture
  102901. */
  102902. readonly frameTimeCounter: PerfCounter;
  102903. /**
  102904. * Gets the frame time capture status
  102905. */
  102906. /**
  102907. * Enable or disable the frame time capture
  102908. */
  102909. captureFrameTime: boolean;
  102910. /**
  102911. * Gets the perf counter used for inter-frames time capture
  102912. */
  102913. readonly interFrameTimeCounter: PerfCounter;
  102914. /**
  102915. * Gets the inter-frames time capture status
  102916. */
  102917. /**
  102918. * Enable or disable the inter-frames time capture
  102919. */
  102920. captureInterFrameTime: boolean;
  102921. /**
  102922. * Gets the perf counter used for render time capture
  102923. */
  102924. readonly renderTimeCounter: PerfCounter;
  102925. /**
  102926. * Gets the render time capture status
  102927. */
  102928. /**
  102929. * Enable or disable the render time capture
  102930. */
  102931. captureRenderTime: boolean;
  102932. /**
  102933. * Gets the perf counter used for camera render time capture
  102934. */
  102935. readonly cameraRenderTimeCounter: PerfCounter;
  102936. /**
  102937. * Gets the camera render time capture status
  102938. */
  102939. /**
  102940. * Enable or disable the camera render time capture
  102941. */
  102942. captureCameraRenderTime: boolean;
  102943. /**
  102944. * Gets the perf counter used for draw calls
  102945. */
  102946. readonly drawCallsCounter: PerfCounter;
  102947. /**
  102948. * Gets the perf counter used for texture collisions
  102949. */
  102950. readonly textureCollisionsCounter: PerfCounter;
  102951. /**
  102952. * Instantiates a new scene instrumentation.
  102953. * This class can be used to get instrumentation data from a Babylon engine
  102954. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102955. * @param scene Defines the scene to instrument
  102956. */
  102957. constructor(
  102958. /**
  102959. * Defines the scene to instrument
  102960. */
  102961. scene: Scene);
  102962. /**
  102963. * Dispose and release associated resources.
  102964. */
  102965. dispose(): void;
  102966. }
  102967. }
  102968. declare module BABYLON {
  102969. /** @hidden */
  102970. export var glowMapGenerationPixelShader: {
  102971. name: string;
  102972. shader: string;
  102973. };
  102974. }
  102975. declare module BABYLON {
  102976. /** @hidden */
  102977. export var glowMapGenerationVertexShader: {
  102978. name: string;
  102979. shader: string;
  102980. };
  102981. }
  102982. declare module BABYLON {
  102983. /**
  102984. * Effect layer options. This helps customizing the behaviour
  102985. * of the effect layer.
  102986. */
  102987. export interface IEffectLayerOptions {
  102988. /**
  102989. * Multiplication factor apply to the canvas size to compute the render target size
  102990. * used to generated the objects (the smaller the faster).
  102991. */
  102992. mainTextureRatio: number;
  102993. /**
  102994. * Enforces a fixed size texture to ensure effect stability across devices.
  102995. */
  102996. mainTextureFixedSize?: number;
  102997. /**
  102998. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  102999. */
  103000. alphaBlendingMode: number;
  103001. /**
  103002. * The camera attached to the layer.
  103003. */
  103004. camera: Nullable<Camera>;
  103005. /**
  103006. * The rendering group to draw the layer in.
  103007. */
  103008. renderingGroupId: number;
  103009. }
  103010. /**
  103011. * The effect layer Helps adding post process effect blended with the main pass.
  103012. *
  103013. * This can be for instance use to generate glow or higlight effects on the scene.
  103014. *
  103015. * The effect layer class can not be used directly and is intented to inherited from to be
  103016. * customized per effects.
  103017. */
  103018. export abstract class EffectLayer {
  103019. private _vertexBuffers;
  103020. private _indexBuffer;
  103021. private _cachedDefines;
  103022. private _effectLayerMapGenerationEffect;
  103023. private _effectLayerOptions;
  103024. private _mergeEffect;
  103025. protected _scene: Scene;
  103026. protected _engine: Engine;
  103027. protected _maxSize: number;
  103028. protected _mainTextureDesiredSize: ISize;
  103029. protected _mainTexture: RenderTargetTexture;
  103030. protected _shouldRender: boolean;
  103031. protected _postProcesses: PostProcess[];
  103032. protected _textures: BaseTexture[];
  103033. protected _emissiveTextureAndColor: {
  103034. texture: Nullable<BaseTexture>;
  103035. color: Color4;
  103036. };
  103037. /**
  103038. * The name of the layer
  103039. */
  103040. name: string;
  103041. /**
  103042. * The clear color of the texture used to generate the glow map.
  103043. */
  103044. neutralColor: Color4;
  103045. /**
  103046. * Specifies wether the highlight layer is enabled or not.
  103047. */
  103048. isEnabled: boolean;
  103049. /**
  103050. * Gets the camera attached to the layer.
  103051. */
  103052. readonly camera: Nullable<Camera>;
  103053. /**
  103054. * Gets the rendering group id the layer should render in.
  103055. */
  103056. readonly renderingGroupId: number;
  103057. /**
  103058. * An event triggered when the effect layer has been disposed.
  103059. */
  103060. onDisposeObservable: Observable<EffectLayer>;
  103061. /**
  103062. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  103063. */
  103064. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  103065. /**
  103066. * An event triggered when the generated texture is being merged in the scene.
  103067. */
  103068. onBeforeComposeObservable: Observable<EffectLayer>;
  103069. /**
  103070. * An event triggered when the generated texture has been merged in the scene.
  103071. */
  103072. onAfterComposeObservable: Observable<EffectLayer>;
  103073. /**
  103074. * An event triggered when the efffect layer changes its size.
  103075. */
  103076. onSizeChangedObservable: Observable<EffectLayer>;
  103077. /** @hidden */
  103078. static _SceneComponentInitialization: (scene: Scene) => void;
  103079. /**
  103080. * Instantiates a new effect Layer and references it in the scene.
  103081. * @param name The name of the layer
  103082. * @param scene The scene to use the layer in
  103083. */
  103084. constructor(
  103085. /** The Friendly of the effect in the scene */
  103086. name: string, scene: Scene);
  103087. /**
  103088. * Get the effect name of the layer.
  103089. * @return The effect name
  103090. */
  103091. abstract getEffectName(): string;
  103092. /**
  103093. * Checks for the readiness of the element composing the layer.
  103094. * @param subMesh the mesh to check for
  103095. * @param useInstances specify wether or not to use instances to render the mesh
  103096. * @return true if ready otherwise, false
  103097. */
  103098. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103099. /**
  103100. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103101. * @returns true if the effect requires stencil during the main canvas render pass.
  103102. */
  103103. abstract needStencil(): boolean;
  103104. /**
  103105. * Create the merge effect. This is the shader use to blit the information back
  103106. * to the main canvas at the end of the scene rendering.
  103107. * @returns The effect containing the shader used to merge the effect on the main canvas
  103108. */
  103109. protected abstract _createMergeEffect(): Effect;
  103110. /**
  103111. * Creates the render target textures and post processes used in the effect layer.
  103112. */
  103113. protected abstract _createTextureAndPostProcesses(): void;
  103114. /**
  103115. * Implementation specific of rendering the generating effect on the main canvas.
  103116. * @param effect The effect used to render through
  103117. */
  103118. protected abstract _internalRender(effect: Effect): void;
  103119. /**
  103120. * Sets the required values for both the emissive texture and and the main color.
  103121. */
  103122. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103123. /**
  103124. * Free any resources and references associated to a mesh.
  103125. * Internal use
  103126. * @param mesh The mesh to free.
  103127. */
  103128. abstract _disposeMesh(mesh: Mesh): void;
  103129. /**
  103130. * Serializes this layer (Glow or Highlight for example)
  103131. * @returns a serialized layer object
  103132. */
  103133. abstract serialize?(): any;
  103134. /**
  103135. * Initializes the effect layer with the required options.
  103136. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  103137. */
  103138. protected _init(options: Partial<IEffectLayerOptions>): void;
  103139. /**
  103140. * Generates the index buffer of the full screen quad blending to the main canvas.
  103141. */
  103142. private _generateIndexBuffer;
  103143. /**
  103144. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  103145. */
  103146. private _genrateVertexBuffer;
  103147. /**
  103148. * Sets the main texture desired size which is the closest power of two
  103149. * of the engine canvas size.
  103150. */
  103151. private _setMainTextureSize;
  103152. /**
  103153. * Creates the main texture for the effect layer.
  103154. */
  103155. protected _createMainTexture(): void;
  103156. /**
  103157. * Adds specific effects defines.
  103158. * @param defines The defines to add specifics to.
  103159. */
  103160. protected _addCustomEffectDefines(defines: string[]): void;
  103161. /**
  103162. * Checks for the readiness of the element composing the layer.
  103163. * @param subMesh the mesh to check for
  103164. * @param useInstances specify wether or not to use instances to render the mesh
  103165. * @param emissiveTexture the associated emissive texture used to generate the glow
  103166. * @return true if ready otherwise, false
  103167. */
  103168. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  103169. /**
  103170. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  103171. */
  103172. render(): void;
  103173. /**
  103174. * Determine if a given mesh will be used in the current effect.
  103175. * @param mesh mesh to test
  103176. * @returns true if the mesh will be used
  103177. */
  103178. hasMesh(mesh: AbstractMesh): boolean;
  103179. /**
  103180. * Returns true if the layer contains information to display, otherwise false.
  103181. * @returns true if the glow layer should be rendered
  103182. */
  103183. shouldRender(): boolean;
  103184. /**
  103185. * Returns true if the mesh should render, otherwise false.
  103186. * @param mesh The mesh to render
  103187. * @returns true if it should render otherwise false
  103188. */
  103189. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  103190. /**
  103191. * Returns true if the mesh can be rendered, otherwise false.
  103192. * @param mesh The mesh to render
  103193. * @param material The material used on the mesh
  103194. * @returns true if it can be rendered otherwise false
  103195. */
  103196. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103197. /**
  103198. * Returns true if the mesh should render, otherwise false.
  103199. * @param mesh The mesh to render
  103200. * @returns true if it should render otherwise false
  103201. */
  103202. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  103203. /**
  103204. * Renders the submesh passed in parameter to the generation map.
  103205. */
  103206. protected _renderSubMesh(subMesh: SubMesh): void;
  103207. /**
  103208. * Rebuild the required buffers.
  103209. * @hidden Internal use only.
  103210. */
  103211. _rebuild(): void;
  103212. /**
  103213. * Dispose only the render target textures and post process.
  103214. */
  103215. private _disposeTextureAndPostProcesses;
  103216. /**
  103217. * Dispose the highlight layer and free resources.
  103218. */
  103219. dispose(): void;
  103220. /**
  103221. * Gets the class name of the effect layer
  103222. * @returns the string with the class name of the effect layer
  103223. */
  103224. getClassName(): string;
  103225. /**
  103226. * Creates an effect layer from parsed effect layer data
  103227. * @param parsedEffectLayer defines effect layer data
  103228. * @param scene defines the current scene
  103229. * @param rootUrl defines the root URL containing the effect layer information
  103230. * @returns a parsed effect Layer
  103231. */
  103232. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  103233. }
  103234. }
  103235. declare module BABYLON {
  103236. interface AbstractScene {
  103237. /**
  103238. * The list of effect layers (highlights/glow) added to the scene
  103239. * @see http://doc.babylonjs.com/how_to/highlight_layer
  103240. * @see http://doc.babylonjs.com/how_to/glow_layer
  103241. */
  103242. effectLayers: Array<EffectLayer>;
  103243. /**
  103244. * Removes the given effect layer from this scene.
  103245. * @param toRemove defines the effect layer to remove
  103246. * @returns the index of the removed effect layer
  103247. */
  103248. removeEffectLayer(toRemove: EffectLayer): number;
  103249. /**
  103250. * Adds the given effect layer to this scene
  103251. * @param newEffectLayer defines the effect layer to add
  103252. */
  103253. addEffectLayer(newEffectLayer: EffectLayer): void;
  103254. }
  103255. /**
  103256. * Defines the layer scene component responsible to manage any effect layers
  103257. * in a given scene.
  103258. */
  103259. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  103260. /**
  103261. * The component name helpfull to identify the component in the list of scene components.
  103262. */
  103263. readonly name: string;
  103264. /**
  103265. * The scene the component belongs to.
  103266. */
  103267. scene: Scene;
  103268. private _engine;
  103269. private _renderEffects;
  103270. private _needStencil;
  103271. private _previousStencilState;
  103272. /**
  103273. * Creates a new instance of the component for the given scene
  103274. * @param scene Defines the scene to register the component in
  103275. */
  103276. constructor(scene: Scene);
  103277. /**
  103278. * Registers the component in a given scene
  103279. */
  103280. register(): void;
  103281. /**
  103282. * Rebuilds the elements related to this component in case of
  103283. * context lost for instance.
  103284. */
  103285. rebuild(): void;
  103286. /**
  103287. * Serializes the component data to the specified json object
  103288. * @param serializationObject The object to serialize to
  103289. */
  103290. serialize(serializationObject: any): void;
  103291. /**
  103292. * Adds all the element from the container to the scene
  103293. * @param container the container holding the elements
  103294. */
  103295. addFromContainer(container: AbstractScene): void;
  103296. /**
  103297. * Removes all the elements in the container from the scene
  103298. * @param container contains the elements to remove
  103299. */
  103300. removeFromContainer(container: AbstractScene): void;
  103301. /**
  103302. * Disposes the component and the associated ressources.
  103303. */
  103304. dispose(): void;
  103305. private _isReadyForMesh;
  103306. private _renderMainTexture;
  103307. private _setStencil;
  103308. private _setStencilBack;
  103309. private _draw;
  103310. private _drawCamera;
  103311. private _drawRenderingGroup;
  103312. }
  103313. }
  103314. declare module BABYLON {
  103315. /** @hidden */
  103316. export var glowMapMergePixelShader: {
  103317. name: string;
  103318. shader: string;
  103319. };
  103320. }
  103321. declare module BABYLON {
  103322. /** @hidden */
  103323. export var glowMapMergeVertexShader: {
  103324. name: string;
  103325. shader: string;
  103326. };
  103327. }
  103328. declare module BABYLON {
  103329. interface AbstractScene {
  103330. /**
  103331. * Return a the first highlight layer of the scene with a given name.
  103332. * @param name The name of the highlight layer to look for.
  103333. * @return The highlight layer if found otherwise null.
  103334. */
  103335. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  103336. }
  103337. /**
  103338. * Glow layer options. This helps customizing the behaviour
  103339. * of the glow layer.
  103340. */
  103341. export interface IGlowLayerOptions {
  103342. /**
  103343. * Multiplication factor apply to the canvas size to compute the render target size
  103344. * used to generated the glowing objects (the smaller the faster).
  103345. */
  103346. mainTextureRatio: number;
  103347. /**
  103348. * Enforces a fixed size texture to ensure resize independant blur.
  103349. */
  103350. mainTextureFixedSize?: number;
  103351. /**
  103352. * How big is the kernel of the blur texture.
  103353. */
  103354. blurKernelSize: number;
  103355. /**
  103356. * The camera attached to the layer.
  103357. */
  103358. camera: Nullable<Camera>;
  103359. /**
  103360. * Enable MSAA by chosing the number of samples.
  103361. */
  103362. mainTextureSamples?: number;
  103363. /**
  103364. * The rendering group to draw the layer in.
  103365. */
  103366. renderingGroupId: number;
  103367. }
  103368. /**
  103369. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  103370. *
  103371. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103372. * glowy meshes to your scene.
  103373. *
  103374. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  103375. */
  103376. export class GlowLayer extends EffectLayer {
  103377. /**
  103378. * Effect Name of the layer.
  103379. */
  103380. static readonly EffectName: string;
  103381. /**
  103382. * The default blur kernel size used for the glow.
  103383. */
  103384. static DefaultBlurKernelSize: number;
  103385. /**
  103386. * The default texture size ratio used for the glow.
  103387. */
  103388. static DefaultTextureRatio: number;
  103389. /**
  103390. * Sets the kernel size of the blur.
  103391. */
  103392. /**
  103393. * Gets the kernel size of the blur.
  103394. */
  103395. blurKernelSize: number;
  103396. /**
  103397. * Sets the glow intensity.
  103398. */
  103399. /**
  103400. * Gets the glow intensity.
  103401. */
  103402. intensity: number;
  103403. private _options;
  103404. private _intensity;
  103405. private _horizontalBlurPostprocess1;
  103406. private _verticalBlurPostprocess1;
  103407. private _horizontalBlurPostprocess2;
  103408. private _verticalBlurPostprocess2;
  103409. private _blurTexture1;
  103410. private _blurTexture2;
  103411. private _postProcesses1;
  103412. private _postProcesses2;
  103413. private _includedOnlyMeshes;
  103414. private _excludedMeshes;
  103415. /**
  103416. * Callback used to let the user override the color selection on a per mesh basis
  103417. */
  103418. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  103419. /**
  103420. * Callback used to let the user override the texture selection on a per mesh basis
  103421. */
  103422. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  103423. /**
  103424. * Instantiates a new glow Layer and references it to the scene.
  103425. * @param name The name of the layer
  103426. * @param scene The scene to use the layer in
  103427. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  103428. */
  103429. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  103430. /**
  103431. * Get the effect name of the layer.
  103432. * @return The effect name
  103433. */
  103434. getEffectName(): string;
  103435. /**
  103436. * Create the merge effect. This is the shader use to blit the information back
  103437. * to the main canvas at the end of the scene rendering.
  103438. */
  103439. protected _createMergeEffect(): Effect;
  103440. /**
  103441. * Creates the render target textures and post processes used in the glow layer.
  103442. */
  103443. protected _createTextureAndPostProcesses(): void;
  103444. /**
  103445. * Checks for the readiness of the element composing the layer.
  103446. * @param subMesh the mesh to check for
  103447. * @param useInstances specify wether or not to use instances to render the mesh
  103448. * @param emissiveTexture the associated emissive texture used to generate the glow
  103449. * @return true if ready otherwise, false
  103450. */
  103451. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103452. /**
  103453. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103454. */
  103455. needStencil(): boolean;
  103456. /**
  103457. * Returns true if the mesh can be rendered, otherwise false.
  103458. * @param mesh The mesh to render
  103459. * @param material The material used on the mesh
  103460. * @returns true if it can be rendered otherwise false
  103461. */
  103462. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103463. /**
  103464. * Implementation specific of rendering the generating effect on the main canvas.
  103465. * @param effect The effect used to render through
  103466. */
  103467. protected _internalRender(effect: Effect): void;
  103468. /**
  103469. * Sets the required values for both the emissive texture and and the main color.
  103470. */
  103471. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103472. /**
  103473. * Returns true if the mesh should render, otherwise false.
  103474. * @param mesh The mesh to render
  103475. * @returns true if it should render otherwise false
  103476. */
  103477. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103478. /**
  103479. * Adds specific effects defines.
  103480. * @param defines The defines to add specifics to.
  103481. */
  103482. protected _addCustomEffectDefines(defines: string[]): void;
  103483. /**
  103484. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  103485. * @param mesh The mesh to exclude from the glow layer
  103486. */
  103487. addExcludedMesh(mesh: Mesh): void;
  103488. /**
  103489. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  103490. * @param mesh The mesh to remove
  103491. */
  103492. removeExcludedMesh(mesh: Mesh): void;
  103493. /**
  103494. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  103495. * @param mesh The mesh to include in the glow layer
  103496. */
  103497. addIncludedOnlyMesh(mesh: Mesh): void;
  103498. /**
  103499. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  103500. * @param mesh The mesh to remove
  103501. */
  103502. removeIncludedOnlyMesh(mesh: Mesh): void;
  103503. /**
  103504. * Determine if a given mesh will be used in the glow layer
  103505. * @param mesh The mesh to test
  103506. * @returns true if the mesh will be highlighted by the current glow layer
  103507. */
  103508. hasMesh(mesh: AbstractMesh): boolean;
  103509. /**
  103510. * Free any resources and references associated to a mesh.
  103511. * Internal use
  103512. * @param mesh The mesh to free.
  103513. * @hidden
  103514. */
  103515. _disposeMesh(mesh: Mesh): void;
  103516. /**
  103517. * Gets the class name of the effect layer
  103518. * @returns the string with the class name of the effect layer
  103519. */
  103520. getClassName(): string;
  103521. /**
  103522. * Serializes this glow layer
  103523. * @returns a serialized glow layer object
  103524. */
  103525. serialize(): any;
  103526. /**
  103527. * Creates a Glow Layer from parsed glow layer data
  103528. * @param parsedGlowLayer defines glow layer data
  103529. * @param scene defines the current scene
  103530. * @param rootUrl defines the root URL containing the glow layer information
  103531. * @returns a parsed Glow Layer
  103532. */
  103533. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  103534. }
  103535. }
  103536. declare module BABYLON {
  103537. /** @hidden */
  103538. export var glowBlurPostProcessPixelShader: {
  103539. name: string;
  103540. shader: string;
  103541. };
  103542. }
  103543. declare module BABYLON {
  103544. interface AbstractScene {
  103545. /**
  103546. * Return a the first highlight layer of the scene with a given name.
  103547. * @param name The name of the highlight layer to look for.
  103548. * @return The highlight layer if found otherwise null.
  103549. */
  103550. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  103551. }
  103552. /**
  103553. * Highlight layer options. This helps customizing the behaviour
  103554. * of the highlight layer.
  103555. */
  103556. export interface IHighlightLayerOptions {
  103557. /**
  103558. * Multiplication factor apply to the canvas size to compute the render target size
  103559. * used to generated the glowing objects (the smaller the faster).
  103560. */
  103561. mainTextureRatio: number;
  103562. /**
  103563. * Enforces a fixed size texture to ensure resize independant blur.
  103564. */
  103565. mainTextureFixedSize?: number;
  103566. /**
  103567. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  103568. * of the picture to blur (the smaller the faster).
  103569. */
  103570. blurTextureSizeRatio: number;
  103571. /**
  103572. * How big in texel of the blur texture is the vertical blur.
  103573. */
  103574. blurVerticalSize: number;
  103575. /**
  103576. * How big in texel of the blur texture is the horizontal blur.
  103577. */
  103578. blurHorizontalSize: number;
  103579. /**
  103580. * Alpha blending mode used to apply the blur. Default is combine.
  103581. */
  103582. alphaBlendingMode: number;
  103583. /**
  103584. * The camera attached to the layer.
  103585. */
  103586. camera: Nullable<Camera>;
  103587. /**
  103588. * Should we display highlight as a solid stroke?
  103589. */
  103590. isStroke?: boolean;
  103591. /**
  103592. * The rendering group to draw the layer in.
  103593. */
  103594. renderingGroupId: number;
  103595. }
  103596. /**
  103597. * The highlight layer Helps adding a glow effect around a mesh.
  103598. *
  103599. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103600. * glowy meshes to your scene.
  103601. *
  103602. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  103603. */
  103604. export class HighlightLayer extends EffectLayer {
  103605. name: string;
  103606. /**
  103607. * Effect Name of the highlight layer.
  103608. */
  103609. static readonly EffectName: string;
  103610. /**
  103611. * The neutral color used during the preparation of the glow effect.
  103612. * This is black by default as the blend operation is a blend operation.
  103613. */
  103614. static NeutralColor: Color4;
  103615. /**
  103616. * Stencil value used for glowing meshes.
  103617. */
  103618. static GlowingMeshStencilReference: number;
  103619. /**
  103620. * Stencil value used for the other meshes in the scene.
  103621. */
  103622. static NormalMeshStencilReference: number;
  103623. /**
  103624. * Specifies whether or not the inner glow is ACTIVE in the layer.
  103625. */
  103626. innerGlow: boolean;
  103627. /**
  103628. * Specifies whether or not the outer glow is ACTIVE in the layer.
  103629. */
  103630. outerGlow: boolean;
  103631. /**
  103632. * Specifies the horizontal size of the blur.
  103633. */
  103634. /**
  103635. * Gets the horizontal size of the blur.
  103636. */
  103637. blurHorizontalSize: number;
  103638. /**
  103639. * Specifies the vertical size of the blur.
  103640. */
  103641. /**
  103642. * Gets the vertical size of the blur.
  103643. */
  103644. blurVerticalSize: number;
  103645. /**
  103646. * An event triggered when the highlight layer is being blurred.
  103647. */
  103648. onBeforeBlurObservable: Observable<HighlightLayer>;
  103649. /**
  103650. * An event triggered when the highlight layer has been blurred.
  103651. */
  103652. onAfterBlurObservable: Observable<HighlightLayer>;
  103653. private _instanceGlowingMeshStencilReference;
  103654. private _options;
  103655. private _downSamplePostprocess;
  103656. private _horizontalBlurPostprocess;
  103657. private _verticalBlurPostprocess;
  103658. private _blurTexture;
  103659. private _meshes;
  103660. private _excludedMeshes;
  103661. /**
  103662. * Instantiates a new highlight Layer and references it to the scene..
  103663. * @param name The name of the layer
  103664. * @param scene The scene to use the layer in
  103665. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  103666. */
  103667. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  103668. /**
  103669. * Get the effect name of the layer.
  103670. * @return The effect name
  103671. */
  103672. getEffectName(): string;
  103673. /**
  103674. * Create the merge effect. This is the shader use to blit the information back
  103675. * to the main canvas at the end of the scene rendering.
  103676. */
  103677. protected _createMergeEffect(): Effect;
  103678. /**
  103679. * Creates the render target textures and post processes used in the highlight layer.
  103680. */
  103681. protected _createTextureAndPostProcesses(): void;
  103682. /**
  103683. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103684. */
  103685. needStencil(): boolean;
  103686. /**
  103687. * Checks for the readiness of the element composing the layer.
  103688. * @param subMesh the mesh to check for
  103689. * @param useInstances specify wether or not to use instances to render the mesh
  103690. * @param emissiveTexture the associated emissive texture used to generate the glow
  103691. * @return true if ready otherwise, false
  103692. */
  103693. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103694. /**
  103695. * Implementation specific of rendering the generating effect on the main canvas.
  103696. * @param effect The effect used to render through
  103697. */
  103698. protected _internalRender(effect: Effect): void;
  103699. /**
  103700. * Returns true if the layer contains information to display, otherwise false.
  103701. */
  103702. shouldRender(): boolean;
  103703. /**
  103704. * Returns true if the mesh should render, otherwise false.
  103705. * @param mesh The mesh to render
  103706. * @returns true if it should render otherwise false
  103707. */
  103708. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103709. /**
  103710. * Sets the required values for both the emissive texture and and the main color.
  103711. */
  103712. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103713. /**
  103714. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  103715. * @param mesh The mesh to exclude from the highlight layer
  103716. */
  103717. addExcludedMesh(mesh: Mesh): void;
  103718. /**
  103719. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  103720. * @param mesh The mesh to highlight
  103721. */
  103722. removeExcludedMesh(mesh: Mesh): void;
  103723. /**
  103724. * Determine if a given mesh will be highlighted by the current HighlightLayer
  103725. * @param mesh mesh to test
  103726. * @returns true if the mesh will be highlighted by the current HighlightLayer
  103727. */
  103728. hasMesh(mesh: AbstractMesh): boolean;
  103729. /**
  103730. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  103731. * @param mesh The mesh to highlight
  103732. * @param color The color of the highlight
  103733. * @param glowEmissiveOnly Extract the glow from the emissive texture
  103734. */
  103735. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  103736. /**
  103737. * Remove a mesh from the highlight layer in order to make it stop glowing.
  103738. * @param mesh The mesh to highlight
  103739. */
  103740. removeMesh(mesh: Mesh): void;
  103741. /**
  103742. * Force the stencil to the normal expected value for none glowing parts
  103743. */
  103744. private _defaultStencilReference;
  103745. /**
  103746. * Free any resources and references associated to a mesh.
  103747. * Internal use
  103748. * @param mesh The mesh to free.
  103749. * @hidden
  103750. */
  103751. _disposeMesh(mesh: Mesh): void;
  103752. /**
  103753. * Dispose the highlight layer and free resources.
  103754. */
  103755. dispose(): void;
  103756. /**
  103757. * Gets the class name of the effect layer
  103758. * @returns the string with the class name of the effect layer
  103759. */
  103760. getClassName(): string;
  103761. /**
  103762. * Serializes this Highlight layer
  103763. * @returns a serialized Highlight layer object
  103764. */
  103765. serialize(): any;
  103766. /**
  103767. * Creates a Highlight layer from parsed Highlight layer data
  103768. * @param parsedHightlightLayer defines the Highlight layer data
  103769. * @param scene defines the current scene
  103770. * @param rootUrl defines the root URL containing the Highlight layer information
  103771. * @returns a parsed Highlight layer
  103772. */
  103773. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  103774. }
  103775. }
  103776. declare module BABYLON {
  103777. /** @hidden */
  103778. export var lensFlarePixelShader: {
  103779. name: string;
  103780. shader: string;
  103781. };
  103782. }
  103783. declare module BABYLON {
  103784. /** @hidden */
  103785. export var lensFlareVertexShader: {
  103786. name: string;
  103787. shader: string;
  103788. };
  103789. }
  103790. declare module BABYLON {
  103791. /**
  103792. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103793. * It is usually composed of several `lensFlare`.
  103794. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103795. */
  103796. export class LensFlareSystem {
  103797. /**
  103798. * Define the name of the lens flare system
  103799. */
  103800. name: string;
  103801. /**
  103802. * List of lens flares used in this system.
  103803. */
  103804. lensFlares: LensFlare[];
  103805. /**
  103806. * Define a limit from the border the lens flare can be visible.
  103807. */
  103808. borderLimit: number;
  103809. /**
  103810. * Define a viewport border we do not want to see the lens flare in.
  103811. */
  103812. viewportBorder: number;
  103813. /**
  103814. * Define a predicate which could limit the list of meshes able to occlude the effect.
  103815. */
  103816. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103817. /**
  103818. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  103819. */
  103820. layerMask: number;
  103821. /**
  103822. * Define the id of the lens flare system in the scene.
  103823. * (equal to name by default)
  103824. */
  103825. id: string;
  103826. private _scene;
  103827. private _emitter;
  103828. private _vertexBuffers;
  103829. private _indexBuffer;
  103830. private _effect;
  103831. private _positionX;
  103832. private _positionY;
  103833. private _isEnabled;
  103834. /** @hidden */
  103835. static _SceneComponentInitialization: (scene: Scene) => void;
  103836. /**
  103837. * Instantiates a lens flare system.
  103838. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103839. * It is usually composed of several `lensFlare`.
  103840. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103841. * @param name Define the name of the lens flare system in the scene
  103842. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  103843. * @param scene Define the scene the lens flare system belongs to
  103844. */
  103845. constructor(
  103846. /**
  103847. * Define the name of the lens flare system
  103848. */
  103849. name: string, emitter: any, scene: Scene);
  103850. /**
  103851. * Define if the lens flare system is enabled.
  103852. */
  103853. isEnabled: boolean;
  103854. /**
  103855. * Get the scene the effects belongs to.
  103856. * @returns the scene holding the lens flare system
  103857. */
  103858. getScene(): Scene;
  103859. /**
  103860. * Get the emitter of the lens flare system.
  103861. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103862. * @returns the emitter of the lens flare system
  103863. */
  103864. getEmitter(): any;
  103865. /**
  103866. * Set the emitter of the lens flare system.
  103867. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103868. * @param newEmitter Define the new emitter of the system
  103869. */
  103870. setEmitter(newEmitter: any): void;
  103871. /**
  103872. * Get the lens flare system emitter position.
  103873. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  103874. * @returns the position
  103875. */
  103876. getEmitterPosition(): Vector3;
  103877. /**
  103878. * @hidden
  103879. */
  103880. computeEffectivePosition(globalViewport: Viewport): boolean;
  103881. /** @hidden */
  103882. _isVisible(): boolean;
  103883. /**
  103884. * @hidden
  103885. */
  103886. render(): boolean;
  103887. /**
  103888. * Dispose and release the lens flare with its associated resources.
  103889. */
  103890. dispose(): void;
  103891. /**
  103892. * Parse a lens flare system from a JSON repressentation
  103893. * @param parsedLensFlareSystem Define the JSON to parse
  103894. * @param scene Define the scene the parsed system should be instantiated in
  103895. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  103896. * @returns the parsed system
  103897. */
  103898. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  103899. /**
  103900. * Serialize the current Lens Flare System into a JSON representation.
  103901. * @returns the serialized JSON
  103902. */
  103903. serialize(): any;
  103904. }
  103905. }
  103906. declare module BABYLON {
  103907. /**
  103908. * This represents one of the lens effect in a `lensFlareSystem`.
  103909. * It controls one of the indiviual texture used in the effect.
  103910. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103911. */
  103912. export class LensFlare {
  103913. /**
  103914. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103915. */
  103916. size: number;
  103917. /**
  103918. * 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.
  103919. */
  103920. position: number;
  103921. /**
  103922. * Define the lens color.
  103923. */
  103924. color: Color3;
  103925. /**
  103926. * Define the lens texture.
  103927. */
  103928. texture: Nullable<Texture>;
  103929. /**
  103930. * Define the alpha mode to render this particular lens.
  103931. */
  103932. alphaMode: number;
  103933. private _system;
  103934. /**
  103935. * Creates a new Lens Flare.
  103936. * This represents one of the lens effect in a `lensFlareSystem`.
  103937. * It controls one of the indiviual texture used in the effect.
  103938. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103939. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  103940. * @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.
  103941. * @param color Define the lens color
  103942. * @param imgUrl Define the lens texture url
  103943. * @param system Define the `lensFlareSystem` this flare is part of
  103944. * @returns The newly created Lens Flare
  103945. */
  103946. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  103947. /**
  103948. * Instantiates a new Lens Flare.
  103949. * This represents one of the lens effect in a `lensFlareSystem`.
  103950. * It controls one of the indiviual texture used in the effect.
  103951. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103952. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  103953. * @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.
  103954. * @param color Define the lens color
  103955. * @param imgUrl Define the lens texture url
  103956. * @param system Define the `lensFlareSystem` this flare is part of
  103957. */
  103958. constructor(
  103959. /**
  103960. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103961. */
  103962. size: number,
  103963. /**
  103964. * 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.
  103965. */
  103966. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  103967. /**
  103968. * Dispose and release the lens flare with its associated resources.
  103969. */
  103970. dispose(): void;
  103971. }
  103972. }
  103973. declare module BABYLON {
  103974. interface AbstractScene {
  103975. /**
  103976. * The list of lens flare system added to the scene
  103977. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103978. */
  103979. lensFlareSystems: Array<LensFlareSystem>;
  103980. /**
  103981. * Removes the given lens flare system from this scene.
  103982. * @param toRemove The lens flare system to remove
  103983. * @returns The index of the removed lens flare system
  103984. */
  103985. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  103986. /**
  103987. * Adds the given lens flare system to this scene
  103988. * @param newLensFlareSystem The lens flare system to add
  103989. */
  103990. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  103991. /**
  103992. * Gets a lens flare system using its name
  103993. * @param name defines the name to look for
  103994. * @returns the lens flare system or null if not found
  103995. */
  103996. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  103997. /**
  103998. * Gets a lens flare system using its id
  103999. * @param id defines the id to look for
  104000. * @returns the lens flare system or null if not found
  104001. */
  104002. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  104003. }
  104004. /**
  104005. * Defines the lens flare scene component responsible to manage any lens flares
  104006. * in a given scene.
  104007. */
  104008. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  104009. /**
  104010. * The component name helpfull to identify the component in the list of scene components.
  104011. */
  104012. readonly name: string;
  104013. /**
  104014. * The scene the component belongs to.
  104015. */
  104016. scene: Scene;
  104017. /**
  104018. * Creates a new instance of the component for the given scene
  104019. * @param scene Defines the scene to register the component in
  104020. */
  104021. constructor(scene: Scene);
  104022. /**
  104023. * Registers the component in a given scene
  104024. */
  104025. register(): void;
  104026. /**
  104027. * Rebuilds the elements related to this component in case of
  104028. * context lost for instance.
  104029. */
  104030. rebuild(): void;
  104031. /**
  104032. * Adds all the element from the container to the scene
  104033. * @param container the container holding the elements
  104034. */
  104035. addFromContainer(container: AbstractScene): void;
  104036. /**
  104037. * Removes all the elements in the container from the scene
  104038. * @param container contains the elements to remove
  104039. */
  104040. removeFromContainer(container: AbstractScene): void;
  104041. /**
  104042. * Serializes the component data to the specified json object
  104043. * @param serializationObject The object to serialize to
  104044. */
  104045. serialize(serializationObject: any): void;
  104046. /**
  104047. * Disposes the component and the associated ressources.
  104048. */
  104049. dispose(): void;
  104050. private _draw;
  104051. }
  104052. }
  104053. declare module BABYLON {
  104054. /**
  104055. * Defines the shadow generator component responsible to manage any shadow generators
  104056. * in a given scene.
  104057. */
  104058. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  104059. /**
  104060. * The component name helpfull to identify the component in the list of scene components.
  104061. */
  104062. readonly name: string;
  104063. /**
  104064. * The scene the component belongs to.
  104065. */
  104066. scene: Scene;
  104067. /**
  104068. * Creates a new instance of the component for the given scene
  104069. * @param scene Defines the scene to register the component in
  104070. */
  104071. constructor(scene: Scene);
  104072. /**
  104073. * Registers the component in a given scene
  104074. */
  104075. register(): void;
  104076. /**
  104077. * Rebuilds the elements related to this component in case of
  104078. * context lost for instance.
  104079. */
  104080. rebuild(): void;
  104081. /**
  104082. * Serializes the component data to the specified json object
  104083. * @param serializationObject The object to serialize to
  104084. */
  104085. serialize(serializationObject: any): void;
  104086. /**
  104087. * Adds all the element from the container to the scene
  104088. * @param container the container holding the elements
  104089. */
  104090. addFromContainer(container: AbstractScene): void;
  104091. /**
  104092. * Removes all the elements in the container from the scene
  104093. * @param container contains the elements to remove
  104094. */
  104095. removeFromContainer(container: AbstractScene): void;
  104096. /**
  104097. * Rebuilds the elements related to this component in case of
  104098. * context lost for instance.
  104099. */
  104100. dispose(): void;
  104101. private _gatherRenderTargets;
  104102. }
  104103. }
  104104. declare module BABYLON {
  104105. /**
  104106. * A directional light is defined by a direction (what a surprise!).
  104107. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  104108. * 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.
  104109. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104110. */
  104111. export class DirectionalLight extends ShadowLight {
  104112. private _shadowFrustumSize;
  104113. /**
  104114. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  104115. */
  104116. /**
  104117. * Specifies a fix frustum size for the shadow generation.
  104118. */
  104119. shadowFrustumSize: number;
  104120. private _shadowOrthoScale;
  104121. /**
  104122. * Gets the shadow projection scale against the optimal computed one.
  104123. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104124. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104125. */
  104126. /**
  104127. * Sets the shadow projection scale against the optimal computed one.
  104128. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104129. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104130. */
  104131. shadowOrthoScale: number;
  104132. /**
  104133. * Automatically compute the projection matrix to best fit (including all the casters)
  104134. * on each frame.
  104135. */
  104136. autoUpdateExtends: boolean;
  104137. private _orthoLeft;
  104138. private _orthoRight;
  104139. private _orthoTop;
  104140. private _orthoBottom;
  104141. /**
  104142. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  104143. * The directional light is emitted from everywhere in the given direction.
  104144. * It can cast shadows.
  104145. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104146. * @param name The friendly name of the light
  104147. * @param direction The direction of the light
  104148. * @param scene The scene the light belongs to
  104149. */
  104150. constructor(name: string, direction: Vector3, scene: Scene);
  104151. /**
  104152. * Returns the string "DirectionalLight".
  104153. * @return The class name
  104154. */
  104155. getClassName(): string;
  104156. /**
  104157. * Returns the integer 1.
  104158. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104159. */
  104160. getTypeID(): number;
  104161. /**
  104162. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  104163. * Returns the DirectionalLight Shadow projection matrix.
  104164. */
  104165. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104166. /**
  104167. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  104168. * Returns the DirectionalLight Shadow projection matrix.
  104169. */
  104170. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  104171. /**
  104172. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  104173. * Returns the DirectionalLight Shadow projection matrix.
  104174. */
  104175. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104176. protected _buildUniformLayout(): void;
  104177. /**
  104178. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  104179. * @param effect The effect to update
  104180. * @param lightIndex The index of the light in the effect to update
  104181. * @returns The directional light
  104182. */
  104183. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  104184. /**
  104185. * Gets the minZ used for shadow according to both the scene and the light.
  104186. *
  104187. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104188. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104189. * @param activeCamera The camera we are returning the min for
  104190. * @returns the depth min z
  104191. */
  104192. getDepthMinZ(activeCamera: Camera): number;
  104193. /**
  104194. * Gets the maxZ used for shadow according to both the scene and the light.
  104195. *
  104196. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104197. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104198. * @param activeCamera The camera we are returning the max for
  104199. * @returns the depth max z
  104200. */
  104201. getDepthMaxZ(activeCamera: Camera): number;
  104202. /**
  104203. * Prepares the list of defines specific to the light type.
  104204. * @param defines the list of defines
  104205. * @param lightIndex defines the index of the light for the effect
  104206. */
  104207. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104208. }
  104209. }
  104210. declare module BABYLON {
  104211. /**
  104212. * A point light is a light defined by an unique point in world space.
  104213. * The light is emitted in every direction from this point.
  104214. * A good example of a point light is a standard light bulb.
  104215. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104216. */
  104217. export class PointLight extends ShadowLight {
  104218. private _shadowAngle;
  104219. /**
  104220. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104221. * This specifies what angle the shadow will use to be created.
  104222. *
  104223. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104224. */
  104225. /**
  104226. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104227. * This specifies what angle the shadow will use to be created.
  104228. *
  104229. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104230. */
  104231. shadowAngle: number;
  104232. /**
  104233. * Gets the direction if it has been set.
  104234. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104235. */
  104236. /**
  104237. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104238. */
  104239. direction: Vector3;
  104240. /**
  104241. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  104242. * A PointLight emits the light in every direction.
  104243. * It can cast shadows.
  104244. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  104245. * ```javascript
  104246. * var pointLight = new PointLight("pl", camera.position, scene);
  104247. * ```
  104248. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104249. * @param name The light friendly name
  104250. * @param position The position of the point light in the scene
  104251. * @param scene The scene the lights belongs to
  104252. */
  104253. constructor(name: string, position: Vector3, scene: Scene);
  104254. /**
  104255. * Returns the string "PointLight"
  104256. * @returns the class name
  104257. */
  104258. getClassName(): string;
  104259. /**
  104260. * Returns the integer 0.
  104261. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104262. */
  104263. getTypeID(): number;
  104264. /**
  104265. * Specifies wether or not the shadowmap should be a cube texture.
  104266. * @returns true if the shadowmap needs to be a cube texture.
  104267. */
  104268. needCube(): boolean;
  104269. /**
  104270. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  104271. * @param faceIndex The index of the face we are computed the direction to generate shadow
  104272. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  104273. */
  104274. getShadowDirection(faceIndex?: number): Vector3;
  104275. /**
  104276. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  104277. * - fov = PI / 2
  104278. * - aspect ratio : 1.0
  104279. * - z-near and far equal to the active camera minZ and maxZ.
  104280. * Returns the PointLight.
  104281. */
  104282. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104283. protected _buildUniformLayout(): void;
  104284. /**
  104285. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  104286. * @param effect The effect to update
  104287. * @param lightIndex The index of the light in the effect to update
  104288. * @returns The point light
  104289. */
  104290. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  104291. /**
  104292. * Prepares the list of defines specific to the light type.
  104293. * @param defines the list of defines
  104294. * @param lightIndex defines the index of the light for the effect
  104295. */
  104296. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104297. }
  104298. }
  104299. declare module BABYLON {
  104300. /**
  104301. * A spot light is defined by a position, a direction, an angle, and an exponent.
  104302. * These values define a cone of light starting from the position, emitting toward the direction.
  104303. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  104304. * and the exponent defines the speed of the decay of the light with distance (reach).
  104305. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104306. */
  104307. export class SpotLight extends ShadowLight {
  104308. private _angle;
  104309. private _innerAngle;
  104310. private _cosHalfAngle;
  104311. private _lightAngleScale;
  104312. private _lightAngleOffset;
  104313. /**
  104314. * Gets the cone angle of the spot light in Radians.
  104315. */
  104316. /**
  104317. * Sets the cone angle of the spot light in Radians.
  104318. */
  104319. angle: number;
  104320. /**
  104321. * Only used in gltf falloff mode, this defines the angle where
  104322. * the directional falloff will start before cutting at angle which could be seen
  104323. * as outer angle.
  104324. */
  104325. /**
  104326. * Only used in gltf falloff mode, this defines the angle where
  104327. * the directional falloff will start before cutting at angle which could be seen
  104328. * as outer angle.
  104329. */
  104330. innerAngle: number;
  104331. private _shadowAngleScale;
  104332. /**
  104333. * Allows scaling the angle of the light for shadow generation only.
  104334. */
  104335. /**
  104336. * Allows scaling the angle of the light for shadow generation only.
  104337. */
  104338. shadowAngleScale: number;
  104339. /**
  104340. * The light decay speed with the distance from the emission spot.
  104341. */
  104342. exponent: number;
  104343. private _projectionTextureMatrix;
  104344. /**
  104345. * Allows reading the projecton texture
  104346. */
  104347. readonly projectionTextureMatrix: Matrix;
  104348. protected _projectionTextureLightNear: number;
  104349. /**
  104350. * Gets the near clip of the Spotlight for texture projection.
  104351. */
  104352. /**
  104353. * Sets the near clip of the Spotlight for texture projection.
  104354. */
  104355. projectionTextureLightNear: number;
  104356. protected _projectionTextureLightFar: number;
  104357. /**
  104358. * Gets the far clip of the Spotlight for texture projection.
  104359. */
  104360. /**
  104361. * Sets the far clip of the Spotlight for texture projection.
  104362. */
  104363. projectionTextureLightFar: number;
  104364. protected _projectionTextureUpDirection: Vector3;
  104365. /**
  104366. * Gets the Up vector of the Spotlight for texture projection.
  104367. */
  104368. /**
  104369. * Sets the Up vector of the Spotlight for texture projection.
  104370. */
  104371. projectionTextureUpDirection: Vector3;
  104372. private _projectionTexture;
  104373. /**
  104374. * Gets the projection texture of the light.
  104375. */
  104376. /**
  104377. * Sets the projection texture of the light.
  104378. */
  104379. projectionTexture: Nullable<BaseTexture>;
  104380. private _projectionTextureViewLightDirty;
  104381. private _projectionTextureProjectionLightDirty;
  104382. private _projectionTextureDirty;
  104383. private _projectionTextureViewTargetVector;
  104384. private _projectionTextureViewLightMatrix;
  104385. private _projectionTextureProjectionLightMatrix;
  104386. private _projectionTextureScalingMatrix;
  104387. /**
  104388. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  104389. * It can cast shadows.
  104390. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104391. * @param name The light friendly name
  104392. * @param position The position of the spot light in the scene
  104393. * @param direction The direction of the light in the scene
  104394. * @param angle The cone angle of the light in Radians
  104395. * @param exponent The light decay speed with the distance from the emission spot
  104396. * @param scene The scene the lights belongs to
  104397. */
  104398. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  104399. /**
  104400. * Returns the string "SpotLight".
  104401. * @returns the class name
  104402. */
  104403. getClassName(): string;
  104404. /**
  104405. * Returns the integer 2.
  104406. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104407. */
  104408. getTypeID(): number;
  104409. /**
  104410. * Overrides the direction setter to recompute the projection texture view light Matrix.
  104411. */
  104412. protected _setDirection(value: Vector3): void;
  104413. /**
  104414. * Overrides the position setter to recompute the projection texture view light Matrix.
  104415. */
  104416. protected _setPosition(value: Vector3): void;
  104417. /**
  104418. * 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.
  104419. * Returns the SpotLight.
  104420. */
  104421. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104422. protected _computeProjectionTextureViewLightMatrix(): void;
  104423. protected _computeProjectionTextureProjectionLightMatrix(): void;
  104424. /**
  104425. * Main function for light texture projection matrix computing.
  104426. */
  104427. protected _computeProjectionTextureMatrix(): void;
  104428. protected _buildUniformLayout(): void;
  104429. private _computeAngleValues;
  104430. /**
  104431. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  104432. * @param effect The effect to update
  104433. * @param lightIndex The index of the light in the effect to update
  104434. * @returns The spot light
  104435. */
  104436. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  104437. /**
  104438. * Disposes the light and the associated resources.
  104439. */
  104440. dispose(): void;
  104441. /**
  104442. * Prepares the list of defines specific to the light type.
  104443. * @param defines the list of defines
  104444. * @param lightIndex defines the index of the light for the effect
  104445. */
  104446. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104447. }
  104448. }
  104449. declare module BABYLON {
  104450. /**
  104451. * Header information of HDR texture files.
  104452. */
  104453. export interface HDRInfo {
  104454. /**
  104455. * The height of the texture in pixels.
  104456. */
  104457. height: number;
  104458. /**
  104459. * The width of the texture in pixels.
  104460. */
  104461. width: number;
  104462. /**
  104463. * The index of the beginning of the data in the binary file.
  104464. */
  104465. dataPosition: number;
  104466. }
  104467. /**
  104468. * This groups tools to convert HDR texture to native colors array.
  104469. */
  104470. export class HDRTools {
  104471. private static Ldexp;
  104472. private static Rgbe2float;
  104473. private static readStringLine;
  104474. /**
  104475. * Reads header information from an RGBE texture stored in a native array.
  104476. * More information on this format are available here:
  104477. * https://en.wikipedia.org/wiki/RGBE_image_format
  104478. *
  104479. * @param uint8array The binary file stored in native array.
  104480. * @return The header information.
  104481. */
  104482. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  104483. /**
  104484. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  104485. * This RGBE texture needs to store the information as a panorama.
  104486. *
  104487. * More information on this format are available here:
  104488. * https://en.wikipedia.org/wiki/RGBE_image_format
  104489. *
  104490. * @param buffer The binary file stored in an array buffer.
  104491. * @param size The expected size of the extracted cubemap.
  104492. * @return The Cube Map information.
  104493. */
  104494. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  104495. /**
  104496. * Returns the pixels data extracted from an RGBE texture.
  104497. * This pixels will be stored left to right up to down in the R G B order in one array.
  104498. *
  104499. * More information on this format are available here:
  104500. * https://en.wikipedia.org/wiki/RGBE_image_format
  104501. *
  104502. * @param uint8array The binary file stored in an array buffer.
  104503. * @param hdrInfo The header information of the file.
  104504. * @return The pixels data in RGB right to left up to down order.
  104505. */
  104506. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  104507. private static RGBE_ReadPixels_RLE;
  104508. }
  104509. }
  104510. declare module BABYLON {
  104511. /**
  104512. * This represents a texture coming from an HDR input.
  104513. *
  104514. * The only supported format is currently panorama picture stored in RGBE format.
  104515. * Example of such files can be found on HDRLib: http://hdrlib.com/
  104516. */
  104517. export class HDRCubeTexture extends BaseTexture {
  104518. private static _facesMapping;
  104519. private _generateHarmonics;
  104520. private _noMipmap;
  104521. private _textureMatrix;
  104522. private _size;
  104523. private _onLoad;
  104524. private _onError;
  104525. /**
  104526. * The texture URL.
  104527. */
  104528. url: string;
  104529. /**
  104530. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  104531. */
  104532. coordinatesMode: number;
  104533. protected _isBlocking: boolean;
  104534. /**
  104535. * Sets wether or not the texture is blocking during loading.
  104536. */
  104537. /**
  104538. * Gets wether or not the texture is blocking during loading.
  104539. */
  104540. isBlocking: boolean;
  104541. protected _rotationY: number;
  104542. /**
  104543. * Sets texture matrix rotation angle around Y axis in radians.
  104544. */
  104545. /**
  104546. * Gets texture matrix rotation angle around Y axis radians.
  104547. */
  104548. rotationY: number;
  104549. /**
  104550. * Gets or sets the center of the bounding box associated with the cube texture
  104551. * It must define where the camera used to render the texture was set
  104552. */
  104553. boundingBoxPosition: Vector3;
  104554. private _boundingBoxSize;
  104555. /**
  104556. * Gets or sets the size of the bounding box associated with the cube texture
  104557. * When defined, the cubemap will switch to local mode
  104558. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104559. * @example https://www.babylonjs-playground.com/#RNASML
  104560. */
  104561. boundingBoxSize: Vector3;
  104562. /**
  104563. * Instantiates an HDRTexture from the following parameters.
  104564. *
  104565. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  104566. * @param scene The scene the texture will be used in
  104567. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  104568. * @param noMipmap Forces to not generate the mipmap if true
  104569. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  104570. * @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)
  104571. * @param reserved Reserved flag for internal use.
  104572. */
  104573. 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>);
  104574. /**
  104575. * Get the current class name of the texture useful for serialization or dynamic coding.
  104576. * @returns "HDRCubeTexture"
  104577. */
  104578. getClassName(): string;
  104579. /**
  104580. * Occurs when the file is raw .hdr file.
  104581. */
  104582. private loadTexture;
  104583. clone(): HDRCubeTexture;
  104584. delayLoad(): void;
  104585. /**
  104586. * Get the texture reflection matrix used to rotate/transform the reflection.
  104587. * @returns the reflection matrix
  104588. */
  104589. getReflectionTextureMatrix(): Matrix;
  104590. /**
  104591. * Set the texture reflection matrix used to rotate/transform the reflection.
  104592. * @param value Define the reflection matrix to set
  104593. */
  104594. setReflectionTextureMatrix(value: Matrix): void;
  104595. /**
  104596. * Parses a JSON representation of an HDR Texture in order to create the texture
  104597. * @param parsedTexture Define the JSON representation
  104598. * @param scene Define the scene the texture should be created in
  104599. * @param rootUrl Define the root url in case we need to load relative dependencies
  104600. * @returns the newly created texture after parsing
  104601. */
  104602. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  104603. serialize(): any;
  104604. }
  104605. }
  104606. declare module BABYLON {
  104607. /**
  104608. * Class used to control physics engine
  104609. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104610. */
  104611. export class PhysicsEngine implements IPhysicsEngine {
  104612. private _physicsPlugin;
  104613. /**
  104614. * Global value used to control the smallest number supported by the simulation
  104615. */
  104616. static Epsilon: number;
  104617. private _impostors;
  104618. private _joints;
  104619. /**
  104620. * Gets the gravity vector used by the simulation
  104621. */
  104622. gravity: Vector3;
  104623. /**
  104624. * Factory used to create the default physics plugin.
  104625. * @returns The default physics plugin
  104626. */
  104627. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  104628. /**
  104629. * Creates a new Physics Engine
  104630. * @param gravity defines the gravity vector used by the simulation
  104631. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  104632. */
  104633. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  104634. /**
  104635. * Sets the gravity vector used by the simulation
  104636. * @param gravity defines the gravity vector to use
  104637. */
  104638. setGravity(gravity: Vector3): void;
  104639. /**
  104640. * Set the time step of the physics engine.
  104641. * Default is 1/60.
  104642. * To slow it down, enter 1/600 for example.
  104643. * To speed it up, 1/30
  104644. * @param newTimeStep defines the new timestep to apply to this world.
  104645. */
  104646. setTimeStep(newTimeStep?: number): void;
  104647. /**
  104648. * Get the time step of the physics engine.
  104649. * @returns the current time step
  104650. */
  104651. getTimeStep(): number;
  104652. /**
  104653. * Release all resources
  104654. */
  104655. dispose(): void;
  104656. /**
  104657. * Gets the name of the current physics plugin
  104658. * @returns the name of the plugin
  104659. */
  104660. getPhysicsPluginName(): string;
  104661. /**
  104662. * Adding a new impostor for the impostor tracking.
  104663. * This will be done by the impostor itself.
  104664. * @param impostor the impostor to add
  104665. */
  104666. addImpostor(impostor: PhysicsImpostor): void;
  104667. /**
  104668. * Remove an impostor from the engine.
  104669. * This impostor and its mesh will not longer be updated by the physics engine.
  104670. * @param impostor the impostor to remove
  104671. */
  104672. removeImpostor(impostor: PhysicsImpostor): void;
  104673. /**
  104674. * Add a joint to the physics engine
  104675. * @param mainImpostor defines the main impostor to which the joint is added.
  104676. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104677. * @param joint defines the joint that will connect both impostors.
  104678. */
  104679. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104680. /**
  104681. * Removes a joint from the simulation
  104682. * @param mainImpostor defines the impostor used with the joint
  104683. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104684. * @param joint defines the joint to remove
  104685. */
  104686. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104687. /**
  104688. * Called by the scene. No need to call it.
  104689. * @param delta defines the timespam between frames
  104690. */
  104691. _step(delta: number): void;
  104692. /**
  104693. * Gets the current plugin used to run the simulation
  104694. * @returns current plugin
  104695. */
  104696. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104697. /**
  104698. * Gets the list of physic impostors
  104699. * @returns an array of PhysicsImpostor
  104700. */
  104701. getImpostors(): Array<PhysicsImpostor>;
  104702. /**
  104703. * Gets the impostor for a physics enabled object
  104704. * @param object defines the object impersonated by the impostor
  104705. * @returns the PhysicsImpostor or null if not found
  104706. */
  104707. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104708. /**
  104709. * Gets the impostor for a physics body object
  104710. * @param body defines physics body used by the impostor
  104711. * @returns the PhysicsImpostor or null if not found
  104712. */
  104713. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104714. }
  104715. }
  104716. declare module BABYLON {
  104717. /** @hidden */
  104718. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  104719. private _useDeltaForWorldStep;
  104720. world: any;
  104721. name: string;
  104722. private _physicsMaterials;
  104723. private _fixedTimeStep;
  104724. BJSCANNON: any;
  104725. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  104726. setGravity(gravity: Vector3): void;
  104727. setTimeStep(timeStep: number): void;
  104728. getTimeStep(): number;
  104729. executeStep(delta: number): void;
  104730. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104731. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104732. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104733. private _processChildMeshes;
  104734. removePhysicsBody(impostor: PhysicsImpostor): void;
  104735. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104736. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104737. private _addMaterial;
  104738. private _checkWithEpsilon;
  104739. private _createShape;
  104740. private _createHeightmap;
  104741. private _minus90X;
  104742. private _plus90X;
  104743. private _tmpPosition;
  104744. private _tmpDeltaPosition;
  104745. private _tmpUnityRotation;
  104746. private _updatePhysicsBodyTransformation;
  104747. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104748. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104749. isSupported(): boolean;
  104750. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104751. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104752. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104753. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104754. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104755. getBodyMass(impostor: PhysicsImpostor): number;
  104756. getBodyFriction(impostor: PhysicsImpostor): number;
  104757. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104758. getBodyRestitution(impostor: PhysicsImpostor): number;
  104759. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104760. sleepBody(impostor: PhysicsImpostor): void;
  104761. wakeUpBody(impostor: PhysicsImpostor): void;
  104762. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  104763. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  104764. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  104765. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104766. getRadius(impostor: PhysicsImpostor): number;
  104767. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104768. dispose(): void;
  104769. private _extendNamespace;
  104770. }
  104771. }
  104772. declare module BABYLON {
  104773. /** @hidden */
  104774. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  104775. world: any;
  104776. name: string;
  104777. BJSOIMO: any;
  104778. constructor(iterations?: number, oimoInjection?: any);
  104779. setGravity(gravity: Vector3): void;
  104780. setTimeStep(timeStep: number): void;
  104781. getTimeStep(): number;
  104782. private _tmpImpostorsArray;
  104783. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104784. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104785. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104786. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104787. private _tmpPositionVector;
  104788. removePhysicsBody(impostor: PhysicsImpostor): void;
  104789. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104790. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104791. isSupported(): boolean;
  104792. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104793. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104794. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104795. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104796. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104797. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104798. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104799. getBodyMass(impostor: PhysicsImpostor): number;
  104800. getBodyFriction(impostor: PhysicsImpostor): number;
  104801. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104802. getBodyRestitution(impostor: PhysicsImpostor): number;
  104803. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104804. sleepBody(impostor: PhysicsImpostor): void;
  104805. wakeUpBody(impostor: PhysicsImpostor): void;
  104806. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104807. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  104808. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104809. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104810. getRadius(impostor: PhysicsImpostor): number;
  104811. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104812. dispose(): void;
  104813. }
  104814. }
  104815. declare module BABYLON {
  104816. interface AbstractScene {
  104817. /**
  104818. * The list of reflection probes added to the scene
  104819. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104820. */
  104821. reflectionProbes: Array<ReflectionProbe>;
  104822. /**
  104823. * Removes the given reflection probe from this scene.
  104824. * @param toRemove The reflection probe to remove
  104825. * @returns The index of the removed reflection probe
  104826. */
  104827. removeReflectionProbe(toRemove: ReflectionProbe): number;
  104828. /**
  104829. * Adds the given reflection probe to this scene.
  104830. * @param newReflectionProbe The reflection probe to add
  104831. */
  104832. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  104833. }
  104834. /**
  104835. * Class used to generate realtime reflection / refraction cube textures
  104836. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104837. */
  104838. export class ReflectionProbe {
  104839. /** defines the name of the probe */
  104840. name: string;
  104841. private _scene;
  104842. private _renderTargetTexture;
  104843. private _projectionMatrix;
  104844. private _viewMatrix;
  104845. private _target;
  104846. private _add;
  104847. private _attachedMesh;
  104848. private _invertYAxis;
  104849. /** Gets or sets probe position (center of the cube map) */
  104850. position: Vector3;
  104851. /**
  104852. * Creates a new reflection probe
  104853. * @param name defines the name of the probe
  104854. * @param size defines the texture resolution (for each face)
  104855. * @param scene defines the hosting scene
  104856. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  104857. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  104858. */
  104859. constructor(
  104860. /** defines the name of the probe */
  104861. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  104862. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  104863. samples: number;
  104864. /** Gets or sets the refresh rate to use (on every frame by default) */
  104865. refreshRate: number;
  104866. /**
  104867. * Gets the hosting scene
  104868. * @returns a Scene
  104869. */
  104870. getScene(): Scene;
  104871. /** Gets the internal CubeTexture used to render to */
  104872. readonly cubeTexture: RenderTargetTexture;
  104873. /** Gets the list of meshes to render */
  104874. readonly renderList: Nullable<AbstractMesh[]>;
  104875. /**
  104876. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  104877. * @param mesh defines the mesh to attach to
  104878. */
  104879. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  104880. /**
  104881. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  104882. * @param renderingGroupId The rendering group id corresponding to its index
  104883. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104884. */
  104885. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104886. /**
  104887. * Clean all associated resources
  104888. */
  104889. dispose(): void;
  104890. /**
  104891. * Converts the reflection probe information to a readable string for debug purpose.
  104892. * @param fullDetails Supports for multiple levels of logging within scene loading
  104893. * @returns the human readable reflection probe info
  104894. */
  104895. toString(fullDetails?: boolean): string;
  104896. /**
  104897. * Get the class name of the relfection probe.
  104898. * @returns "ReflectionProbe"
  104899. */
  104900. getClassName(): string;
  104901. /**
  104902. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  104903. * @returns The JSON representation of the texture
  104904. */
  104905. serialize(): any;
  104906. /**
  104907. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  104908. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  104909. * @param scene Define the scene the parsed reflection probe should be instantiated in
  104910. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104911. * @returns The parsed reflection probe if successful
  104912. */
  104913. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  104914. }
  104915. }
  104916. declare module BABYLON {
  104917. /** @hidden */
  104918. export var _BabylonLoaderRegistered: boolean;
  104919. }
  104920. declare module BABYLON {
  104921. /**
  104922. * The Physically based simple base material of BJS.
  104923. *
  104924. * This enables better naming and convention enforcements on top of the pbrMaterial.
  104925. * It is used as the base class for both the specGloss and metalRough conventions.
  104926. */
  104927. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  104928. /**
  104929. * Number of Simultaneous lights allowed on the material.
  104930. */
  104931. maxSimultaneousLights: number;
  104932. /**
  104933. * If sets to true, disables all the lights affecting the material.
  104934. */
  104935. disableLighting: boolean;
  104936. /**
  104937. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  104938. */
  104939. environmentTexture: BaseTexture;
  104940. /**
  104941. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104942. */
  104943. invertNormalMapX: boolean;
  104944. /**
  104945. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104946. */
  104947. invertNormalMapY: boolean;
  104948. /**
  104949. * Normal map used in the model.
  104950. */
  104951. normalTexture: BaseTexture;
  104952. /**
  104953. * Emissivie color used to self-illuminate the model.
  104954. */
  104955. emissiveColor: Color3;
  104956. /**
  104957. * Emissivie texture used to self-illuminate the model.
  104958. */
  104959. emissiveTexture: BaseTexture;
  104960. /**
  104961. * Occlusion Channel Strenght.
  104962. */
  104963. occlusionStrength: number;
  104964. /**
  104965. * Occlusion Texture of the material (adding extra occlusion effects).
  104966. */
  104967. occlusionTexture: BaseTexture;
  104968. /**
  104969. * Defines the alpha limits in alpha test mode.
  104970. */
  104971. alphaCutOff: number;
  104972. /**
  104973. * Gets the current double sided mode.
  104974. */
  104975. /**
  104976. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104977. */
  104978. doubleSided: boolean;
  104979. /**
  104980. * Stores the pre-calculated light information of a mesh in a texture.
  104981. */
  104982. lightmapTexture: BaseTexture;
  104983. /**
  104984. * If true, the light map contains occlusion information instead of lighting info.
  104985. */
  104986. useLightmapAsShadowmap: boolean;
  104987. /**
  104988. * Instantiates a new PBRMaterial instance.
  104989. *
  104990. * @param name The material name
  104991. * @param scene The scene the material will be use in.
  104992. */
  104993. constructor(name: string, scene: Scene);
  104994. getClassName(): string;
  104995. }
  104996. }
  104997. declare module BABYLON {
  104998. /**
  104999. * The PBR material of BJS following the metal roughness convention.
  105000. *
  105001. * This fits to the PBR convention in the GLTF definition:
  105002. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  105003. */
  105004. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  105005. /**
  105006. * The base color has two different interpretations depending on the value of metalness.
  105007. * When the material is a metal, the base color is the specific measured reflectance value
  105008. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  105009. * of the material.
  105010. */
  105011. baseColor: Color3;
  105012. /**
  105013. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  105014. * well as opacity information in the alpha channel.
  105015. */
  105016. baseTexture: BaseTexture;
  105017. /**
  105018. * Specifies the metallic scalar value of the material.
  105019. * Can also be used to scale the metalness values of the metallic texture.
  105020. */
  105021. metallic: number;
  105022. /**
  105023. * Specifies the roughness scalar value of the material.
  105024. * Can also be used to scale the roughness values of the metallic texture.
  105025. */
  105026. roughness: number;
  105027. /**
  105028. * Texture containing both the metallic value in the B channel and the
  105029. * roughness value in the G channel to keep better precision.
  105030. */
  105031. metallicRoughnessTexture: BaseTexture;
  105032. /**
  105033. * Instantiates a new PBRMetalRoughnessMaterial instance.
  105034. *
  105035. * @param name The material name
  105036. * @param scene The scene the material will be use in.
  105037. */
  105038. constructor(name: string, scene: Scene);
  105039. /**
  105040. * Return the currrent class name of the material.
  105041. */
  105042. getClassName(): string;
  105043. /**
  105044. * Makes a duplicate of the current material.
  105045. * @param name - name to use for the new material.
  105046. */
  105047. clone(name: string): PBRMetallicRoughnessMaterial;
  105048. /**
  105049. * Serialize the material to a parsable JSON object.
  105050. */
  105051. serialize(): any;
  105052. /**
  105053. * Parses a JSON object correponding to the serialize function.
  105054. */
  105055. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  105056. }
  105057. }
  105058. declare module BABYLON {
  105059. /**
  105060. * The PBR material of BJS following the specular glossiness convention.
  105061. *
  105062. * This fits to the PBR convention in the GLTF definition:
  105063. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  105064. */
  105065. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  105066. /**
  105067. * Specifies the diffuse color of the material.
  105068. */
  105069. diffuseColor: Color3;
  105070. /**
  105071. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  105072. * channel.
  105073. */
  105074. diffuseTexture: BaseTexture;
  105075. /**
  105076. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  105077. */
  105078. specularColor: Color3;
  105079. /**
  105080. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  105081. */
  105082. glossiness: number;
  105083. /**
  105084. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  105085. */
  105086. specularGlossinessTexture: BaseTexture;
  105087. /**
  105088. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  105089. *
  105090. * @param name The material name
  105091. * @param scene The scene the material will be use in.
  105092. */
  105093. constructor(name: string, scene: Scene);
  105094. /**
  105095. * Return the currrent class name of the material.
  105096. */
  105097. getClassName(): string;
  105098. /**
  105099. * Makes a duplicate of the current material.
  105100. * @param name - name to use for the new material.
  105101. */
  105102. clone(name: string): PBRSpecularGlossinessMaterial;
  105103. /**
  105104. * Serialize the material to a parsable JSON object.
  105105. */
  105106. serialize(): any;
  105107. /**
  105108. * Parses a JSON object correponding to the serialize function.
  105109. */
  105110. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  105111. }
  105112. }
  105113. declare module BABYLON {
  105114. /**
  105115. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  105116. * It can help converting any input color in a desired output one. This can then be used to create effects
  105117. * from sepia, black and white to sixties or futuristic rendering...
  105118. *
  105119. * The only supported format is currently 3dl.
  105120. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  105121. */
  105122. export class ColorGradingTexture extends BaseTexture {
  105123. /**
  105124. * The current texture matrix. (will always be identity in color grading texture)
  105125. */
  105126. private _textureMatrix;
  105127. /**
  105128. * The texture URL.
  105129. */
  105130. url: string;
  105131. /**
  105132. * Empty line regex stored for GC.
  105133. */
  105134. private static _noneEmptyLineRegex;
  105135. private _engine;
  105136. /**
  105137. * Instantiates a ColorGradingTexture from the following parameters.
  105138. *
  105139. * @param url The location of the color gradind data (currently only supporting 3dl)
  105140. * @param scene The scene the texture will be used in
  105141. */
  105142. constructor(url: string, scene: Scene);
  105143. /**
  105144. * Returns the texture matrix used in most of the material.
  105145. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  105146. */
  105147. getTextureMatrix(): Matrix;
  105148. /**
  105149. * Occurs when the file being loaded is a .3dl LUT file.
  105150. */
  105151. private load3dlTexture;
  105152. /**
  105153. * Starts the loading process of the texture.
  105154. */
  105155. private loadTexture;
  105156. /**
  105157. * Clones the color gradind texture.
  105158. */
  105159. clone(): ColorGradingTexture;
  105160. /**
  105161. * Called during delayed load for textures.
  105162. */
  105163. delayLoad(): void;
  105164. /**
  105165. * Parses a color grading texture serialized by Babylon.
  105166. * @param parsedTexture The texture information being parsedTexture
  105167. * @param scene The scene to load the texture in
  105168. * @param rootUrl The root url of the data assets to load
  105169. * @return A color gradind texture
  105170. */
  105171. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  105172. /**
  105173. * Serializes the LUT texture to json format.
  105174. */
  105175. serialize(): any;
  105176. }
  105177. }
  105178. declare module BABYLON {
  105179. /**
  105180. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  105181. */
  105182. export class EquiRectangularCubeTexture extends BaseTexture {
  105183. /** The six faces of the cube. */
  105184. private static _FacesMapping;
  105185. private _noMipmap;
  105186. private _onLoad;
  105187. private _onError;
  105188. /** The size of the cubemap. */
  105189. private _size;
  105190. /** The buffer of the image. */
  105191. private _buffer;
  105192. /** The width of the input image. */
  105193. private _width;
  105194. /** The height of the input image. */
  105195. private _height;
  105196. /** The URL to the image. */
  105197. url: string;
  105198. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  105199. coordinatesMode: number;
  105200. /**
  105201. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  105202. * @param url The location of the image
  105203. * @param scene The scene the texture will be used in
  105204. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105205. * @param noMipmap Forces to not generate the mipmap if true
  105206. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  105207. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  105208. * @param onLoad — defines a callback called when texture is loaded
  105209. * @param onError — defines a callback called if there is an error
  105210. */
  105211. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  105212. /**
  105213. * Load the image data, by putting the image on a canvas and extracting its buffer.
  105214. */
  105215. private loadImage;
  105216. /**
  105217. * Convert the image buffer into a cubemap and create a CubeTexture.
  105218. */
  105219. private loadTexture;
  105220. /**
  105221. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  105222. * @param buffer The ArrayBuffer that should be converted.
  105223. * @returns The buffer as Float32Array.
  105224. */
  105225. private getFloat32ArrayFromArrayBuffer;
  105226. /**
  105227. * Get the current class name of the texture useful for serialization or dynamic coding.
  105228. * @returns "EquiRectangularCubeTexture"
  105229. */
  105230. getClassName(): string;
  105231. /**
  105232. * Create a clone of the current EquiRectangularCubeTexture and return it.
  105233. * @returns A clone of the current EquiRectangularCubeTexture.
  105234. */
  105235. clone(): EquiRectangularCubeTexture;
  105236. }
  105237. }
  105238. declare module BABYLON {
  105239. /**
  105240. * Based on jsTGALoader - Javascript loader for TGA file
  105241. * By Vincent Thibault
  105242. * @see http://blog.robrowser.com/javascript-tga-loader.html
  105243. */
  105244. export class TGATools {
  105245. private static _TYPE_INDEXED;
  105246. private static _TYPE_RGB;
  105247. private static _TYPE_GREY;
  105248. private static _TYPE_RLE_INDEXED;
  105249. private static _TYPE_RLE_RGB;
  105250. private static _TYPE_RLE_GREY;
  105251. private static _ORIGIN_MASK;
  105252. private static _ORIGIN_SHIFT;
  105253. private static _ORIGIN_BL;
  105254. private static _ORIGIN_BR;
  105255. private static _ORIGIN_UL;
  105256. private static _ORIGIN_UR;
  105257. /**
  105258. * Gets the header of a TGA file
  105259. * @param data defines the TGA data
  105260. * @returns the header
  105261. */
  105262. static GetTGAHeader(data: Uint8Array): any;
  105263. /**
  105264. * Uploads TGA content to a Babylon Texture
  105265. * @hidden
  105266. */
  105267. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  105268. /** @hidden */
  105269. 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;
  105270. /** @hidden */
  105271. 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;
  105272. /** @hidden */
  105273. 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;
  105274. /** @hidden */
  105275. 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;
  105276. /** @hidden */
  105277. 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;
  105278. /** @hidden */
  105279. 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;
  105280. }
  105281. }
  105282. declare module BABYLON {
  105283. /**
  105284. * Implementation of the TGA Texture Loader.
  105285. * @hidden
  105286. */
  105287. export class _TGATextureLoader implements IInternalTextureLoader {
  105288. /**
  105289. * Defines wether the loader supports cascade loading the different faces.
  105290. */
  105291. readonly supportCascades: boolean;
  105292. /**
  105293. * This returns if the loader support the current file information.
  105294. * @param extension defines the file extension of the file being loaded
  105295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105296. * @param fallback defines the fallback internal texture if any
  105297. * @param isBase64 defines whether the texture is encoded as a base64
  105298. * @param isBuffer defines whether the texture data are stored as a buffer
  105299. * @returns true if the loader can load the specified file
  105300. */
  105301. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105302. /**
  105303. * Transform the url before loading if required.
  105304. * @param rootUrl the url of the texture
  105305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105306. * @returns the transformed texture
  105307. */
  105308. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105309. /**
  105310. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105311. * @param rootUrl the url of the texture
  105312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105313. * @returns the fallback texture
  105314. */
  105315. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105316. /**
  105317. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105318. * @param data contains the texture data
  105319. * @param texture defines the BabylonJS internal texture
  105320. * @param createPolynomials will be true if polynomials have been requested
  105321. * @param onLoad defines the callback to trigger once the texture is ready
  105322. * @param onError defines the callback to trigger in case of error
  105323. */
  105324. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105325. /**
  105326. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105327. * @param data contains the texture data
  105328. * @param texture defines the BabylonJS internal texture
  105329. * @param callback defines the method to call once ready to upload
  105330. */
  105331. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105332. }
  105333. }
  105334. declare module BABYLON {
  105335. /**
  105336. * 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.
  105337. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  105338. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  105339. */
  105340. export class CustomProceduralTexture extends ProceduralTexture {
  105341. private _animate;
  105342. private _time;
  105343. private _config;
  105344. private _texturePath;
  105345. /**
  105346. * Instantiates a new Custom Procedural Texture.
  105347. * 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.
  105348. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  105349. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  105350. * @param name Define the name of the texture
  105351. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  105352. * @param size Define the size of the texture to create
  105353. * @param scene Define the scene the texture belongs to
  105354. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  105355. * @param generateMipMaps Define if the texture should creates mip maps or not
  105356. */
  105357. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  105358. private _loadJson;
  105359. /**
  105360. * Is the texture ready to be used ? (rendered at least once)
  105361. * @returns true if ready, otherwise, false.
  105362. */
  105363. isReady(): boolean;
  105364. /**
  105365. * Render the texture to its associated render target.
  105366. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  105367. */
  105368. render(useCameraPostProcess?: boolean): void;
  105369. /**
  105370. * Update the list of dependant textures samplers in the shader.
  105371. */
  105372. updateTextures(): void;
  105373. /**
  105374. * Update the uniform values of the procedural texture in the shader.
  105375. */
  105376. updateShaderUniforms(): void;
  105377. /**
  105378. * Define if the texture animates or not.
  105379. */
  105380. animate: boolean;
  105381. }
  105382. }
  105383. declare module BABYLON {
  105384. /** @hidden */
  105385. export var noisePixelShader: {
  105386. name: string;
  105387. shader: string;
  105388. };
  105389. }
  105390. declare module BABYLON {
  105391. /**
  105392. * Class used to generate noise procedural textures
  105393. */
  105394. export class NoiseProceduralTexture extends ProceduralTexture {
  105395. private _time;
  105396. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  105397. brightness: number;
  105398. /** Defines the number of octaves to process */
  105399. octaves: number;
  105400. /** Defines the level of persistence (0.8 by default) */
  105401. persistence: number;
  105402. /** Gets or sets animation speed factor (default is 1) */
  105403. animationSpeedFactor: number;
  105404. /**
  105405. * Creates a new NoiseProceduralTexture
  105406. * @param name defines the name fo the texture
  105407. * @param size defines the size of the texture (default is 256)
  105408. * @param scene defines the hosting scene
  105409. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  105410. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  105411. */
  105412. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  105413. private _updateShaderUniforms;
  105414. protected _getDefines(): string;
  105415. /** Generate the current state of the procedural texture */
  105416. render(useCameraPostProcess?: boolean): void;
  105417. /**
  105418. * Serializes this noise procedural texture
  105419. * @returns a serialized noise procedural texture object
  105420. */
  105421. serialize(): any;
  105422. /**
  105423. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  105424. * @param parsedTexture defines parsed texture data
  105425. * @param scene defines the current scene
  105426. * @param rootUrl defines the root URL containing noise procedural texture information
  105427. * @returns a parsed NoiseProceduralTexture
  105428. */
  105429. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  105430. }
  105431. }
  105432. declare module BABYLON {
  105433. /**
  105434. * Raw cube texture where the raw buffers are passed in
  105435. */
  105436. export class RawCubeTexture extends CubeTexture {
  105437. /**
  105438. * Creates a cube texture where the raw buffers are passed in.
  105439. * @param scene defines the scene the texture is attached to
  105440. * @param data defines the array of data to use to create each face
  105441. * @param size defines the size of the textures
  105442. * @param format defines the format of the data
  105443. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105444. * @param generateMipMaps defines if the engine should generate the mip levels
  105445. * @param invertY defines if data must be stored with Y axis inverted
  105446. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105447. * @param compression defines the compression used (null by default)
  105448. */
  105449. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  105450. /**
  105451. * Updates the raw cube texture.
  105452. * @param data defines the data to store
  105453. * @param format defines the data format
  105454. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105455. * @param invertY defines if data must be stored with Y axis inverted
  105456. * @param compression defines the compression used (null by default)
  105457. * @param level defines which level of the texture to update
  105458. */
  105459. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  105460. /**
  105461. * Updates a raw cube texture with RGBD encoded data.
  105462. * @param data defines the array of data [mipmap][face] to use to create each face
  105463. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  105464. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  105465. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  105466. * @returns a promsie that resolves when the operation is complete
  105467. */
  105468. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  105469. /**
  105470. * Clones the raw cube texture.
  105471. * @return a new cube texture
  105472. */
  105473. clone(): CubeTexture;
  105474. /** @hidden */
  105475. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105476. }
  105477. }
  105478. declare module BABYLON {
  105479. /**
  105480. * Class used to store 3D textures containing user data
  105481. */
  105482. export class RawTexture3D extends Texture {
  105483. /** Gets or sets the texture format to use */
  105484. format: number;
  105485. private _engine;
  105486. /**
  105487. * Create a new RawTexture3D
  105488. * @param data defines the data of the texture
  105489. * @param width defines the width of the texture
  105490. * @param height defines the height of the texture
  105491. * @param depth defines the depth of the texture
  105492. * @param format defines the texture format to use
  105493. * @param scene defines the hosting scene
  105494. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  105495. * @param invertY defines if texture must be stored with Y axis inverted
  105496. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  105497. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  105498. */
  105499. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  105500. /** Gets or sets the texture format to use */
  105501. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  105502. /**
  105503. * Update the texture with new data
  105504. * @param data defines the data to store in the texture
  105505. */
  105506. update(data: ArrayBufferView): void;
  105507. }
  105508. }
  105509. declare module BABYLON {
  105510. /**
  105511. * Creates a refraction texture used by refraction channel of the standard material.
  105512. * It is like a mirror but to see through a material.
  105513. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105514. */
  105515. export class RefractionTexture extends RenderTargetTexture {
  105516. /**
  105517. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  105518. * 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.
  105519. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105520. */
  105521. refractionPlane: Plane;
  105522. /**
  105523. * Define how deep under the surface we should see.
  105524. */
  105525. depth: number;
  105526. /**
  105527. * Creates a refraction texture used by refraction channel of the standard material.
  105528. * It is like a mirror but to see through a material.
  105529. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105530. * @param name Define the texture name
  105531. * @param size Define the size of the underlying texture
  105532. * @param scene Define the scene the refraction belongs to
  105533. * @param generateMipMaps Define if we need to generate mips level for the refraction
  105534. */
  105535. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  105536. /**
  105537. * Clone the refraction texture.
  105538. * @returns the cloned texture
  105539. */
  105540. clone(): RefractionTexture;
  105541. /**
  105542. * Serialize the texture to a JSON representation you could use in Parse later on
  105543. * @returns the serialized JSON representation
  105544. */
  105545. serialize(): any;
  105546. }
  105547. }
  105548. declare module BABYLON {
  105549. /**
  105550. * Configuration for Draco compression
  105551. */
  105552. export interface IDracoCompressionConfiguration {
  105553. /**
  105554. * Configuration for the decoder.
  105555. */
  105556. decoder?: {
  105557. /**
  105558. * The url to the WebAssembly module.
  105559. */
  105560. wasmUrl?: string;
  105561. /**
  105562. * The url to the WebAssembly binary.
  105563. */
  105564. wasmBinaryUrl?: string;
  105565. /**
  105566. * The url to the fallback JavaScript module.
  105567. */
  105568. fallbackUrl?: string;
  105569. };
  105570. }
  105571. /**
  105572. * Draco compression (https://google.github.io/draco/)
  105573. *
  105574. * This class wraps the Draco module.
  105575. *
  105576. * **Encoder**
  105577. *
  105578. * The encoder is not currently implemented.
  105579. *
  105580. * **Decoder**
  105581. *
  105582. * 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.
  105583. *
  105584. * To update the configuration, use the following code:
  105585. * ```javascript
  105586. * DracoCompression.Configuration = {
  105587. * decoder: {
  105588. * wasmUrl: "<url to the WebAssembly library>",
  105589. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  105590. * fallbackUrl: "<url to the fallback JavaScript library>",
  105591. * }
  105592. * };
  105593. * ```
  105594. *
  105595. * 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.
  105596. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  105597. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  105598. *
  105599. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  105600. * ```javascript
  105601. * var dracoCompression = new DracoCompression();
  105602. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  105603. * [VertexBuffer.PositionKind]: 0
  105604. * });
  105605. * ```
  105606. *
  105607. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  105608. */
  105609. export class DracoCompression implements IDisposable {
  105610. private static _DecoderModulePromise;
  105611. /**
  105612. * The configuration. Defaults to the following urls:
  105613. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  105614. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  105615. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  105616. */
  105617. static Configuration: IDracoCompressionConfiguration;
  105618. /**
  105619. * Returns true if the decoder is available.
  105620. */
  105621. static readonly DecoderAvailable: boolean;
  105622. /**
  105623. * Constructor
  105624. */
  105625. constructor();
  105626. /**
  105627. * Stop all async operations and release resources.
  105628. */
  105629. dispose(): void;
  105630. /**
  105631. * Decode Draco compressed mesh data to vertex data.
  105632. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  105633. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  105634. * @returns A promise that resolves with the decoded vertex data
  105635. */
  105636. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  105637. [kind: string]: number;
  105638. }): Promise<VertexData>;
  105639. private static _GetDecoderModule;
  105640. private static _LoadScriptAsync;
  105641. private static _LoadFileAsync;
  105642. }
  105643. }
  105644. declare module BABYLON {
  105645. /**
  105646. * Class for building Constructive Solid Geometry
  105647. */
  105648. export class CSG {
  105649. private polygons;
  105650. /**
  105651. * The world matrix
  105652. */
  105653. matrix: Matrix;
  105654. /**
  105655. * Stores the position
  105656. */
  105657. position: Vector3;
  105658. /**
  105659. * Stores the rotation
  105660. */
  105661. rotation: Vector3;
  105662. /**
  105663. * Stores the rotation quaternion
  105664. */
  105665. rotationQuaternion: Nullable<Quaternion>;
  105666. /**
  105667. * Stores the scaling vector
  105668. */
  105669. scaling: Vector3;
  105670. /**
  105671. * Convert the Mesh to CSG
  105672. * @param mesh The Mesh to convert to CSG
  105673. * @returns A new CSG from the Mesh
  105674. */
  105675. static FromMesh(mesh: Mesh): CSG;
  105676. /**
  105677. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  105678. * @param polygons Polygons used to construct a CSG solid
  105679. */
  105680. private static FromPolygons;
  105681. /**
  105682. * Clones, or makes a deep copy, of the CSG
  105683. * @returns A new CSG
  105684. */
  105685. clone(): CSG;
  105686. /**
  105687. * Unions this CSG with another CSG
  105688. * @param csg The CSG to union against this CSG
  105689. * @returns The unioned CSG
  105690. */
  105691. union(csg: CSG): CSG;
  105692. /**
  105693. * Unions this CSG with another CSG in place
  105694. * @param csg The CSG to union against this CSG
  105695. */
  105696. unionInPlace(csg: CSG): void;
  105697. /**
  105698. * Subtracts this CSG with another CSG
  105699. * @param csg The CSG to subtract against this CSG
  105700. * @returns A new CSG
  105701. */
  105702. subtract(csg: CSG): CSG;
  105703. /**
  105704. * Subtracts this CSG with another CSG in place
  105705. * @param csg The CSG to subtact against this CSG
  105706. */
  105707. subtractInPlace(csg: CSG): void;
  105708. /**
  105709. * Intersect this CSG with another CSG
  105710. * @param csg The CSG to intersect against this CSG
  105711. * @returns A new CSG
  105712. */
  105713. intersect(csg: CSG): CSG;
  105714. /**
  105715. * Intersects this CSG with another CSG in place
  105716. * @param csg The CSG to intersect against this CSG
  105717. */
  105718. intersectInPlace(csg: CSG): void;
  105719. /**
  105720. * Return a new CSG solid with solid and empty space switched. This solid is
  105721. * not modified.
  105722. * @returns A new CSG solid with solid and empty space switched
  105723. */
  105724. inverse(): CSG;
  105725. /**
  105726. * Inverses the CSG in place
  105727. */
  105728. inverseInPlace(): void;
  105729. /**
  105730. * This is used to keep meshes transformations so they can be restored
  105731. * when we build back a Babylon Mesh
  105732. * NB : All CSG operations are performed in world coordinates
  105733. * @param csg The CSG to copy the transform attributes from
  105734. * @returns This CSG
  105735. */
  105736. copyTransformAttributes(csg: CSG): CSG;
  105737. /**
  105738. * Build Raw mesh from CSG
  105739. * Coordinates here are in world space
  105740. * @param name The name of the mesh geometry
  105741. * @param scene The Scene
  105742. * @param keepSubMeshes Specifies if the submeshes should be kept
  105743. * @returns A new Mesh
  105744. */
  105745. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  105746. /**
  105747. * Build Mesh from CSG taking material and transforms into account
  105748. * @param name The name of the Mesh
  105749. * @param material The material of the Mesh
  105750. * @param scene The Scene
  105751. * @param keepSubMeshes Specifies if submeshes should be kept
  105752. * @returns The new Mesh
  105753. */
  105754. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  105755. }
  105756. }
  105757. declare module BABYLON {
  105758. /**
  105759. * Class used to create a trail following a mesh
  105760. */
  105761. export class TrailMesh extends Mesh {
  105762. private _generator;
  105763. private _autoStart;
  105764. private _running;
  105765. private _diameter;
  105766. private _length;
  105767. private _sectionPolygonPointsCount;
  105768. private _sectionVectors;
  105769. private _sectionNormalVectors;
  105770. private _beforeRenderObserver;
  105771. /**
  105772. * @constructor
  105773. * @param name The value used by scene.getMeshByName() to do a lookup.
  105774. * @param generator The mesh to generate a trail.
  105775. * @param scene The scene to add this mesh to.
  105776. * @param diameter Diameter of trailing mesh. Default is 1.
  105777. * @param length Length of trailing mesh. Default is 60.
  105778. * @param autoStart Automatically start trailing mesh. Default true.
  105779. */
  105780. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  105781. /**
  105782. * "TrailMesh"
  105783. * @returns "TrailMesh"
  105784. */
  105785. getClassName(): string;
  105786. private _createMesh;
  105787. /**
  105788. * Start trailing mesh.
  105789. */
  105790. start(): void;
  105791. /**
  105792. * Stop trailing mesh.
  105793. */
  105794. stop(): void;
  105795. /**
  105796. * Update trailing mesh geometry.
  105797. */
  105798. update(): void;
  105799. /**
  105800. * Returns a new TrailMesh object.
  105801. * @param name is a string, the name given to the new mesh
  105802. * @param newGenerator use new generator object for cloned trail mesh
  105803. * @returns a new mesh
  105804. */
  105805. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  105806. /**
  105807. * Serializes this trail mesh
  105808. * @param serializationObject object to write serialization to
  105809. */
  105810. serialize(serializationObject: any): void;
  105811. /**
  105812. * Parses a serialized trail mesh
  105813. * @param parsedMesh the serialized mesh
  105814. * @param scene the scene to create the trail mesh in
  105815. * @returns the created trail mesh
  105816. */
  105817. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  105818. }
  105819. }
  105820. declare module BABYLON {
  105821. /**
  105822. * Class containing static functions to help procedurally build meshes
  105823. */
  105824. export class RibbonBuilder {
  105825. /**
  105826. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105827. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105828. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105829. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105830. * * 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
  105831. * * 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
  105832. * * 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
  105833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105835. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105836. * * 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
  105837. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105838. * * 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
  105839. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105841. * @param name defines the name of the mesh
  105842. * @param options defines the options used to create the mesh
  105843. * @param scene defines the hosting scene
  105844. * @returns the ribbon mesh
  105845. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105846. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105847. */
  105848. static CreateRibbon(name: string, options: {
  105849. pathArray: Vector3[][];
  105850. closeArray?: boolean;
  105851. closePath?: boolean;
  105852. offset?: number;
  105853. updatable?: boolean;
  105854. sideOrientation?: number;
  105855. frontUVs?: Vector4;
  105856. backUVs?: Vector4;
  105857. instance?: Mesh;
  105858. invertUV?: boolean;
  105859. uvs?: Vector2[];
  105860. colors?: Color4[];
  105861. }, scene?: Nullable<Scene>): Mesh;
  105862. }
  105863. }
  105864. declare module BABYLON {
  105865. /**
  105866. * Class containing static functions to help procedurally build meshes
  105867. */
  105868. export class TorusKnotBuilder {
  105869. /**
  105870. * Creates a torus knot mesh
  105871. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105872. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105873. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105874. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105878. * @param name defines the name of the mesh
  105879. * @param options defines the options used to create the mesh
  105880. * @param scene defines the hosting scene
  105881. * @returns the torus knot mesh
  105882. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105883. */
  105884. static CreateTorusKnot(name: string, options: {
  105885. radius?: number;
  105886. tube?: number;
  105887. radialSegments?: number;
  105888. tubularSegments?: number;
  105889. p?: number;
  105890. q?: number;
  105891. updatable?: boolean;
  105892. sideOrientation?: number;
  105893. frontUVs?: Vector4;
  105894. backUVs?: Vector4;
  105895. }, scene: any): Mesh;
  105896. }
  105897. }
  105898. declare module BABYLON {
  105899. /**
  105900. * Polygon
  105901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105902. */
  105903. export class Polygon {
  105904. /**
  105905. * Creates a rectangle
  105906. * @param xmin bottom X coord
  105907. * @param ymin bottom Y coord
  105908. * @param xmax top X coord
  105909. * @param ymax top Y coord
  105910. * @returns points that make the resulting rectation
  105911. */
  105912. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105913. /**
  105914. * Creates a circle
  105915. * @param radius radius of circle
  105916. * @param cx scale in x
  105917. * @param cy scale in y
  105918. * @param numberOfSides number of sides that make up the circle
  105919. * @returns points that make the resulting circle
  105920. */
  105921. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105922. /**
  105923. * Creates a polygon from input string
  105924. * @param input Input polygon data
  105925. * @returns the parsed points
  105926. */
  105927. static Parse(input: string): Vector2[];
  105928. /**
  105929. * Starts building a polygon from x and y coordinates
  105930. * @param x x coordinate
  105931. * @param y y coordinate
  105932. * @returns the started path2
  105933. */
  105934. static StartingAt(x: number, y: number): Path2;
  105935. }
  105936. /**
  105937. * Builds a polygon
  105938. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105939. */
  105940. export class PolygonMeshBuilder {
  105941. private _points;
  105942. private _outlinepoints;
  105943. private _holes;
  105944. private _name;
  105945. private _scene;
  105946. private _epoints;
  105947. private _eholes;
  105948. private _addToepoint;
  105949. /**
  105950. * Babylon reference to the earcut plugin.
  105951. */
  105952. bjsEarcut: any;
  105953. /**
  105954. * Creates a PolygonMeshBuilder
  105955. * @param name name of the builder
  105956. * @param contours Path of the polygon
  105957. * @param scene scene to add to
  105958. * @param earcutInjection can be used to inject your own earcut reference
  105959. */
  105960. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105961. /**
  105962. * Adds a whole within the polygon
  105963. * @param hole Array of points defining the hole
  105964. * @returns this
  105965. */
  105966. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105967. /**
  105968. * Creates the polygon
  105969. * @param updatable If the mesh should be updatable
  105970. * @param depth The depth of the mesh created
  105971. * @returns the created mesh
  105972. */
  105973. build(updatable?: boolean, depth?: number): Mesh;
  105974. /**
  105975. * Creates the polygon
  105976. * @param depth The depth of the mesh created
  105977. * @returns the created VertexData
  105978. */
  105979. buildVertexData(depth?: number): VertexData;
  105980. /**
  105981. * Adds a side to the polygon
  105982. * @param positions points that make the polygon
  105983. * @param normals normals of the polygon
  105984. * @param uvs uvs of the polygon
  105985. * @param indices indices of the polygon
  105986. * @param bounds bounds of the polygon
  105987. * @param points points of the polygon
  105988. * @param depth depth of the polygon
  105989. * @param flip flip of the polygon
  105990. */
  105991. private addSide;
  105992. }
  105993. }
  105994. declare module BABYLON {
  105995. /**
  105996. * Class containing static functions to help procedurally build meshes
  105997. */
  105998. export class PolygonBuilder {
  105999. /**
  106000. * Creates a polygon mesh
  106001. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106002. * * 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
  106003. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106006. * * Remember you can only change the shape positions, not their number when updating a polygon
  106007. * @param name defines the name of the mesh
  106008. * @param options defines the options used to create the mesh
  106009. * @param scene defines the hosting scene
  106010. * @param earcutInjection can be used to inject your own earcut reference
  106011. * @returns the polygon mesh
  106012. */
  106013. static CreatePolygon(name: string, options: {
  106014. shape: Vector3[];
  106015. holes?: Vector3[][];
  106016. depth?: number;
  106017. faceUV?: Vector4[];
  106018. faceColors?: Color4[];
  106019. updatable?: boolean;
  106020. sideOrientation?: number;
  106021. frontUVs?: Vector4;
  106022. backUVs?: Vector4;
  106023. }, scene: Scene, earcutInjection?: any): Mesh;
  106024. /**
  106025. * Creates an extruded polygon mesh, with depth in the Y direction.
  106026. * * 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)
  106027. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106028. * @param name defines the name of the mesh
  106029. * @param options defines the options used to create the mesh
  106030. * @param scene defines the hosting scene
  106031. * @param earcutInjection can be used to inject your own earcut reference
  106032. * @returns the polygon mesh
  106033. */
  106034. static ExtrudePolygon(name: string, options: {
  106035. shape: Vector3[];
  106036. holes?: Vector3[][];
  106037. depth?: number;
  106038. faceUV?: Vector4[];
  106039. faceColors?: Color4[];
  106040. updatable?: boolean;
  106041. sideOrientation?: number;
  106042. frontUVs?: Vector4;
  106043. backUVs?: Vector4;
  106044. }, scene: Scene, earcutInjection?: any): Mesh;
  106045. }
  106046. }
  106047. declare module BABYLON {
  106048. /**
  106049. * Class containing static functions to help procedurally build meshes
  106050. */
  106051. export class ShapeBuilder {
  106052. /**
  106053. * 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.
  106054. * * 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.
  106055. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106056. * * 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.
  106057. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106058. * * 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
  106059. * * 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
  106060. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106065. * @param name defines the name of the mesh
  106066. * @param options defines the options used to create the mesh
  106067. * @param scene defines the hosting scene
  106068. * @returns the extruded shape mesh
  106069. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106071. */
  106072. static ExtrudeShape(name: string, options: {
  106073. shape: Vector3[];
  106074. path: Vector3[];
  106075. scale?: number;
  106076. rotation?: number;
  106077. cap?: number;
  106078. updatable?: boolean;
  106079. sideOrientation?: number;
  106080. frontUVs?: Vector4;
  106081. backUVs?: Vector4;
  106082. instance?: Mesh;
  106083. invertUV?: boolean;
  106084. }, scene?: Nullable<Scene>): Mesh;
  106085. /**
  106086. * Creates an custom extruded shape mesh.
  106087. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106088. * * 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.
  106089. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106090. * * 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
  106091. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106092. * * 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
  106093. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106094. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106095. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106096. * * 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
  106097. * * 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
  106098. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106103. * @param name defines the name of the mesh
  106104. * @param options defines the options used to create the mesh
  106105. * @param scene defines the hosting scene
  106106. * @returns the custom extruded shape mesh
  106107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106108. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106109. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106110. */
  106111. static ExtrudeShapeCustom(name: string, options: {
  106112. shape: Vector3[];
  106113. path: Vector3[];
  106114. scaleFunction?: any;
  106115. rotationFunction?: any;
  106116. ribbonCloseArray?: boolean;
  106117. ribbonClosePath?: boolean;
  106118. cap?: number;
  106119. updatable?: boolean;
  106120. sideOrientation?: number;
  106121. frontUVs?: Vector4;
  106122. backUVs?: Vector4;
  106123. instance?: Mesh;
  106124. invertUV?: boolean;
  106125. }, scene: Scene): Mesh;
  106126. private static _ExtrudeShapeGeneric;
  106127. }
  106128. }
  106129. declare module BABYLON {
  106130. /**
  106131. * Class containing static functions to help procedurally build meshes
  106132. */
  106133. export class LatheBuilder {
  106134. /**
  106135. * Creates lathe mesh.
  106136. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106137. * * 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
  106138. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106139. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106140. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106141. * * 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
  106142. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106143. * * 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
  106144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106146. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106148. * @param name defines the name of the mesh
  106149. * @param options defines the options used to create the mesh
  106150. * @param scene defines the hosting scene
  106151. * @returns the lathe mesh
  106152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106153. */
  106154. static CreateLathe(name: string, options: {
  106155. shape: Vector3[];
  106156. radius?: number;
  106157. tessellation?: number;
  106158. clip?: number;
  106159. arc?: number;
  106160. closed?: boolean;
  106161. updatable?: boolean;
  106162. sideOrientation?: number;
  106163. frontUVs?: Vector4;
  106164. backUVs?: Vector4;
  106165. cap?: number;
  106166. invertUV?: boolean;
  106167. }, scene: Scene): Mesh;
  106168. }
  106169. }
  106170. declare module BABYLON {
  106171. /**
  106172. * Class containing static functions to help procedurally build meshes
  106173. */
  106174. export class TubeBuilder {
  106175. /**
  106176. * Creates a tube mesh.
  106177. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106178. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106179. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106180. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106181. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106182. * * 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)
  106183. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106184. * * 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
  106185. * * 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
  106186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106190. * @param name defines the name of the mesh
  106191. * @param options defines the options used to create the mesh
  106192. * @param scene defines the hosting scene
  106193. * @returns the tube mesh
  106194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106195. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106196. */
  106197. static CreateTube(name: string, options: {
  106198. path: Vector3[];
  106199. radius?: number;
  106200. tessellation?: number;
  106201. radiusFunction?: {
  106202. (i: number, distance: number): number;
  106203. };
  106204. cap?: number;
  106205. arc?: number;
  106206. updatable?: boolean;
  106207. sideOrientation?: number;
  106208. frontUVs?: Vector4;
  106209. backUVs?: Vector4;
  106210. instance?: Mesh;
  106211. invertUV?: boolean;
  106212. }, scene: Scene): Mesh;
  106213. }
  106214. }
  106215. declare module BABYLON {
  106216. /**
  106217. * Class containing static functions to help procedurally build meshes
  106218. */
  106219. export class IcoSphereBuilder {
  106220. /**
  106221. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106222. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106223. * * 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`)
  106224. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106225. * * 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
  106226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106229. * @param name defines the name of the mesh
  106230. * @param options defines the options used to create the mesh
  106231. * @param scene defines the hosting scene
  106232. * @returns the icosahedron mesh
  106233. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106234. */
  106235. static CreateIcoSphere(name: string, options: {
  106236. radius?: number;
  106237. radiusX?: number;
  106238. radiusY?: number;
  106239. radiusZ?: number;
  106240. flat?: boolean;
  106241. subdivisions?: number;
  106242. sideOrientation?: number;
  106243. frontUVs?: Vector4;
  106244. backUVs?: Vector4;
  106245. updatable?: boolean;
  106246. }, scene: Scene): Mesh;
  106247. }
  106248. }
  106249. declare module BABYLON {
  106250. /**
  106251. * Class containing static functions to help procedurally build meshes
  106252. */
  106253. export class DecalBuilder {
  106254. /**
  106255. * Creates a decal mesh.
  106256. * 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
  106257. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106258. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106259. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106260. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106261. * @param name defines the name of the mesh
  106262. * @param sourceMesh defines the mesh where the decal must be applied
  106263. * @param options defines the options used to create the mesh
  106264. * @param scene defines the hosting scene
  106265. * @returns the decal mesh
  106266. * @see https://doc.babylonjs.com/how_to/decals
  106267. */
  106268. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106269. position?: Vector3;
  106270. normal?: Vector3;
  106271. size?: Vector3;
  106272. angle?: number;
  106273. }): Mesh;
  106274. }
  106275. }
  106276. declare module BABYLON {
  106277. /**
  106278. * Class containing static functions to help procedurally build meshes
  106279. */
  106280. export class MeshBuilder {
  106281. /**
  106282. * Creates a box mesh
  106283. * * The parameter `size` sets the size (float) of each box side (default 1)
  106284. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  106285. * * 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)
  106286. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106290. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  106291. * @param name defines the name of the mesh
  106292. * @param options defines the options used to create the mesh
  106293. * @param scene defines the hosting scene
  106294. * @returns the box mesh
  106295. */
  106296. static CreateBox(name: string, options: {
  106297. size?: number;
  106298. width?: number;
  106299. height?: number;
  106300. depth?: number;
  106301. faceUV?: Vector4[];
  106302. faceColors?: Color4[];
  106303. sideOrientation?: number;
  106304. frontUVs?: Vector4;
  106305. backUVs?: Vector4;
  106306. updatable?: boolean;
  106307. }, scene?: Nullable<Scene>): Mesh;
  106308. /**
  106309. * Creates a sphere mesh
  106310. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  106311. * * 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`)
  106312. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  106313. * * 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
  106314. * * 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)
  106315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106318. * @param name defines the name of the mesh
  106319. * @param options defines the options used to create the mesh
  106320. * @param scene defines the hosting scene
  106321. * @returns the sphere mesh
  106322. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  106323. */
  106324. static CreateSphere(name: string, options: {
  106325. segments?: number;
  106326. diameter?: number;
  106327. diameterX?: number;
  106328. diameterY?: number;
  106329. diameterZ?: number;
  106330. arc?: number;
  106331. slice?: number;
  106332. sideOrientation?: number;
  106333. frontUVs?: Vector4;
  106334. backUVs?: Vector4;
  106335. updatable?: boolean;
  106336. }, scene: any): Mesh;
  106337. /**
  106338. * Creates a plane polygonal mesh. By default, this is a disc
  106339. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106340. * * 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
  106341. * * 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
  106342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106345. * @param name defines the name of the mesh
  106346. * @param options defines the options used to create the mesh
  106347. * @param scene defines the hosting scene
  106348. * @returns the plane polygonal mesh
  106349. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106350. */
  106351. static CreateDisc(name: string, options: {
  106352. radius?: number;
  106353. tessellation?: number;
  106354. arc?: number;
  106355. updatable?: boolean;
  106356. sideOrientation?: number;
  106357. frontUVs?: Vector4;
  106358. backUVs?: Vector4;
  106359. }, scene?: Nullable<Scene>): Mesh;
  106360. /**
  106361. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106362. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106363. * * 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`)
  106364. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106365. * * 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
  106366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106369. * @param name defines the name of the mesh
  106370. * @param options defines the options used to create the mesh
  106371. * @param scene defines the hosting scene
  106372. * @returns the icosahedron mesh
  106373. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106374. */
  106375. static CreateIcoSphere(name: string, options: {
  106376. radius?: number;
  106377. radiusX?: number;
  106378. radiusY?: number;
  106379. radiusZ?: number;
  106380. flat?: boolean;
  106381. subdivisions?: number;
  106382. sideOrientation?: number;
  106383. frontUVs?: Vector4;
  106384. backUVs?: Vector4;
  106385. updatable?: boolean;
  106386. }, scene: Scene): Mesh;
  106387. /**
  106388. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106389. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106390. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106391. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106392. * * 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
  106393. * * 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
  106394. * * 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
  106395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106397. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106398. * * 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
  106399. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106400. * * 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
  106401. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106403. * @param name defines the name of the mesh
  106404. * @param options defines the options used to create the mesh
  106405. * @param scene defines the hosting scene
  106406. * @returns the ribbon mesh
  106407. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106408. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106409. */
  106410. static CreateRibbon(name: string, options: {
  106411. pathArray: Vector3[][];
  106412. closeArray?: boolean;
  106413. closePath?: boolean;
  106414. offset?: number;
  106415. updatable?: boolean;
  106416. sideOrientation?: number;
  106417. frontUVs?: Vector4;
  106418. backUVs?: Vector4;
  106419. instance?: Mesh;
  106420. invertUV?: boolean;
  106421. uvs?: Vector2[];
  106422. colors?: Color4[];
  106423. }, scene?: Nullable<Scene>): Mesh;
  106424. /**
  106425. * Creates a cylinder or a cone mesh
  106426. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106427. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106428. * * 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.
  106429. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106430. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106431. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106432. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106433. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106434. * * 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).
  106435. * * 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
  106436. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106437. * * 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
  106438. * * 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.
  106439. * * If `enclose` is false, a ring surface is one element.
  106440. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106441. * * 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
  106442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106445. * @param name defines the name of the mesh
  106446. * @param options defines the options used to create the mesh
  106447. * @param scene defines the hosting scene
  106448. * @returns the cylinder mesh
  106449. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106450. */
  106451. static CreateCylinder(name: string, options: {
  106452. height?: number;
  106453. diameterTop?: number;
  106454. diameterBottom?: number;
  106455. diameter?: number;
  106456. tessellation?: number;
  106457. subdivisions?: number;
  106458. arc?: number;
  106459. faceColors?: Color4[];
  106460. faceUV?: Vector4[];
  106461. updatable?: boolean;
  106462. hasRings?: boolean;
  106463. enclose?: boolean;
  106464. sideOrientation?: number;
  106465. frontUVs?: Vector4;
  106466. backUVs?: Vector4;
  106467. }, scene: any): Mesh;
  106468. /**
  106469. * Creates a torus mesh
  106470. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106471. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106472. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106476. * @param name defines the name of the mesh
  106477. * @param options defines the options used to create the mesh
  106478. * @param scene defines the hosting scene
  106479. * @returns the torus mesh
  106480. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106481. */
  106482. static CreateTorus(name: string, options: {
  106483. diameter?: number;
  106484. thickness?: number;
  106485. tessellation?: number;
  106486. updatable?: boolean;
  106487. sideOrientation?: number;
  106488. frontUVs?: Vector4;
  106489. backUVs?: Vector4;
  106490. }, scene: any): Mesh;
  106491. /**
  106492. * Creates a torus knot mesh
  106493. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106494. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106495. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106496. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106500. * @param name defines the name of the mesh
  106501. * @param options defines the options used to create the mesh
  106502. * @param scene defines the hosting scene
  106503. * @returns the torus knot mesh
  106504. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106505. */
  106506. static CreateTorusKnot(name: string, options: {
  106507. radius?: number;
  106508. tube?: number;
  106509. radialSegments?: number;
  106510. tubularSegments?: number;
  106511. p?: number;
  106512. q?: number;
  106513. updatable?: boolean;
  106514. sideOrientation?: number;
  106515. frontUVs?: Vector4;
  106516. backUVs?: Vector4;
  106517. }, scene: any): Mesh;
  106518. /**
  106519. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106520. * * 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
  106521. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106522. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106523. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106524. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106525. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106526. * * 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
  106527. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106529. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106530. * @param name defines the name of the new line system
  106531. * @param options defines the options used to create the line system
  106532. * @param scene defines the hosting scene
  106533. * @returns a new line system mesh
  106534. */
  106535. static CreateLineSystem(name: string, options: {
  106536. lines: Vector3[][];
  106537. updatable?: boolean;
  106538. instance?: Nullable<LinesMesh>;
  106539. colors?: Nullable<Color4[][]>;
  106540. useVertexAlpha?: boolean;
  106541. }, scene: Nullable<Scene>): LinesMesh;
  106542. /**
  106543. * Creates a line mesh
  106544. * 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
  106545. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106546. * * The parameter `points` is an array successive Vector3
  106547. * * 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
  106548. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106549. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106550. * * When updating an instance, remember that only point positions can change, not the number of points
  106551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106552. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106553. * @param name defines the name of the new line system
  106554. * @param options defines the options used to create the line system
  106555. * @param scene defines the hosting scene
  106556. * @returns a new line mesh
  106557. */
  106558. static CreateLines(name: string, options: {
  106559. points: Vector3[];
  106560. updatable?: boolean;
  106561. instance?: Nullable<LinesMesh>;
  106562. colors?: Color4[];
  106563. useVertexAlpha?: boolean;
  106564. }, scene?: Nullable<Scene>): LinesMesh;
  106565. /**
  106566. * Creates a dashed line mesh
  106567. * * 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
  106568. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106569. * * The parameter `points` is an array successive Vector3
  106570. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106571. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106572. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106573. * * 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
  106574. * * When updating an instance, remember that only point positions can change, not the number of points
  106575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106576. * @param name defines the name of the mesh
  106577. * @param options defines the options used to create the mesh
  106578. * @param scene defines the hosting scene
  106579. * @returns the dashed line mesh
  106580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106581. */
  106582. static CreateDashedLines(name: string, options: {
  106583. points: Vector3[];
  106584. dashSize?: number;
  106585. gapSize?: number;
  106586. dashNb?: number;
  106587. updatable?: boolean;
  106588. instance?: LinesMesh;
  106589. }, scene?: Nullable<Scene>): LinesMesh;
  106590. /**
  106591. * 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.
  106592. * * 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.
  106593. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106594. * * 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.
  106595. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106596. * * 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
  106597. * * 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
  106598. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106601. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106603. * @param name defines the name of the mesh
  106604. * @param options defines the options used to create the mesh
  106605. * @param scene defines the hosting scene
  106606. * @returns the extruded shape mesh
  106607. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106609. */
  106610. static ExtrudeShape(name: string, options: {
  106611. shape: Vector3[];
  106612. path: Vector3[];
  106613. scale?: number;
  106614. rotation?: number;
  106615. cap?: number;
  106616. updatable?: boolean;
  106617. sideOrientation?: number;
  106618. frontUVs?: Vector4;
  106619. backUVs?: Vector4;
  106620. instance?: Mesh;
  106621. invertUV?: boolean;
  106622. }, scene?: Nullable<Scene>): Mesh;
  106623. /**
  106624. * Creates an custom extruded shape mesh.
  106625. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106626. * * 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.
  106627. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106628. * * 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
  106629. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106630. * * 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
  106631. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106632. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106633. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106634. * * 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
  106635. * * 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
  106636. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106641. * @param name defines the name of the mesh
  106642. * @param options defines the options used to create the mesh
  106643. * @param scene defines the hosting scene
  106644. * @returns the custom extruded shape mesh
  106645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106646. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106648. */
  106649. static ExtrudeShapeCustom(name: string, options: {
  106650. shape: Vector3[];
  106651. path: Vector3[];
  106652. scaleFunction?: any;
  106653. rotationFunction?: any;
  106654. ribbonCloseArray?: boolean;
  106655. ribbonClosePath?: boolean;
  106656. cap?: number;
  106657. updatable?: boolean;
  106658. sideOrientation?: number;
  106659. frontUVs?: Vector4;
  106660. backUVs?: Vector4;
  106661. instance?: Mesh;
  106662. invertUV?: boolean;
  106663. }, scene: Scene): Mesh;
  106664. /**
  106665. * Creates lathe mesh.
  106666. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106667. * * 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
  106668. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106669. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106670. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106671. * * 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
  106672. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106673. * * 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
  106674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106676. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106678. * @param name defines the name of the mesh
  106679. * @param options defines the options used to create the mesh
  106680. * @param scene defines the hosting scene
  106681. * @returns the lathe mesh
  106682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106683. */
  106684. static CreateLathe(name: string, options: {
  106685. shape: Vector3[];
  106686. radius?: number;
  106687. tessellation?: number;
  106688. clip?: number;
  106689. arc?: number;
  106690. closed?: boolean;
  106691. updatable?: boolean;
  106692. sideOrientation?: number;
  106693. frontUVs?: Vector4;
  106694. backUVs?: Vector4;
  106695. cap?: number;
  106696. invertUV?: boolean;
  106697. }, scene: Scene): Mesh;
  106698. /**
  106699. * Creates a plane mesh
  106700. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  106701. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  106702. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  106703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106706. * @param name defines the name of the mesh
  106707. * @param options defines the options used to create the mesh
  106708. * @param scene defines the hosting scene
  106709. * @returns the plane mesh
  106710. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  106711. */
  106712. static CreatePlane(name: string, options: {
  106713. size?: number;
  106714. width?: number;
  106715. height?: number;
  106716. sideOrientation?: number;
  106717. frontUVs?: Vector4;
  106718. backUVs?: Vector4;
  106719. updatable?: boolean;
  106720. sourcePlane?: Plane;
  106721. }, scene: Scene): Mesh;
  106722. /**
  106723. * Creates a ground mesh
  106724. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106725. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106727. * @param name defines the name of the mesh
  106728. * @param options defines the options used to create the mesh
  106729. * @param scene defines the hosting scene
  106730. * @returns the ground mesh
  106731. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106732. */
  106733. static CreateGround(name: string, options: {
  106734. width?: number;
  106735. height?: number;
  106736. subdivisions?: number;
  106737. subdivisionsX?: number;
  106738. subdivisionsY?: number;
  106739. updatable?: boolean;
  106740. }, scene: any): Mesh;
  106741. /**
  106742. * Creates a tiled ground mesh
  106743. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106744. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106745. * * 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
  106746. * * 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
  106747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106748. * @param name defines the name of the mesh
  106749. * @param options defines the options used to create the mesh
  106750. * @param scene defines the hosting scene
  106751. * @returns the tiled ground mesh
  106752. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106753. */
  106754. static CreateTiledGround(name: string, options: {
  106755. xmin: number;
  106756. zmin: number;
  106757. xmax: number;
  106758. zmax: number;
  106759. subdivisions?: {
  106760. w: number;
  106761. h: number;
  106762. };
  106763. precision?: {
  106764. w: number;
  106765. h: number;
  106766. };
  106767. updatable?: boolean;
  106768. }, scene: Scene): Mesh;
  106769. /**
  106770. * Creates a ground mesh from a height map
  106771. * * The parameter `url` sets the URL of the height map image resource.
  106772. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106773. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106774. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106775. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106776. * * 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.
  106777. * * 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).
  106778. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106780. * @param name defines the name of the mesh
  106781. * @param url defines the url to the height map
  106782. * @param options defines the options used to create the mesh
  106783. * @param scene defines the hosting scene
  106784. * @returns the ground mesh
  106785. * @see https://doc.babylonjs.com/babylon101/height_map
  106786. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106787. */
  106788. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106789. width?: number;
  106790. height?: number;
  106791. subdivisions?: number;
  106792. minHeight?: number;
  106793. maxHeight?: number;
  106794. colorFilter?: Color3;
  106795. alphaFilter?: number;
  106796. updatable?: boolean;
  106797. onReady?: (mesh: GroundMesh) => void;
  106798. }, scene: Scene): GroundMesh;
  106799. /**
  106800. * Creates a polygon mesh
  106801. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106802. * * 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
  106803. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106806. * * Remember you can only change the shape positions, not their number when updating a polygon
  106807. * @param name defines the name of the mesh
  106808. * @param options defines the options used to create the mesh
  106809. * @param scene defines the hosting scene
  106810. * @param earcutInjection can be used to inject your own earcut reference
  106811. * @returns the polygon mesh
  106812. */
  106813. static CreatePolygon(name: string, options: {
  106814. shape: Vector3[];
  106815. holes?: Vector3[][];
  106816. depth?: number;
  106817. faceUV?: Vector4[];
  106818. faceColors?: Color4[];
  106819. updatable?: boolean;
  106820. sideOrientation?: number;
  106821. frontUVs?: Vector4;
  106822. backUVs?: Vector4;
  106823. }, scene: Scene, earcutInjection?: any): Mesh;
  106824. /**
  106825. * Creates an extruded polygon mesh, with depth in the Y direction.
  106826. * * 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)
  106827. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106828. * @param name defines the name of the mesh
  106829. * @param options defines the options used to create the mesh
  106830. * @param scene defines the hosting scene
  106831. * @param earcutInjection can be used to inject your own earcut reference
  106832. * @returns the polygon mesh
  106833. */
  106834. static ExtrudePolygon(name: string, options: {
  106835. shape: Vector3[];
  106836. holes?: Vector3[][];
  106837. depth?: number;
  106838. faceUV?: Vector4[];
  106839. faceColors?: Color4[];
  106840. updatable?: boolean;
  106841. sideOrientation?: number;
  106842. frontUVs?: Vector4;
  106843. backUVs?: Vector4;
  106844. }, scene: Scene, earcutInjection?: any): Mesh;
  106845. /**
  106846. * Creates a tube mesh.
  106847. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106848. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106849. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106850. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106851. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106852. * * 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)
  106853. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106854. * * 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
  106855. * * 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
  106856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106858. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106860. * @param name defines the name of the mesh
  106861. * @param options defines the options used to create the mesh
  106862. * @param scene defines the hosting scene
  106863. * @returns the tube mesh
  106864. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106865. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106866. */
  106867. static CreateTube(name: string, options: {
  106868. path: Vector3[];
  106869. radius?: number;
  106870. tessellation?: number;
  106871. radiusFunction?: {
  106872. (i: number, distance: number): number;
  106873. };
  106874. cap?: number;
  106875. arc?: number;
  106876. updatable?: boolean;
  106877. sideOrientation?: number;
  106878. frontUVs?: Vector4;
  106879. backUVs?: Vector4;
  106880. instance?: Mesh;
  106881. invertUV?: boolean;
  106882. }, scene: Scene): Mesh;
  106883. /**
  106884. * Creates a polyhedron mesh
  106885. * * 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
  106886. * * The parameter `size` (positive float, default 1) sets the polygon size
  106887. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106888. * * 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`
  106889. * * 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
  106890. * * 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)`)
  106891. * * 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
  106892. * * 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
  106893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106896. * @param name defines the name of the mesh
  106897. * @param options defines the options used to create the mesh
  106898. * @param scene defines the hosting scene
  106899. * @returns the polyhedron mesh
  106900. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106901. */
  106902. static CreatePolyhedron(name: string, options: {
  106903. type?: number;
  106904. size?: number;
  106905. sizeX?: number;
  106906. sizeY?: number;
  106907. sizeZ?: number;
  106908. custom?: any;
  106909. faceUV?: Vector4[];
  106910. faceColors?: Color4[];
  106911. flat?: boolean;
  106912. updatable?: boolean;
  106913. sideOrientation?: number;
  106914. frontUVs?: Vector4;
  106915. backUVs?: Vector4;
  106916. }, scene: Scene): Mesh;
  106917. /**
  106918. * Creates a decal mesh.
  106919. * 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
  106920. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106921. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106922. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106923. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106924. * @param name defines the name of the mesh
  106925. * @param sourceMesh defines the mesh where the decal must be applied
  106926. * @param options defines the options used to create the mesh
  106927. * @param scene defines the hosting scene
  106928. * @returns the decal mesh
  106929. * @see https://doc.babylonjs.com/how_to/decals
  106930. */
  106931. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106932. position?: Vector3;
  106933. normal?: Vector3;
  106934. size?: Vector3;
  106935. angle?: number;
  106936. }): Mesh;
  106937. }
  106938. }
  106939. declare module BABYLON {
  106940. /**
  106941. * A simplifier interface for future simplification implementations
  106942. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106943. */
  106944. export interface ISimplifier {
  106945. /**
  106946. * Simplification of a given mesh according to the given settings.
  106947. * Since this requires computation, it is assumed that the function runs async.
  106948. * @param settings The settings of the simplification, including quality and distance
  106949. * @param successCallback A callback that will be called after the mesh was simplified.
  106950. * @param errorCallback in case of an error, this callback will be called. optional.
  106951. */
  106952. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106953. }
  106954. /**
  106955. * Expected simplification settings.
  106956. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106957. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106958. */
  106959. export interface ISimplificationSettings {
  106960. /**
  106961. * Gets or sets the expected quality
  106962. */
  106963. quality: number;
  106964. /**
  106965. * Gets or sets the distance when this optimized version should be used
  106966. */
  106967. distance: number;
  106968. /**
  106969. * Gets an already optimized mesh
  106970. */
  106971. optimizeMesh?: boolean;
  106972. }
  106973. /**
  106974. * Class used to specify simplification options
  106975. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106976. */
  106977. export class SimplificationSettings implements ISimplificationSettings {
  106978. /** expected quality */
  106979. quality: number;
  106980. /** distance when this optimized version should be used */
  106981. distance: number;
  106982. /** already optimized mesh */
  106983. optimizeMesh?: boolean | undefined;
  106984. /**
  106985. * Creates a SimplificationSettings
  106986. * @param quality expected quality
  106987. * @param distance distance when this optimized version should be used
  106988. * @param optimizeMesh already optimized mesh
  106989. */
  106990. constructor(
  106991. /** expected quality */
  106992. quality: number,
  106993. /** distance when this optimized version should be used */
  106994. distance: number,
  106995. /** already optimized mesh */
  106996. optimizeMesh?: boolean | undefined);
  106997. }
  106998. /**
  106999. * Interface used to define a simplification task
  107000. */
  107001. export interface ISimplificationTask {
  107002. /**
  107003. * Array of settings
  107004. */
  107005. settings: Array<ISimplificationSettings>;
  107006. /**
  107007. * Simplification type
  107008. */
  107009. simplificationType: SimplificationType;
  107010. /**
  107011. * Mesh to simplify
  107012. */
  107013. mesh: Mesh;
  107014. /**
  107015. * Callback called on success
  107016. */
  107017. successCallback?: () => void;
  107018. /**
  107019. * Defines if parallel processing can be used
  107020. */
  107021. parallelProcessing: boolean;
  107022. }
  107023. /**
  107024. * Queue used to order the simplification tasks
  107025. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107026. */
  107027. export class SimplificationQueue {
  107028. private _simplificationArray;
  107029. /**
  107030. * Gets a boolean indicating that the process is still running
  107031. */
  107032. running: boolean;
  107033. /**
  107034. * Creates a new queue
  107035. */
  107036. constructor();
  107037. /**
  107038. * Adds a new simplification task
  107039. * @param task defines a task to add
  107040. */
  107041. addTask(task: ISimplificationTask): void;
  107042. /**
  107043. * Execute next task
  107044. */
  107045. executeNext(): void;
  107046. /**
  107047. * Execute a simplification task
  107048. * @param task defines the task to run
  107049. */
  107050. runSimplification(task: ISimplificationTask): void;
  107051. private getSimplifier;
  107052. }
  107053. /**
  107054. * The implemented types of simplification
  107055. * At the moment only Quadratic Error Decimation is implemented
  107056. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107057. */
  107058. export enum SimplificationType {
  107059. /** Quadratic error decimation */
  107060. QUADRATIC = 0
  107061. }
  107062. }
  107063. declare module BABYLON {
  107064. interface Scene {
  107065. /** @hidden (Backing field) */
  107066. _simplificationQueue: SimplificationQueue;
  107067. /**
  107068. * Gets or sets the simplification queue attached to the scene
  107069. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107070. */
  107071. simplificationQueue: SimplificationQueue;
  107072. }
  107073. interface Mesh {
  107074. /**
  107075. * Simplify the mesh according to the given array of settings.
  107076. * Function will return immediately and will simplify async
  107077. * @param settings a collection of simplification settings
  107078. * @param parallelProcessing should all levels calculate parallel or one after the other
  107079. * @param simplificationType the type of simplification to run
  107080. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  107081. * @returns the current mesh
  107082. */
  107083. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  107084. }
  107085. /**
  107086. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  107087. * created in a scene
  107088. */
  107089. export class SimplicationQueueSceneComponent implements ISceneComponent {
  107090. /**
  107091. * The component name helpfull to identify the component in the list of scene components.
  107092. */
  107093. readonly name: string;
  107094. /**
  107095. * The scene the component belongs to.
  107096. */
  107097. scene: Scene;
  107098. /**
  107099. * Creates a new instance of the component for the given scene
  107100. * @param scene Defines the scene to register the component in
  107101. */
  107102. constructor(scene: Scene);
  107103. /**
  107104. * Registers the component in a given scene
  107105. */
  107106. register(): void;
  107107. /**
  107108. * Rebuilds the elements related to this component in case of
  107109. * context lost for instance.
  107110. */
  107111. rebuild(): void;
  107112. /**
  107113. * Disposes the component and the associated ressources
  107114. */
  107115. dispose(): void;
  107116. private _beforeCameraUpdate;
  107117. }
  107118. }
  107119. declare module BABYLON {
  107120. /**
  107121. * Class used to enable access to IndexedDB
  107122. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  107123. */
  107124. export class Database implements IOfflineProvider {
  107125. private _callbackManifestChecked;
  107126. private _currentSceneUrl;
  107127. private _db;
  107128. private _enableSceneOffline;
  107129. private _enableTexturesOffline;
  107130. private _manifestVersionFound;
  107131. private _mustUpdateRessources;
  107132. private _hasReachedQuota;
  107133. private _isSupported;
  107134. private _idbFactory;
  107135. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  107136. private static IsUASupportingBlobStorage;
  107137. /**
  107138. * Gets a boolean indicating if Database storate is enabled (off by default)
  107139. */
  107140. static IDBStorageEnabled: boolean;
  107141. /**
  107142. * Gets a boolean indicating if scene must be saved in the database
  107143. */
  107144. readonly enableSceneOffline: boolean;
  107145. /**
  107146. * Gets a boolean indicating if textures must be saved in the database
  107147. */
  107148. readonly enableTexturesOffline: boolean;
  107149. /**
  107150. * Creates a new Database
  107151. * @param urlToScene defines the url to load the scene
  107152. * @param callbackManifestChecked defines the callback to use when manifest is checked
  107153. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  107154. */
  107155. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  107156. private static _ParseURL;
  107157. private static _ReturnFullUrlLocation;
  107158. private _checkManifestFile;
  107159. /**
  107160. * Open the database and make it available
  107161. * @param successCallback defines the callback to call on success
  107162. * @param errorCallback defines the callback to call on error
  107163. */
  107164. open(successCallback: () => void, errorCallback: () => void): void;
  107165. /**
  107166. * Loads an image from the database
  107167. * @param url defines the url to load from
  107168. * @param image defines the target DOM image
  107169. */
  107170. loadImage(url: string, image: HTMLImageElement): void;
  107171. private _loadImageFromDBAsync;
  107172. private _saveImageIntoDBAsync;
  107173. private _checkVersionFromDB;
  107174. private _loadVersionFromDBAsync;
  107175. private _saveVersionIntoDBAsync;
  107176. /**
  107177. * Loads a file from database
  107178. * @param url defines the URL to load from
  107179. * @param sceneLoaded defines a callback to call on success
  107180. * @param progressCallBack defines a callback to call when progress changed
  107181. * @param errorCallback defines a callback to call on error
  107182. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  107183. */
  107184. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  107185. private _loadFileAsync;
  107186. private _saveFileAsync;
  107187. /**
  107188. * Validates if xhr data is correct
  107189. * @param xhr defines the request to validate
  107190. * @param dataType defines the expected data type
  107191. * @returns true if data is correct
  107192. */
  107193. private static _ValidateXHRData;
  107194. }
  107195. }
  107196. declare module BABYLON {
  107197. /** @hidden */
  107198. export var gpuUpdateParticlesPixelShader: {
  107199. name: string;
  107200. shader: string;
  107201. };
  107202. }
  107203. declare module BABYLON {
  107204. /** @hidden */
  107205. export var gpuUpdateParticlesVertexShader: {
  107206. name: string;
  107207. shader: string;
  107208. };
  107209. }
  107210. declare module BABYLON {
  107211. /** @hidden */
  107212. export var clipPlaneFragmentDeclaration2: {
  107213. name: string;
  107214. shader: string;
  107215. };
  107216. }
  107217. declare module BABYLON {
  107218. /** @hidden */
  107219. export var gpuRenderParticlesPixelShader: {
  107220. name: string;
  107221. shader: string;
  107222. };
  107223. }
  107224. declare module BABYLON {
  107225. /** @hidden */
  107226. export var clipPlaneVertexDeclaration2: {
  107227. name: string;
  107228. shader: string;
  107229. };
  107230. }
  107231. declare module BABYLON {
  107232. /** @hidden */
  107233. export var gpuRenderParticlesVertexShader: {
  107234. name: string;
  107235. shader: string;
  107236. };
  107237. }
  107238. declare module BABYLON {
  107239. /**
  107240. * This represents a GPU particle system in Babylon
  107241. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  107242. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  107243. */
  107244. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  107245. /**
  107246. * The layer mask we are rendering the particles through.
  107247. */
  107248. layerMask: number;
  107249. private _capacity;
  107250. private _activeCount;
  107251. private _currentActiveCount;
  107252. private _accumulatedCount;
  107253. private _renderEffect;
  107254. private _updateEffect;
  107255. private _buffer0;
  107256. private _buffer1;
  107257. private _spriteBuffer;
  107258. private _updateVAO;
  107259. private _renderVAO;
  107260. private _targetIndex;
  107261. private _sourceBuffer;
  107262. private _targetBuffer;
  107263. private _engine;
  107264. private _currentRenderId;
  107265. private _started;
  107266. private _stopped;
  107267. private _timeDelta;
  107268. private _randomTexture;
  107269. private _randomTexture2;
  107270. private _attributesStrideSize;
  107271. private _updateEffectOptions;
  107272. private _randomTextureSize;
  107273. private _actualFrame;
  107274. private readonly _rawTextureWidth;
  107275. /**
  107276. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  107277. */
  107278. static readonly IsSupported: boolean;
  107279. /**
  107280. * An event triggered when the system is disposed.
  107281. */
  107282. onDisposeObservable: Observable<GPUParticleSystem>;
  107283. /**
  107284. * Gets the maximum number of particles active at the same time.
  107285. * @returns The max number of active particles.
  107286. */
  107287. getCapacity(): number;
  107288. /**
  107289. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  107290. * to override the particles.
  107291. */
  107292. forceDepthWrite: boolean;
  107293. /**
  107294. * Gets or set the number of active particles
  107295. */
  107296. activeParticleCount: number;
  107297. private _preWarmDone;
  107298. /**
  107299. * Is this system ready to be used/rendered
  107300. * @return true if the system is ready
  107301. */
  107302. isReady(): boolean;
  107303. /**
  107304. * Gets if the system has been started. (Note: this will still be true after stop is called)
  107305. * @returns True if it has been started, otherwise false.
  107306. */
  107307. isStarted(): boolean;
  107308. /**
  107309. * Starts the particle system and begins to emit
  107310. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  107311. */
  107312. start(delay?: number): void;
  107313. /**
  107314. * Stops the particle system.
  107315. */
  107316. stop(): void;
  107317. /**
  107318. * Remove all active particles
  107319. */
  107320. reset(): void;
  107321. /**
  107322. * Returns the string "GPUParticleSystem"
  107323. * @returns a string containing the class name
  107324. */
  107325. getClassName(): string;
  107326. private _colorGradientsTexture;
  107327. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  107328. /**
  107329. * Adds a new color gradient
  107330. * @param gradient defines the gradient to use (between 0 and 1)
  107331. * @param color1 defines the color to affect to the specified gradient
  107332. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  107333. * @returns the current particle system
  107334. */
  107335. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  107336. /**
  107337. * Remove a specific color gradient
  107338. * @param gradient defines the gradient to remove
  107339. * @returns the current particle system
  107340. */
  107341. removeColorGradient(gradient: number): GPUParticleSystem;
  107342. private _angularSpeedGradientsTexture;
  107343. private _sizeGradientsTexture;
  107344. private _velocityGradientsTexture;
  107345. private _limitVelocityGradientsTexture;
  107346. private _dragGradientsTexture;
  107347. private _addFactorGradient;
  107348. /**
  107349. * Adds a new size gradient
  107350. * @param gradient defines the gradient to use (between 0 and 1)
  107351. * @param factor defines the size factor to affect to the specified gradient
  107352. * @returns the current particle system
  107353. */
  107354. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  107355. /**
  107356. * Remove a specific size gradient
  107357. * @param gradient defines the gradient to remove
  107358. * @returns the current particle system
  107359. */
  107360. removeSizeGradient(gradient: number): GPUParticleSystem;
  107361. /**
  107362. * Adds a new angular speed gradient
  107363. * @param gradient defines the gradient to use (between 0 and 1)
  107364. * @param factor defines the angular speed to affect to the specified gradient
  107365. * @returns the current particle system
  107366. */
  107367. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  107368. /**
  107369. * Remove a specific angular speed gradient
  107370. * @param gradient defines the gradient to remove
  107371. * @returns the current particle system
  107372. */
  107373. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  107374. /**
  107375. * Adds a new velocity gradient
  107376. * @param gradient defines the gradient to use (between 0 and 1)
  107377. * @param factor defines the velocity to affect to the specified gradient
  107378. * @returns the current particle system
  107379. */
  107380. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  107381. /**
  107382. * Remove a specific velocity gradient
  107383. * @param gradient defines the gradient to remove
  107384. * @returns the current particle system
  107385. */
  107386. removeVelocityGradient(gradient: number): GPUParticleSystem;
  107387. /**
  107388. * Adds a new limit velocity gradient
  107389. * @param gradient defines the gradient to use (between 0 and 1)
  107390. * @param factor defines the limit velocity value to affect to the specified gradient
  107391. * @returns the current particle system
  107392. */
  107393. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  107394. /**
  107395. * Remove a specific limit velocity gradient
  107396. * @param gradient defines the gradient to remove
  107397. * @returns the current particle system
  107398. */
  107399. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  107400. /**
  107401. * Adds a new drag gradient
  107402. * @param gradient defines the gradient to use (between 0 and 1)
  107403. * @param factor defines the drag value to affect to the specified gradient
  107404. * @returns the current particle system
  107405. */
  107406. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  107407. /**
  107408. * Remove a specific drag gradient
  107409. * @param gradient defines the gradient to remove
  107410. * @returns the current particle system
  107411. */
  107412. removeDragGradient(gradient: number): GPUParticleSystem;
  107413. /**
  107414. * Not supported by GPUParticleSystem
  107415. * @param gradient defines the gradient to use (between 0 and 1)
  107416. * @param factor defines the emit rate value to affect to the specified gradient
  107417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107418. * @returns the current particle system
  107419. */
  107420. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107421. /**
  107422. * Not supported by GPUParticleSystem
  107423. * @param gradient defines the gradient to remove
  107424. * @returns the current particle system
  107425. */
  107426. removeEmitRateGradient(gradient: number): IParticleSystem;
  107427. /**
  107428. * Not supported by GPUParticleSystem
  107429. * @param gradient defines the gradient to use (between 0 and 1)
  107430. * @param factor defines the start size value to affect to the specified gradient
  107431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107432. * @returns the current particle system
  107433. */
  107434. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107435. /**
  107436. * Not supported by GPUParticleSystem
  107437. * @param gradient defines the gradient to remove
  107438. * @returns the current particle system
  107439. */
  107440. removeStartSizeGradient(gradient: number): IParticleSystem;
  107441. /**
  107442. * Not supported by GPUParticleSystem
  107443. * @param gradient defines the gradient to use (between 0 and 1)
  107444. * @param min defines the color remap minimal range
  107445. * @param max defines the color remap maximal range
  107446. * @returns the current particle system
  107447. */
  107448. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107449. /**
  107450. * Not supported by GPUParticleSystem
  107451. * @param gradient defines the gradient to remove
  107452. * @returns the current particle system
  107453. */
  107454. removeColorRemapGradient(): IParticleSystem;
  107455. /**
  107456. * Not supported by GPUParticleSystem
  107457. * @param gradient defines the gradient to use (between 0 and 1)
  107458. * @param min defines the alpha remap minimal range
  107459. * @param max defines the alpha remap maximal range
  107460. * @returns the current particle system
  107461. */
  107462. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107463. /**
  107464. * Not supported by GPUParticleSystem
  107465. * @param gradient defines the gradient to remove
  107466. * @returns the current particle system
  107467. */
  107468. removeAlphaRemapGradient(): IParticleSystem;
  107469. /**
  107470. * Not supported by GPUParticleSystem
  107471. * @param gradient defines the gradient to use (between 0 and 1)
  107472. * @param color defines the color to affect to the specified gradient
  107473. * @returns the current particle system
  107474. */
  107475. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  107476. /**
  107477. * Not supported by GPUParticleSystem
  107478. * @param gradient defines the gradient to remove
  107479. * @returns the current particle system
  107480. */
  107481. removeRampGradient(): IParticleSystem;
  107482. /**
  107483. * Not supported by GPUParticleSystem
  107484. * @returns the list of ramp gradients
  107485. */
  107486. getRampGradients(): Nullable<Array<Color3Gradient>>;
  107487. /**
  107488. * Not supported by GPUParticleSystem
  107489. * Gets or sets a boolean indicating that ramp gradients must be used
  107490. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107491. */
  107492. useRampGradients: boolean;
  107493. /**
  107494. * Not supported by GPUParticleSystem
  107495. * @param gradient defines the gradient to use (between 0 and 1)
  107496. * @param factor defines the life time factor to affect to the specified gradient
  107497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107498. * @returns the current particle system
  107499. */
  107500. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107501. /**
  107502. * Not supported by GPUParticleSystem
  107503. * @param gradient defines the gradient to remove
  107504. * @returns the current particle system
  107505. */
  107506. removeLifeTimeGradient(gradient: number): IParticleSystem;
  107507. /**
  107508. * Instantiates a GPU particle system.
  107509. * 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.
  107510. * @param name The name of the particle system
  107511. * @param options The options used to create the system
  107512. * @param scene The scene the particle system belongs to
  107513. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  107514. */
  107515. constructor(name: string, options: Partial<{
  107516. capacity: number;
  107517. randomTextureSize: number;
  107518. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  107519. protected _reset(): void;
  107520. private _createUpdateVAO;
  107521. private _createRenderVAO;
  107522. private _initialize;
  107523. /** @hidden */
  107524. _recreateUpdateEffect(): void;
  107525. /** @hidden */
  107526. _recreateRenderEffect(): void;
  107527. /**
  107528. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107529. * @param preWarm defines if we are in the pre-warmimg phase
  107530. */
  107531. animate(preWarm?: boolean): void;
  107532. private _createFactorGradientTexture;
  107533. private _createSizeGradientTexture;
  107534. private _createAngularSpeedGradientTexture;
  107535. private _createVelocityGradientTexture;
  107536. private _createLimitVelocityGradientTexture;
  107537. private _createDragGradientTexture;
  107538. private _createColorGradientTexture;
  107539. /**
  107540. * Renders the particle system in its current state
  107541. * @param preWarm defines if the system should only update the particles but not render them
  107542. * @returns the current number of particles
  107543. */
  107544. render(preWarm?: boolean): number;
  107545. /**
  107546. * Rebuilds the particle system
  107547. */
  107548. rebuild(): void;
  107549. private _releaseBuffers;
  107550. private _releaseVAOs;
  107551. /**
  107552. * Disposes the particle system and free the associated resources
  107553. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107554. */
  107555. dispose(disposeTexture?: boolean): void;
  107556. /**
  107557. * Clones the particle system.
  107558. * @param name The name of the cloned object
  107559. * @param newEmitter The new emitter to use
  107560. * @returns the cloned particle system
  107561. */
  107562. clone(name: string, newEmitter: any): GPUParticleSystem;
  107563. /**
  107564. * Serializes the particle system to a JSON object.
  107565. * @returns the JSON object
  107566. */
  107567. serialize(): any;
  107568. /**
  107569. * Parses a JSON object to create a GPU particle system.
  107570. * @param parsedParticleSystem The JSON object to parse
  107571. * @param scene The scene to create the particle system in
  107572. * @param rootUrl The root url to use to load external dependencies like texture
  107573. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107574. * @returns the parsed GPU particle system
  107575. */
  107576. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  107577. }
  107578. }
  107579. declare module BABYLON {
  107580. /**
  107581. * Represents a set of particle systems working together to create a specific effect
  107582. */
  107583. export class ParticleSystemSet implements IDisposable {
  107584. private _emitterCreationOptions;
  107585. private _emitterNode;
  107586. /**
  107587. * Gets the particle system list
  107588. */
  107589. systems: IParticleSystem[];
  107590. /**
  107591. * Gets the emitter node used with this set
  107592. */
  107593. readonly emitterNode: Nullable<TransformNode>;
  107594. /**
  107595. * Creates a new emitter mesh as a sphere
  107596. * @param options defines the options used to create the sphere
  107597. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107598. * @param scene defines the hosting scene
  107599. */
  107600. setEmitterAsSphere(options: {
  107601. diameter: number;
  107602. segments: number;
  107603. color: Color3;
  107604. }, renderingGroupId: number, scene: Scene): void;
  107605. /**
  107606. * Starts all particle systems of the set
  107607. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107608. */
  107609. start(emitter?: AbstractMesh): void;
  107610. /**
  107611. * Release all associated resources
  107612. */
  107613. dispose(): void;
  107614. /**
  107615. * Serialize the set into a JSON compatible object
  107616. * @returns a JSON compatible representation of the set
  107617. */
  107618. serialize(): any;
  107619. /**
  107620. * Parse a new ParticleSystemSet from a serialized source
  107621. * @param data defines a JSON compatible representation of the set
  107622. * @param scene defines the hosting scene
  107623. * @param gpu defines if we want GPU particles or CPU particles
  107624. * @returns a new ParticleSystemSet
  107625. */
  107626. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  107627. }
  107628. }
  107629. declare module BABYLON {
  107630. /**
  107631. * This class is made for on one-liner static method to help creating particle system set.
  107632. */
  107633. export class ParticleHelper {
  107634. /**
  107635. * Gets or sets base Assets URL
  107636. */
  107637. static BaseAssetsUrl: string;
  107638. /**
  107639. * Create a default particle system that you can tweak
  107640. * @param emitter defines the emitter to use
  107641. * @param capacity defines the system capacity (default is 500 particles)
  107642. * @param scene defines the hosting scene
  107643. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  107644. * @returns the new Particle system
  107645. */
  107646. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  107647. /**
  107648. * This is the main static method (one-liner) of this helper to create different particle systems
  107649. * @param type This string represents the type to the particle system to create
  107650. * @param scene The scene where the particle system should live
  107651. * @param gpu If the system will use gpu
  107652. * @returns the ParticleSystemSet created
  107653. */
  107654. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  107655. /**
  107656. * Static function used to export a particle system to a ParticleSystemSet variable.
  107657. * Please note that the emitter shape is not exported
  107658. * @param systems defines the particle systems to export
  107659. * @returns the created particle system set
  107660. */
  107661. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  107662. }
  107663. }
  107664. declare module BABYLON {
  107665. interface Engine {
  107666. /**
  107667. * Create an effect to use with particle systems.
  107668. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  107669. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  107670. * @param uniformsNames defines a list of attribute names
  107671. * @param samplers defines an array of string used to represent textures
  107672. * @param defines defines the string containing the defines to use to compile the shaders
  107673. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107674. * @param onCompiled defines a function to call when the effect creation is successful
  107675. * @param onError defines a function to call when the effect creation has failed
  107676. * @returns the new Effect
  107677. */
  107678. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  107679. }
  107680. interface Mesh {
  107681. /**
  107682. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  107683. * @returns an array of IParticleSystem
  107684. */
  107685. getEmittedParticleSystems(): IParticleSystem[];
  107686. /**
  107687. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  107688. * @returns an array of IParticleSystem
  107689. */
  107690. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  107691. }
  107692. /**
  107693. * @hidden
  107694. */
  107695. export var _IDoNeedToBeInTheBuild: number;
  107696. }
  107697. declare module BABYLON {
  107698. interface Scene {
  107699. /** @hidden (Backing field) */
  107700. _physicsEngine: Nullable<IPhysicsEngine>;
  107701. /**
  107702. * Gets the current physics engine
  107703. * @returns a IPhysicsEngine or null if none attached
  107704. */
  107705. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  107706. /**
  107707. * Enables physics to the current scene
  107708. * @param gravity defines the scene's gravity for the physics engine
  107709. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  107710. * @return a boolean indicating if the physics engine was initialized
  107711. */
  107712. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  107713. /**
  107714. * Disables and disposes the physics engine associated with the scene
  107715. */
  107716. disablePhysicsEngine(): void;
  107717. /**
  107718. * Gets a boolean indicating if there is an active physics engine
  107719. * @returns a boolean indicating if there is an active physics engine
  107720. */
  107721. isPhysicsEnabled(): boolean;
  107722. /**
  107723. * Deletes a physics compound impostor
  107724. * @param compound defines the compound to delete
  107725. */
  107726. deleteCompoundImpostor(compound: any): void;
  107727. /**
  107728. * An event triggered when physic simulation is about to be run
  107729. */
  107730. onBeforePhysicsObservable: Observable<Scene>;
  107731. /**
  107732. * An event triggered when physic simulation has been done
  107733. */
  107734. onAfterPhysicsObservable: Observable<Scene>;
  107735. }
  107736. interface AbstractMesh {
  107737. /** @hidden */
  107738. _physicsImpostor: Nullable<PhysicsImpostor>;
  107739. /**
  107740. * Gets or sets impostor used for physic simulation
  107741. * @see http://doc.babylonjs.com/features/physics_engine
  107742. */
  107743. physicsImpostor: Nullable<PhysicsImpostor>;
  107744. /**
  107745. * Gets the current physics impostor
  107746. * @see http://doc.babylonjs.com/features/physics_engine
  107747. * @returns a physics impostor or null
  107748. */
  107749. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  107750. /** Apply a physic impulse to the mesh
  107751. * @param force defines the force to apply
  107752. * @param contactPoint defines where to apply the force
  107753. * @returns the current mesh
  107754. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107755. */
  107756. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  107757. /**
  107758. * Creates a physic joint between two meshes
  107759. * @param otherMesh defines the other mesh to use
  107760. * @param pivot1 defines the pivot to use on this mesh
  107761. * @param pivot2 defines the pivot to use on the other mesh
  107762. * @param options defines additional options (can be plugin dependent)
  107763. * @returns the current mesh
  107764. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  107765. */
  107766. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  107767. /** @hidden */
  107768. _disposePhysicsObserver: Nullable<Observer<Node>>;
  107769. }
  107770. /**
  107771. * Defines the physics engine scene component responsible to manage a physics engine
  107772. */
  107773. export class PhysicsEngineSceneComponent implements ISceneComponent {
  107774. /**
  107775. * The component name helpful to identify the component in the list of scene components.
  107776. */
  107777. readonly name: string;
  107778. /**
  107779. * The scene the component belongs to.
  107780. */
  107781. scene: Scene;
  107782. /**
  107783. * Creates a new instance of the component for the given scene
  107784. * @param scene Defines the scene to register the component in
  107785. */
  107786. constructor(scene: Scene);
  107787. /**
  107788. * Registers the component in a given scene
  107789. */
  107790. register(): void;
  107791. /**
  107792. * Rebuilds the elements related to this component in case of
  107793. * context lost for instance.
  107794. */
  107795. rebuild(): void;
  107796. /**
  107797. * Disposes the component and the associated ressources
  107798. */
  107799. dispose(): void;
  107800. }
  107801. }
  107802. declare module BABYLON {
  107803. /**
  107804. * A helper for physics simulations
  107805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107806. */
  107807. export class PhysicsHelper {
  107808. private _scene;
  107809. private _physicsEngine;
  107810. /**
  107811. * Initializes the Physics helper
  107812. * @param scene Babylon.js scene
  107813. */
  107814. constructor(scene: Scene);
  107815. /**
  107816. * Applies a radial explosion impulse
  107817. * @param origin the origin of the explosion
  107818. * @param radius the explosion radius
  107819. * @param strength the explosion strength
  107820. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107821. * @returns A physics radial explosion event, or null
  107822. */
  107823. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107824. /**
  107825. * Applies a radial explosion force
  107826. * @param origin the origin of the explosion
  107827. * @param radius the explosion radius
  107828. * @param strength the explosion strength
  107829. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107830. * @returns A physics radial explosion event, or null
  107831. */
  107832. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107833. /**
  107834. * Creates a gravitational field
  107835. * @param origin the origin of the explosion
  107836. * @param radius the explosion radius
  107837. * @param strength the explosion strength
  107838. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107839. * @returns A physics gravitational field event, or null
  107840. */
  107841. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  107842. /**
  107843. * Creates a physics updraft event
  107844. * @param origin the origin of the updraft
  107845. * @param radius the radius of the updraft
  107846. * @param strength the strength of the updraft
  107847. * @param height the height of the updraft
  107848. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107849. * @returns A physics updraft event, or null
  107850. */
  107851. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107852. /**
  107853. * Creates a physics vortex event
  107854. * @param origin the of the vortex
  107855. * @param radius the radius of the vortex
  107856. * @param strength the strength of the vortex
  107857. * @param height the height of the vortex
  107858. * @returns a Physics vortex event, or null
  107859. * A physics vortex event or null
  107860. */
  107861. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107862. }
  107863. /**
  107864. * Represents a physics radial explosion event
  107865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107866. */
  107867. export class PhysicsRadialExplosionEvent {
  107868. private _scene;
  107869. private _sphere;
  107870. private _sphereOptions;
  107871. private _rays;
  107872. private _dataFetched;
  107873. /**
  107874. * Initializes a radial explosioin event
  107875. * @param scene BabylonJS scene
  107876. */
  107877. constructor(scene: Scene);
  107878. /**
  107879. * Returns the data related to the radial explosion event (sphere & rays).
  107880. * @returns The radial explosion event data
  107881. */
  107882. getData(): PhysicsRadialExplosionEventData;
  107883. /**
  107884. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107885. * @param impostor A physics imposter
  107886. * @param origin the origin of the explosion
  107887. * @param radius the explosion radius
  107888. * @param strength the explosion strength
  107889. * @param falloff possible options: Constant & Linear
  107890. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107891. */
  107892. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107893. /**
  107894. * Disposes the sphere.
  107895. * @param force Specifies if the sphere should be disposed by force
  107896. */
  107897. dispose(force?: boolean): void;
  107898. /*** Helpers ***/
  107899. private _prepareSphere;
  107900. private _intersectsWithSphere;
  107901. }
  107902. /**
  107903. * Represents a gravitational field event
  107904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107905. */
  107906. export class PhysicsGravitationalFieldEvent {
  107907. private _physicsHelper;
  107908. private _scene;
  107909. private _origin;
  107910. private _radius;
  107911. private _strength;
  107912. private _falloff;
  107913. private _tickCallback;
  107914. private _sphere;
  107915. private _dataFetched;
  107916. /**
  107917. * Initializes the physics gravitational field event
  107918. * @param physicsHelper A physics helper
  107919. * @param scene BabylonJS scene
  107920. * @param origin The origin position of the gravitational field event
  107921. * @param radius The radius of the gravitational field event
  107922. * @param strength The strength of the gravitational field event
  107923. * @param falloff The falloff for the gravitational field event
  107924. */
  107925. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107926. /**
  107927. * Returns the data related to the gravitational field event (sphere).
  107928. * @returns A gravitational field event
  107929. */
  107930. getData(): PhysicsGravitationalFieldEventData;
  107931. /**
  107932. * Enables the gravitational field.
  107933. */
  107934. enable(): void;
  107935. /**
  107936. * Disables the gravitational field.
  107937. */
  107938. disable(): void;
  107939. /**
  107940. * Disposes the sphere.
  107941. * @param force The force to dispose from the gravitational field event
  107942. */
  107943. dispose(force?: boolean): void;
  107944. private _tick;
  107945. }
  107946. /**
  107947. * Represents a physics updraft event
  107948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107949. */
  107950. export class PhysicsUpdraftEvent {
  107951. private _scene;
  107952. private _origin;
  107953. private _radius;
  107954. private _strength;
  107955. private _height;
  107956. private _updraftMode;
  107957. private _physicsEngine;
  107958. private _originTop;
  107959. private _originDirection;
  107960. private _tickCallback;
  107961. private _cylinder;
  107962. private _cylinderPosition;
  107963. private _dataFetched;
  107964. /**
  107965. * Initializes the physics updraft event
  107966. * @param _scene BabylonJS scene
  107967. * @param _origin The origin position of the updraft
  107968. * @param _radius The radius of the updraft
  107969. * @param _strength The strength of the updraft
  107970. * @param _height The height of the updraft
  107971. * @param _updraftMode The mode of the updraft
  107972. */
  107973. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107974. /**
  107975. * Returns the data related to the updraft event (cylinder).
  107976. * @returns A physics updraft event
  107977. */
  107978. getData(): PhysicsUpdraftEventData;
  107979. /**
  107980. * Enables the updraft.
  107981. */
  107982. enable(): void;
  107983. /**
  107984. * Disables the cortex.
  107985. */
  107986. disable(): void;
  107987. /**
  107988. * Disposes the sphere.
  107989. * @param force Specifies if the updraft should be disposed by force
  107990. */
  107991. dispose(force?: boolean): void;
  107992. private getImpostorForceAndContactPoint;
  107993. private _tick;
  107994. /*** Helpers ***/
  107995. private _prepareCylinder;
  107996. private _intersectsWithCylinder;
  107997. }
  107998. /**
  107999. * Represents a physics vortex event
  108000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108001. */
  108002. export class PhysicsVortexEvent {
  108003. private _scene;
  108004. private _origin;
  108005. private _radius;
  108006. private _strength;
  108007. private _height;
  108008. private _physicsEngine;
  108009. private _originTop;
  108010. private _centripetalForceThreshold;
  108011. private _updraftMultiplier;
  108012. private _tickCallback;
  108013. private _cylinder;
  108014. private _cylinderPosition;
  108015. private _dataFetched;
  108016. /**
  108017. * Initializes the physics vortex event
  108018. * @param _scene The BabylonJS scene
  108019. * @param _origin The origin position of the vortex
  108020. * @param _radius The radius of the vortex
  108021. * @param _strength The strength of the vortex
  108022. * @param _height The height of the vortex
  108023. */
  108024. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  108025. /**
  108026. * Returns the data related to the vortex event (cylinder).
  108027. * @returns The physics vortex event data
  108028. */
  108029. getData(): PhysicsVortexEventData;
  108030. /**
  108031. * Enables the vortex.
  108032. */
  108033. enable(): void;
  108034. /**
  108035. * Disables the cortex.
  108036. */
  108037. disable(): void;
  108038. /**
  108039. * Disposes the sphere.
  108040. * @param force
  108041. */
  108042. dispose(force?: boolean): void;
  108043. private getImpostorForceAndContactPoint;
  108044. private _tick;
  108045. /*** Helpers ***/
  108046. private _prepareCylinder;
  108047. private _intersectsWithCylinder;
  108048. }
  108049. /**
  108050. * The strenght of the force in correspondence to the distance of the affected object
  108051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108052. */
  108053. export enum PhysicsRadialImpulseFalloff {
  108054. /** Defines that impulse is constant in strength across it's whole radius */
  108055. Constant = 0,
  108056. /** DEfines that impulse gets weaker if it's further from the origin */
  108057. Linear = 1
  108058. }
  108059. /**
  108060. * The strength of the force in correspondence to the distance of the affected object
  108061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108062. */
  108063. export enum PhysicsUpdraftMode {
  108064. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  108065. Center = 0,
  108066. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  108067. Perpendicular = 1
  108068. }
  108069. /**
  108070. * Interface for a physics force and contact point
  108071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108072. */
  108073. export interface PhysicsForceAndContactPoint {
  108074. /**
  108075. * The force applied at the contact point
  108076. */
  108077. force: Vector3;
  108078. /**
  108079. * The contact point
  108080. */
  108081. contactPoint: Vector3;
  108082. }
  108083. /**
  108084. * Interface for radial explosion event data
  108085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108086. */
  108087. export interface PhysicsRadialExplosionEventData {
  108088. /**
  108089. * A sphere used for the radial explosion event
  108090. */
  108091. sphere: Mesh;
  108092. /**
  108093. * An array of rays for the radial explosion event
  108094. */
  108095. rays: Array<Ray>;
  108096. }
  108097. /**
  108098. * Interface for gravitational field event data
  108099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108100. */
  108101. export interface PhysicsGravitationalFieldEventData {
  108102. /**
  108103. * A sphere mesh used for the gravitational field event
  108104. */
  108105. sphere: Mesh;
  108106. }
  108107. /**
  108108. * Interface for updraft event data
  108109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108110. */
  108111. export interface PhysicsUpdraftEventData {
  108112. /**
  108113. * A cylinder used for the updraft event
  108114. */
  108115. cylinder: Mesh;
  108116. }
  108117. /**
  108118. * Interface for vortex event data
  108119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108120. */
  108121. export interface PhysicsVortexEventData {
  108122. /**
  108123. * A cylinder used for the vortex event
  108124. */
  108125. cylinder: Mesh;
  108126. }
  108127. }
  108128. declare module BABYLON {
  108129. /**
  108130. * AmmoJS Physics plugin
  108131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108132. * @see https://github.com/kripken/ammo.js/
  108133. */
  108134. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108135. private _useDeltaForWorldStep;
  108136. /**
  108137. * Reference to the Ammo library
  108138. */
  108139. bjsAMMO: any;
  108140. /**
  108141. * Created ammoJS world which physics bodies are added to
  108142. */
  108143. world: any;
  108144. /**
  108145. * Name of the plugin
  108146. */
  108147. name: string;
  108148. private _timeStep;
  108149. private _fixedTimeStep;
  108150. private _maxSteps;
  108151. private _tmpQuaternion;
  108152. private _tmpAmmoTransform;
  108153. private _tmpAmmoQuaternion;
  108154. private _tmpAmmoConcreteContactResultCallback;
  108155. private _collisionConfiguration;
  108156. private _dispatcher;
  108157. private _overlappingPairCache;
  108158. private _solver;
  108159. private _tmpAmmoVectorA;
  108160. private _tmpAmmoVectorB;
  108161. private _tmpAmmoVectorC;
  108162. private _tmpContactCallbackResult;
  108163. private static readonly DISABLE_COLLISION_FLAG;
  108164. private static readonly KINEMATIC_FLAG;
  108165. private static readonly DISABLE_DEACTIVATION_FLAG;
  108166. /**
  108167. * Initializes the ammoJS plugin
  108168. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108169. * @param ammoInjection can be used to inject your own ammo reference
  108170. */
  108171. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108172. /**
  108173. * Sets the gravity of the physics world (m/(s^2))
  108174. * @param gravity Gravity to set
  108175. */
  108176. setGravity(gravity: Vector3): void;
  108177. /**
  108178. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108179. * @param timeStep timestep to use in seconds
  108180. */
  108181. setTimeStep(timeStep: number): void;
  108182. /**
  108183. * 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)
  108184. * @param fixedTimeStep fixedTimeStep to use in seconds
  108185. */
  108186. setFixedTimeStep(fixedTimeStep: number): void;
  108187. /**
  108188. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108189. * @param maxSteps the maximum number of steps by the physics engine per frame
  108190. */
  108191. setMaxSteps(maxSteps: number): void;
  108192. /**
  108193. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108194. * @returns the current timestep in seconds
  108195. */
  108196. getTimeStep(): number;
  108197. private _isImpostorInContact;
  108198. private _isImpostorPairInContact;
  108199. private _stepSimulation;
  108200. /**
  108201. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108202. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108203. * After the step the babylon meshes are set to the position of the physics imposters
  108204. * @param delta amount of time to step forward
  108205. * @param impostors array of imposters to update before/after the step
  108206. */
  108207. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108208. private _tmpVector;
  108209. private _tmpMatrix;
  108210. /**
  108211. * Applies an implulse on the imposter
  108212. * @param impostor imposter to apply impulse
  108213. * @param force amount of force to be applied to the imposter
  108214. * @param contactPoint the location to apply the impulse on the imposter
  108215. */
  108216. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108217. /**
  108218. * Applies a force on the imposter
  108219. * @param impostor imposter to apply force
  108220. * @param force amount of force to be applied to the imposter
  108221. * @param contactPoint the location to apply the force on the imposter
  108222. */
  108223. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108224. /**
  108225. * Creates a physics body using the plugin
  108226. * @param impostor the imposter to create the physics body on
  108227. */
  108228. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108229. /**
  108230. * Removes the physics body from the imposter and disposes of the body's memory
  108231. * @param impostor imposter to remove the physics body from
  108232. */
  108233. removePhysicsBody(impostor: PhysicsImpostor): void;
  108234. /**
  108235. * Generates a joint
  108236. * @param impostorJoint the imposter joint to create the joint with
  108237. */
  108238. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108239. /**
  108240. * Removes a joint
  108241. * @param impostorJoint the imposter joint to remove the joint from
  108242. */
  108243. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108244. private _addMeshVerts;
  108245. private _createShape;
  108246. /**
  108247. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108248. * @param impostor imposter containing the physics body and babylon object
  108249. */
  108250. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108251. /**
  108252. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108253. * @param impostor imposter containing the physics body and babylon object
  108254. * @param newPosition new position
  108255. * @param newRotation new rotation
  108256. */
  108257. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108258. /**
  108259. * If this plugin is supported
  108260. * @returns true if its supported
  108261. */
  108262. isSupported(): boolean;
  108263. /**
  108264. * Sets the linear velocity of the physics body
  108265. * @param impostor imposter to set the velocity on
  108266. * @param velocity velocity to set
  108267. */
  108268. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108269. /**
  108270. * Sets the angular velocity of the physics body
  108271. * @param impostor imposter to set the velocity on
  108272. * @param velocity velocity to set
  108273. */
  108274. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108275. /**
  108276. * gets the linear velocity
  108277. * @param impostor imposter to get linear velocity from
  108278. * @returns linear velocity
  108279. */
  108280. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108281. /**
  108282. * gets the angular velocity
  108283. * @param impostor imposter to get angular velocity from
  108284. * @returns angular velocity
  108285. */
  108286. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108287. /**
  108288. * Sets the mass of physics body
  108289. * @param impostor imposter to set the mass on
  108290. * @param mass mass to set
  108291. */
  108292. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108293. /**
  108294. * Gets the mass of the physics body
  108295. * @param impostor imposter to get the mass from
  108296. * @returns mass
  108297. */
  108298. getBodyMass(impostor: PhysicsImpostor): number;
  108299. /**
  108300. * Gets friction of the impostor
  108301. * @param impostor impostor to get friction from
  108302. * @returns friction value
  108303. */
  108304. getBodyFriction(impostor: PhysicsImpostor): number;
  108305. /**
  108306. * Sets friction of the impostor
  108307. * @param impostor impostor to set friction on
  108308. * @param friction friction value
  108309. */
  108310. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108311. /**
  108312. * Gets restitution of the impostor
  108313. * @param impostor impostor to get restitution from
  108314. * @returns restitution value
  108315. */
  108316. getBodyRestitution(impostor: PhysicsImpostor): number;
  108317. /**
  108318. * Sets resitution of the impostor
  108319. * @param impostor impostor to set resitution on
  108320. * @param restitution resitution value
  108321. */
  108322. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108323. /**
  108324. * Sleeps the physics body and stops it from being active
  108325. * @param impostor impostor to sleep
  108326. */
  108327. sleepBody(impostor: PhysicsImpostor): void;
  108328. /**
  108329. * Activates the physics body
  108330. * @param impostor impostor to activate
  108331. */
  108332. wakeUpBody(impostor: PhysicsImpostor): void;
  108333. /**
  108334. * Updates the distance parameters of the joint
  108335. * @param joint joint to update
  108336. * @param maxDistance maximum distance of the joint
  108337. * @param minDistance minimum distance of the joint
  108338. */
  108339. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108340. /**
  108341. * Sets a motor on the joint
  108342. * @param joint joint to set motor on
  108343. * @param speed speed of the motor
  108344. * @param maxForce maximum force of the motor
  108345. * @param motorIndex index of the motor
  108346. */
  108347. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108348. /**
  108349. * Sets the motors limit
  108350. * @param joint joint to set limit on
  108351. * @param upperLimit upper limit
  108352. * @param lowerLimit lower limit
  108353. */
  108354. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108355. /**
  108356. * Syncs the position and rotation of a mesh with the impostor
  108357. * @param mesh mesh to sync
  108358. * @param impostor impostor to update the mesh with
  108359. */
  108360. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108361. /**
  108362. * Gets the radius of the impostor
  108363. * @param impostor impostor to get radius from
  108364. * @returns the radius
  108365. */
  108366. getRadius(impostor: PhysicsImpostor): number;
  108367. /**
  108368. * Gets the box size of the impostor
  108369. * @param impostor impostor to get box size from
  108370. * @param result the resulting box size
  108371. */
  108372. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108373. /**
  108374. * Disposes of the impostor
  108375. */
  108376. dispose(): void;
  108377. }
  108378. }
  108379. declare module BABYLON {
  108380. /** @hidden */
  108381. export var blackAndWhitePixelShader: {
  108382. name: string;
  108383. shader: string;
  108384. };
  108385. }
  108386. declare module BABYLON {
  108387. /**
  108388. * Post process used to render in black and white
  108389. */
  108390. export class BlackAndWhitePostProcess extends PostProcess {
  108391. /**
  108392. * Linear about to convert he result to black and white (default: 1)
  108393. */
  108394. degree: number;
  108395. /**
  108396. * Creates a black and white post process
  108397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  108398. * @param name The name of the effect.
  108399. * @param options The required width/height ratio to downsize to before computing the render pass.
  108400. * @param camera The camera to apply the render pass to.
  108401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108402. * @param engine The engine which the post process will be applied. (default: current engine)
  108403. * @param reusable If the post process can be reused on the same frame. (default: false)
  108404. */
  108405. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108406. }
  108407. }
  108408. declare module BABYLON {
  108409. /**
  108410. * This represents a set of one or more post processes in Babylon.
  108411. * A post process can be used to apply a shader to a texture after it is rendered.
  108412. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108413. */
  108414. export class PostProcessRenderEffect {
  108415. private _postProcesses;
  108416. private _getPostProcesses;
  108417. private _singleInstance;
  108418. private _cameras;
  108419. private _indicesForCamera;
  108420. /**
  108421. * Name of the effect
  108422. * @hidden
  108423. */
  108424. _name: string;
  108425. /**
  108426. * Instantiates a post process render effect.
  108427. * A post process can be used to apply a shader to a texture after it is rendered.
  108428. * @param engine The engine the effect is tied to
  108429. * @param name The name of the effect
  108430. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  108431. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  108432. */
  108433. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  108434. /**
  108435. * Checks if all the post processes in the effect are supported.
  108436. */
  108437. readonly isSupported: boolean;
  108438. /**
  108439. * Updates the current state of the effect
  108440. * @hidden
  108441. */
  108442. _update(): void;
  108443. /**
  108444. * Attaches the effect on cameras
  108445. * @param cameras The camera to attach to.
  108446. * @hidden
  108447. */
  108448. _attachCameras(cameras: Camera): void;
  108449. /**
  108450. * Attaches the effect on cameras
  108451. * @param cameras The camera to attach to.
  108452. * @hidden
  108453. */
  108454. _attachCameras(cameras: Camera[]): void;
  108455. /**
  108456. * Detatches the effect on cameras
  108457. * @param cameras The camera to detatch from.
  108458. * @hidden
  108459. */
  108460. _detachCameras(cameras: Camera): void;
  108461. /**
  108462. * Detatches the effect on cameras
  108463. * @param cameras The camera to detatch from.
  108464. * @hidden
  108465. */
  108466. _detachCameras(cameras: Camera[]): void;
  108467. /**
  108468. * Enables the effect on given cameras
  108469. * @param cameras The camera to enable.
  108470. * @hidden
  108471. */
  108472. _enable(cameras: Camera): void;
  108473. /**
  108474. * Enables the effect on given cameras
  108475. * @param cameras The camera to enable.
  108476. * @hidden
  108477. */
  108478. _enable(cameras: Nullable<Camera[]>): void;
  108479. /**
  108480. * Disables the effect on the given cameras
  108481. * @param cameras The camera to disable.
  108482. * @hidden
  108483. */
  108484. _disable(cameras: Camera): void;
  108485. /**
  108486. * Disables the effect on the given cameras
  108487. * @param cameras The camera to disable.
  108488. * @hidden
  108489. */
  108490. _disable(cameras: Nullable<Camera[]>): void;
  108491. /**
  108492. * Gets a list of the post processes contained in the effect.
  108493. * @param camera The camera to get the post processes on.
  108494. * @returns The list of the post processes in the effect.
  108495. */
  108496. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  108497. }
  108498. }
  108499. declare module BABYLON {
  108500. /** @hidden */
  108501. export var extractHighlightsPixelShader: {
  108502. name: string;
  108503. shader: string;
  108504. };
  108505. }
  108506. declare module BABYLON {
  108507. /**
  108508. * 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.
  108509. */
  108510. export class ExtractHighlightsPostProcess extends PostProcess {
  108511. /**
  108512. * The luminance threshold, pixels below this value will be set to black.
  108513. */
  108514. threshold: number;
  108515. /** @hidden */
  108516. _exposure: number;
  108517. /**
  108518. * Post process which has the input texture to be used when performing highlight extraction
  108519. * @hidden
  108520. */
  108521. _inputPostProcess: Nullable<PostProcess>;
  108522. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108523. }
  108524. }
  108525. declare module BABYLON {
  108526. /** @hidden */
  108527. export var bloomMergePixelShader: {
  108528. name: string;
  108529. shader: string;
  108530. };
  108531. }
  108532. declare module BABYLON {
  108533. /**
  108534. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108535. */
  108536. export class BloomMergePostProcess extends PostProcess {
  108537. /** Weight of the bloom to be added to the original input. */
  108538. weight: number;
  108539. /**
  108540. * Creates a new instance of @see BloomMergePostProcess
  108541. * @param name The name of the effect.
  108542. * @param originalFromInput Post process which's input will be used for the merge.
  108543. * @param blurred Blurred highlights post process which's output will be used.
  108544. * @param weight Weight of the bloom to be added to the original input.
  108545. * @param options The required width/height ratio to downsize to before computing the render pass.
  108546. * @param camera The camera to apply the render pass to.
  108547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108548. * @param engine The engine which the post process will be applied. (default: current engine)
  108549. * @param reusable If the post process can be reused on the same frame. (default: false)
  108550. * @param textureType Type of textures used when performing the post process. (default: 0)
  108551. * @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)
  108552. */
  108553. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  108554. /** Weight of the bloom to be added to the original input. */
  108555. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108556. }
  108557. }
  108558. declare module BABYLON {
  108559. /**
  108560. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  108561. */
  108562. export class BloomEffect extends PostProcessRenderEffect {
  108563. private bloomScale;
  108564. /**
  108565. * @hidden Internal
  108566. */
  108567. _effects: Array<PostProcess>;
  108568. /**
  108569. * @hidden Internal
  108570. */
  108571. _downscale: ExtractHighlightsPostProcess;
  108572. private _blurX;
  108573. private _blurY;
  108574. private _merge;
  108575. /**
  108576. * The luminance threshold to find bright areas of the image to bloom.
  108577. */
  108578. threshold: number;
  108579. /**
  108580. * The strength of the bloom.
  108581. */
  108582. weight: number;
  108583. /**
  108584. * Specifies the size of the bloom blur kernel, relative to the final output size
  108585. */
  108586. kernel: number;
  108587. /**
  108588. * Creates a new instance of @see BloomEffect
  108589. * @param scene The scene the effect belongs to.
  108590. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  108591. * @param bloomKernel The size of the kernel to be used when applying the blur.
  108592. * @param bloomWeight The the strength of bloom.
  108593. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108594. * @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)
  108595. */
  108596. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  108597. /**
  108598. * Disposes each of the internal effects for a given camera.
  108599. * @param camera The camera to dispose the effect on.
  108600. */
  108601. disposeEffects(camera: Camera): void;
  108602. /**
  108603. * @hidden Internal
  108604. */
  108605. _updateEffects(): void;
  108606. /**
  108607. * Internal
  108608. * @returns if all the contained post processes are ready.
  108609. * @hidden
  108610. */
  108611. _isReady(): boolean;
  108612. }
  108613. }
  108614. declare module BABYLON {
  108615. /** @hidden */
  108616. export var chromaticAberrationPixelShader: {
  108617. name: string;
  108618. shader: string;
  108619. };
  108620. }
  108621. declare module BABYLON {
  108622. /**
  108623. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  108624. */
  108625. export class ChromaticAberrationPostProcess extends PostProcess {
  108626. /**
  108627. * The amount of seperation of rgb channels (default: 30)
  108628. */
  108629. aberrationAmount: number;
  108630. /**
  108631. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  108632. */
  108633. radialIntensity: number;
  108634. /**
  108635. * 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))
  108636. */
  108637. direction: Vector2;
  108638. /**
  108639. * 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))
  108640. */
  108641. centerPosition: Vector2;
  108642. /**
  108643. * Creates a new instance ChromaticAberrationPostProcess
  108644. * @param name The name of the effect.
  108645. * @param screenWidth The width of the screen to apply the effect on.
  108646. * @param screenHeight The height of the screen to apply the effect on.
  108647. * @param options The required width/height ratio to downsize to before computing the render pass.
  108648. * @param camera The camera to apply the render pass to.
  108649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108650. * @param engine The engine which the post process will be applied. (default: current engine)
  108651. * @param reusable If the post process can be reused on the same frame. (default: false)
  108652. * @param textureType Type of textures used when performing the post process. (default: 0)
  108653. * @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)
  108654. */
  108655. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108656. }
  108657. }
  108658. declare module BABYLON {
  108659. /** @hidden */
  108660. export var circleOfConfusionPixelShader: {
  108661. name: string;
  108662. shader: string;
  108663. };
  108664. }
  108665. declare module BABYLON {
  108666. /**
  108667. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  108668. */
  108669. export class CircleOfConfusionPostProcess extends PostProcess {
  108670. /**
  108671. * 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.
  108672. */
  108673. lensSize: number;
  108674. /**
  108675. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108676. */
  108677. fStop: number;
  108678. /**
  108679. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108680. */
  108681. focusDistance: number;
  108682. /**
  108683. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  108684. */
  108685. focalLength: number;
  108686. private _depthTexture;
  108687. /**
  108688. * Creates a new instance CircleOfConfusionPostProcess
  108689. * @param name The name of the effect.
  108690. * @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.
  108691. * @param options The required width/height ratio to downsize to before computing the render pass.
  108692. * @param camera The camera to apply the render pass to.
  108693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108694. * @param engine The engine which the post process will be applied. (default: current engine)
  108695. * @param reusable If the post process can be reused on the same frame. (default: false)
  108696. * @param textureType Type of textures used when performing the post process. (default: 0)
  108697. * @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)
  108698. */
  108699. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108700. /**
  108701. * 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.
  108702. */
  108703. depthTexture: RenderTargetTexture;
  108704. }
  108705. }
  108706. declare module BABYLON {
  108707. /** @hidden */
  108708. export var colorCorrectionPixelShader: {
  108709. name: string;
  108710. shader: string;
  108711. };
  108712. }
  108713. declare module BABYLON {
  108714. /**
  108715. *
  108716. * This post-process allows the modification of rendered colors by using
  108717. * a 'look-up table' (LUT). This effect is also called Color Grading.
  108718. *
  108719. * The object needs to be provided an url to a texture containing the color
  108720. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  108721. * Use an image editing software to tweak the LUT to match your needs.
  108722. *
  108723. * For an example of a color LUT, see here:
  108724. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  108725. * For explanations on color grading, see here:
  108726. * @see http://udn.epicgames.com/Three/ColorGrading.html
  108727. *
  108728. */
  108729. export class ColorCorrectionPostProcess extends PostProcess {
  108730. private _colorTableTexture;
  108731. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108732. }
  108733. }
  108734. declare module BABYLON {
  108735. /** @hidden */
  108736. export var convolutionPixelShader: {
  108737. name: string;
  108738. shader: string;
  108739. };
  108740. }
  108741. declare module BABYLON {
  108742. /**
  108743. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  108744. * input texture to perform effects such as edge detection or sharpening
  108745. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108746. */
  108747. export class ConvolutionPostProcess extends PostProcess {
  108748. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108749. kernel: number[];
  108750. /**
  108751. * Creates a new instance ConvolutionPostProcess
  108752. * @param name The name of the effect.
  108753. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  108754. * @param options The required width/height ratio to downsize to before computing the render pass.
  108755. * @param camera The camera to apply the render pass to.
  108756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108757. * @param engine The engine which the post process will be applied. (default: current engine)
  108758. * @param reusable If the post process can be reused on the same frame. (default: false)
  108759. * @param textureType Type of textures used when performing the post process. (default: 0)
  108760. */
  108761. constructor(name: string,
  108762. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108763. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108764. /**
  108765. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108766. */
  108767. static EdgeDetect0Kernel: number[];
  108768. /**
  108769. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108770. */
  108771. static EdgeDetect1Kernel: number[];
  108772. /**
  108773. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108774. */
  108775. static EdgeDetect2Kernel: number[];
  108776. /**
  108777. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108778. */
  108779. static SharpenKernel: number[];
  108780. /**
  108781. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108782. */
  108783. static EmbossKernel: number[];
  108784. /**
  108785. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108786. */
  108787. static GaussianKernel: number[];
  108788. }
  108789. }
  108790. declare module BABYLON {
  108791. /**
  108792. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  108793. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  108794. * based on samples that have a large difference in distance than the center pixel.
  108795. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  108796. */
  108797. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  108798. direction: Vector2;
  108799. /**
  108800. * Creates a new instance CircleOfConfusionPostProcess
  108801. * @param name The name of the effect.
  108802. * @param scene The scene the effect belongs to.
  108803. * @param direction The direction the blur should be applied.
  108804. * @param kernel The size of the kernel used to blur.
  108805. * @param options The required width/height ratio to downsize to before computing the render pass.
  108806. * @param camera The camera to apply the render pass to.
  108807. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  108808. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  108809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108810. * @param engine The engine which the post process will be applied. (default: current engine)
  108811. * @param reusable If the post process can be reused on the same frame. (default: false)
  108812. * @param textureType Type of textures used when performing the post process. (default: 0)
  108813. * @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)
  108814. */
  108815. 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);
  108816. }
  108817. }
  108818. declare module BABYLON {
  108819. /** @hidden */
  108820. export var depthOfFieldMergePixelShader: {
  108821. name: string;
  108822. shader: string;
  108823. };
  108824. }
  108825. declare module BABYLON {
  108826. /**
  108827. * Options to be set when merging outputs from the default pipeline.
  108828. */
  108829. export class DepthOfFieldMergePostProcessOptions {
  108830. /**
  108831. * The original image to merge on top of
  108832. */
  108833. originalFromInput: PostProcess;
  108834. /**
  108835. * Parameters to perform the merge of the depth of field effect
  108836. */
  108837. depthOfField?: {
  108838. circleOfConfusion: PostProcess;
  108839. blurSteps: Array<PostProcess>;
  108840. };
  108841. /**
  108842. * Parameters to perform the merge of bloom effect
  108843. */
  108844. bloom?: {
  108845. blurred: PostProcess;
  108846. weight: number;
  108847. };
  108848. }
  108849. /**
  108850. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108851. */
  108852. export class DepthOfFieldMergePostProcess extends PostProcess {
  108853. private blurSteps;
  108854. /**
  108855. * Creates a new instance of DepthOfFieldMergePostProcess
  108856. * @param name The name of the effect.
  108857. * @param originalFromInput Post process which's input will be used for the merge.
  108858. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108859. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108860. * @param options The required width/height ratio to downsize to before computing the render pass.
  108861. * @param camera The camera to apply the render pass to.
  108862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108863. * @param engine The engine which the post process will be applied. (default: current engine)
  108864. * @param reusable If the post process can be reused on the same frame. (default: false)
  108865. * @param textureType Type of textures used when performing the post process. (default: 0)
  108866. * @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)
  108867. */
  108868. 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);
  108869. /**
  108870. * Updates the effect with the current post process compile time values and recompiles the shader.
  108871. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108872. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108873. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108874. * @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
  108875. * @param onCompiled Called when the shader has been compiled.
  108876. * @param onError Called if there is an error when compiling a shader.
  108877. */
  108878. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108879. }
  108880. }
  108881. declare module BABYLON {
  108882. /**
  108883. * Specifies the level of max blur that should be applied when using the depth of field effect
  108884. */
  108885. export enum DepthOfFieldEffectBlurLevel {
  108886. /**
  108887. * Subtle blur
  108888. */
  108889. Low = 0,
  108890. /**
  108891. * Medium blur
  108892. */
  108893. Medium = 1,
  108894. /**
  108895. * Large blur
  108896. */
  108897. High = 2
  108898. }
  108899. /**
  108900. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108901. */
  108902. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108903. private _circleOfConfusion;
  108904. /**
  108905. * @hidden Internal, blurs from high to low
  108906. */
  108907. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108908. private _depthOfFieldBlurY;
  108909. private _dofMerge;
  108910. /**
  108911. * @hidden Internal post processes in depth of field effect
  108912. */
  108913. _effects: Array<PostProcess>;
  108914. /**
  108915. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108916. */
  108917. focalLength: number;
  108918. /**
  108919. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108920. */
  108921. fStop: number;
  108922. /**
  108923. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108924. */
  108925. focusDistance: number;
  108926. /**
  108927. * 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.
  108928. */
  108929. lensSize: number;
  108930. /**
  108931. * Creates a new instance DepthOfFieldEffect
  108932. * @param scene The scene the effect belongs to.
  108933. * @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.
  108934. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108935. * @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)
  108936. */
  108937. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108938. /**
  108939. * 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.
  108940. */
  108941. depthTexture: RenderTargetTexture;
  108942. /**
  108943. * Disposes each of the internal effects for a given camera.
  108944. * @param camera The camera to dispose the effect on.
  108945. */
  108946. disposeEffects(camera: Camera): void;
  108947. /**
  108948. * @hidden Internal
  108949. */
  108950. _updateEffects(): void;
  108951. /**
  108952. * Internal
  108953. * @returns if all the contained post processes are ready.
  108954. * @hidden
  108955. */
  108956. _isReady(): boolean;
  108957. }
  108958. }
  108959. declare module BABYLON {
  108960. /** @hidden */
  108961. export var displayPassPixelShader: {
  108962. name: string;
  108963. shader: string;
  108964. };
  108965. }
  108966. declare module BABYLON {
  108967. /**
  108968. * DisplayPassPostProcess which produces an output the same as it's input
  108969. */
  108970. export class DisplayPassPostProcess extends PostProcess {
  108971. /**
  108972. * Creates the DisplayPassPostProcess
  108973. * @param name The name of the effect.
  108974. * @param options The required width/height ratio to downsize to before computing the render pass.
  108975. * @param camera The camera to apply the render pass to.
  108976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108977. * @param engine The engine which the post process will be applied. (default: current engine)
  108978. * @param reusable If the post process can be reused on the same frame. (default: false)
  108979. */
  108980. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108981. }
  108982. }
  108983. declare module BABYLON {
  108984. /** @hidden */
  108985. export var filterPixelShader: {
  108986. name: string;
  108987. shader: string;
  108988. };
  108989. }
  108990. declare module BABYLON {
  108991. /**
  108992. * Applies a kernel filter to the image
  108993. */
  108994. export class FilterPostProcess extends PostProcess {
  108995. /** The matrix to be applied to the image */
  108996. kernelMatrix: Matrix;
  108997. /**
  108998. *
  108999. * @param name The name of the effect.
  109000. * @param kernelMatrix The matrix to be applied to the image
  109001. * @param options The required width/height ratio to downsize to before computing the render pass.
  109002. * @param camera The camera to apply the render pass to.
  109003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109004. * @param engine The engine which the post process will be applied. (default: current engine)
  109005. * @param reusable If the post process can be reused on the same frame. (default: false)
  109006. */
  109007. constructor(name: string,
  109008. /** The matrix to be applied to the image */
  109009. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109010. }
  109011. }
  109012. declare module BABYLON {
  109013. /** @hidden */
  109014. export var fxaaPixelShader: {
  109015. name: string;
  109016. shader: string;
  109017. };
  109018. }
  109019. declare module BABYLON {
  109020. /** @hidden */
  109021. export var fxaaVertexShader: {
  109022. name: string;
  109023. shader: string;
  109024. };
  109025. }
  109026. declare module BABYLON {
  109027. /**
  109028. * Fxaa post process
  109029. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  109030. */
  109031. export class FxaaPostProcess extends PostProcess {
  109032. /** @hidden */
  109033. texelWidth: number;
  109034. /** @hidden */
  109035. texelHeight: number;
  109036. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109037. private _getDefines;
  109038. }
  109039. }
  109040. declare module BABYLON {
  109041. /** @hidden */
  109042. export var grainPixelShader: {
  109043. name: string;
  109044. shader: string;
  109045. };
  109046. }
  109047. declare module BABYLON {
  109048. /**
  109049. * The GrainPostProcess adds noise to the image at mid luminance levels
  109050. */
  109051. export class GrainPostProcess extends PostProcess {
  109052. /**
  109053. * The intensity of the grain added (default: 30)
  109054. */
  109055. intensity: number;
  109056. /**
  109057. * If the grain should be randomized on every frame
  109058. */
  109059. animated: boolean;
  109060. /**
  109061. * Creates a new instance of @see GrainPostProcess
  109062. * @param name The name of the effect.
  109063. * @param options The required width/height ratio to downsize to before computing the render pass.
  109064. * @param camera The camera to apply the render pass to.
  109065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109066. * @param engine The engine which the post process will be applied. (default: current engine)
  109067. * @param reusable If the post process can be reused on the same frame. (default: false)
  109068. * @param textureType Type of textures used when performing the post process. (default: 0)
  109069. * @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)
  109070. */
  109071. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109072. }
  109073. }
  109074. declare module BABYLON {
  109075. /** @hidden */
  109076. export var highlightsPixelShader: {
  109077. name: string;
  109078. shader: string;
  109079. };
  109080. }
  109081. declare module BABYLON {
  109082. /**
  109083. * Extracts highlights from the image
  109084. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109085. */
  109086. export class HighlightsPostProcess extends PostProcess {
  109087. /**
  109088. * Extracts highlights from the image
  109089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109090. * @param name The name of the effect.
  109091. * @param options The required width/height ratio to downsize to before computing the render pass.
  109092. * @param camera The camera to apply the render pass to.
  109093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109094. * @param engine The engine which the post process will be applied. (default: current engine)
  109095. * @param reusable If the post process can be reused on the same frame. (default: false)
  109096. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  109097. */
  109098. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109099. }
  109100. }
  109101. declare module BABYLON {
  109102. /** @hidden */
  109103. export var mrtFragmentDeclaration: {
  109104. name: string;
  109105. shader: string;
  109106. };
  109107. }
  109108. declare module BABYLON {
  109109. /** @hidden */
  109110. export var geometryPixelShader: {
  109111. name: string;
  109112. shader: string;
  109113. };
  109114. }
  109115. declare module BABYLON {
  109116. /** @hidden */
  109117. export var geometryVertexShader: {
  109118. name: string;
  109119. shader: string;
  109120. };
  109121. }
  109122. declare module BABYLON {
  109123. /**
  109124. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  109125. */
  109126. export class GeometryBufferRenderer {
  109127. /**
  109128. * Constant used to retrieve the position texture index in the G-Buffer textures array
  109129. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  109130. */
  109131. static readonly POSITION_TEXTURE_TYPE: number;
  109132. /**
  109133. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  109134. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  109135. */
  109136. static readonly VELOCITY_TEXTURE_TYPE: number;
  109137. /**
  109138. * Dictionary used to store the previous transformation matrices of each rendered mesh
  109139. * in order to compute objects velocities when enableVelocity is set to "true"
  109140. * @hidden
  109141. */
  109142. _previousTransformationMatrices: {
  109143. [index: number]: Matrix;
  109144. };
  109145. private _scene;
  109146. private _multiRenderTarget;
  109147. private _ratio;
  109148. private _enablePosition;
  109149. private _enableVelocity;
  109150. private _positionIndex;
  109151. private _velocityIndex;
  109152. protected _effect: Effect;
  109153. protected _cachedDefines: string;
  109154. /**
  109155. * Set the render list (meshes to be rendered) used in the G buffer.
  109156. */
  109157. renderList: Mesh[];
  109158. /**
  109159. * Gets wether or not G buffer are supported by the running hardware.
  109160. * This requires draw buffer supports
  109161. */
  109162. readonly isSupported: boolean;
  109163. /**
  109164. * Returns the index of the given texture type in the G-Buffer textures array
  109165. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  109166. * @returns the index of the given texture type in the G-Buffer textures array
  109167. */
  109168. getTextureIndex(textureType: number): number;
  109169. /**
  109170. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  109171. */
  109172. /**
  109173. * Sets whether or not objects positions are enabled for the G buffer.
  109174. */
  109175. enablePosition: boolean;
  109176. /**
  109177. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  109178. */
  109179. /**
  109180. * Sets wether or not objects velocities are enabled for the G buffer.
  109181. */
  109182. enableVelocity: boolean;
  109183. /**
  109184. * Gets the scene associated with the buffer.
  109185. */
  109186. readonly scene: Scene;
  109187. /**
  109188. * Gets the ratio used by the buffer during its creation.
  109189. * How big is the buffer related to the main canvas.
  109190. */
  109191. readonly ratio: number;
  109192. /** @hidden */
  109193. static _SceneComponentInitialization: (scene: Scene) => void;
  109194. /**
  109195. * Creates a new G Buffer for the scene
  109196. * @param scene The scene the buffer belongs to
  109197. * @param ratio How big is the buffer related to the main canvas.
  109198. */
  109199. constructor(scene: Scene, ratio?: number);
  109200. /**
  109201. * Checks wether everything is ready to render a submesh to the G buffer.
  109202. * @param subMesh the submesh to check readiness for
  109203. * @param useInstances is the mesh drawn using instance or not
  109204. * @returns true if ready otherwise false
  109205. */
  109206. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109207. /**
  109208. * Gets the current underlying G Buffer.
  109209. * @returns the buffer
  109210. */
  109211. getGBuffer(): MultiRenderTarget;
  109212. /**
  109213. * Gets the number of samples used to render the buffer (anti aliasing).
  109214. */
  109215. /**
  109216. * Sets the number of samples used to render the buffer (anti aliasing).
  109217. */
  109218. samples: number;
  109219. /**
  109220. * Disposes the renderer and frees up associated resources.
  109221. */
  109222. dispose(): void;
  109223. protected _createRenderTargets(): void;
  109224. }
  109225. }
  109226. declare module BABYLON {
  109227. interface Scene {
  109228. /** @hidden (Backing field) */
  109229. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109230. /**
  109231. * Gets or Sets the current geometry buffer associated to the scene.
  109232. */
  109233. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109234. /**
  109235. * Enables a GeometryBufferRender and associates it with the scene
  109236. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  109237. * @returns the GeometryBufferRenderer
  109238. */
  109239. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  109240. /**
  109241. * Disables the GeometryBufferRender associated with the scene
  109242. */
  109243. disableGeometryBufferRenderer(): void;
  109244. }
  109245. /**
  109246. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  109247. * in several rendering techniques.
  109248. */
  109249. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  109250. /**
  109251. * The component name helpful to identify the component in the list of scene components.
  109252. */
  109253. readonly name: string;
  109254. /**
  109255. * The scene the component belongs to.
  109256. */
  109257. scene: Scene;
  109258. /**
  109259. * Creates a new instance of the component for the given scene
  109260. * @param scene Defines the scene to register the component in
  109261. */
  109262. constructor(scene: Scene);
  109263. /**
  109264. * Registers the component in a given scene
  109265. */
  109266. register(): void;
  109267. /**
  109268. * Rebuilds the elements related to this component in case of
  109269. * context lost for instance.
  109270. */
  109271. rebuild(): void;
  109272. /**
  109273. * Disposes the component and the associated ressources
  109274. */
  109275. dispose(): void;
  109276. private _gatherRenderTargets;
  109277. }
  109278. }
  109279. declare module BABYLON {
  109280. /** @hidden */
  109281. export var motionBlurPixelShader: {
  109282. name: string;
  109283. shader: string;
  109284. };
  109285. }
  109286. declare module BABYLON {
  109287. /**
  109288. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  109289. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  109290. * As an example, all you have to do is to create the post-process:
  109291. * var mb = new BABYLON.MotionBlurPostProcess(
  109292. * 'mb', // The name of the effect.
  109293. * scene, // The scene containing the objects to blur according to their velocity.
  109294. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  109295. * camera // The camera to apply the render pass to.
  109296. * );
  109297. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  109298. */
  109299. export class MotionBlurPostProcess extends PostProcess {
  109300. /**
  109301. * Defines how much the image is blurred by the movement. Default value is equal to 1
  109302. */
  109303. motionStrength: number;
  109304. /**
  109305. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  109306. */
  109307. /**
  109308. * Sets the number of iterations to be used for motion blur quality
  109309. */
  109310. motionBlurSamples: number;
  109311. private _motionBlurSamples;
  109312. private _geometryBufferRenderer;
  109313. /**
  109314. * Creates a new instance MotionBlurPostProcess
  109315. * @param name The name of the effect.
  109316. * @param scene The scene containing the objects to blur according to their velocity.
  109317. * @param options The required width/height ratio to downsize to before computing the render pass.
  109318. * @param camera The camera to apply the render pass to.
  109319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109320. * @param engine The engine which the post process will be applied. (default: current engine)
  109321. * @param reusable If the post process can be reused on the same frame. (default: false)
  109322. * @param textureType Type of textures used when performing the post process. (default: 0)
  109323. * @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)
  109324. */
  109325. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109326. /**
  109327. * Disposes the post process.
  109328. * @param camera The camera to dispose the post process on.
  109329. */
  109330. dispose(camera?: Camera): void;
  109331. }
  109332. }
  109333. declare module BABYLON {
  109334. /** @hidden */
  109335. export var refractionPixelShader: {
  109336. name: string;
  109337. shader: string;
  109338. };
  109339. }
  109340. declare module BABYLON {
  109341. /**
  109342. * Post process which applies a refractin texture
  109343. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  109344. */
  109345. export class RefractionPostProcess extends PostProcess {
  109346. /** the base color of the refraction (used to taint the rendering) */
  109347. color: Color3;
  109348. /** simulated refraction depth */
  109349. depth: number;
  109350. /** the coefficient of the base color (0 to remove base color tainting) */
  109351. colorLevel: number;
  109352. private _refTexture;
  109353. private _ownRefractionTexture;
  109354. /**
  109355. * Gets or sets the refraction texture
  109356. * Please note that you are responsible for disposing the texture if you set it manually
  109357. */
  109358. refractionTexture: Texture;
  109359. /**
  109360. * Initializes the RefractionPostProcess
  109361. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  109362. * @param name The name of the effect.
  109363. * @param refractionTextureUrl Url of the refraction texture to use
  109364. * @param color the base color of the refraction (used to taint the rendering)
  109365. * @param depth simulated refraction depth
  109366. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  109367. * @param camera The camera to apply the render pass to.
  109368. * @param options The required width/height ratio to downsize to before computing the render pass.
  109369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109370. * @param engine The engine which the post process will be applied. (default: current engine)
  109371. * @param reusable If the post process can be reused on the same frame. (default: false)
  109372. */
  109373. constructor(name: string, refractionTextureUrl: string,
  109374. /** the base color of the refraction (used to taint the rendering) */
  109375. color: Color3,
  109376. /** simulated refraction depth */
  109377. depth: number,
  109378. /** the coefficient of the base color (0 to remove base color tainting) */
  109379. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109380. /**
  109381. * Disposes of the post process
  109382. * @param camera Camera to dispose post process on
  109383. */
  109384. dispose(camera: Camera): void;
  109385. }
  109386. }
  109387. declare module BABYLON {
  109388. /** @hidden */
  109389. export var sharpenPixelShader: {
  109390. name: string;
  109391. shader: string;
  109392. };
  109393. }
  109394. declare module BABYLON {
  109395. /**
  109396. * The SharpenPostProcess applies a sharpen kernel to every pixel
  109397. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  109398. */
  109399. export class SharpenPostProcess extends PostProcess {
  109400. /**
  109401. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  109402. */
  109403. colorAmount: number;
  109404. /**
  109405. * How much sharpness should be applied (default: 0.3)
  109406. */
  109407. edgeAmount: number;
  109408. /**
  109409. * Creates a new instance ConvolutionPostProcess
  109410. * @param name The name of the effect.
  109411. * @param options The required width/height ratio to downsize to before computing the render pass.
  109412. * @param camera The camera to apply the render pass to.
  109413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109414. * @param engine The engine which the post process will be applied. (default: current engine)
  109415. * @param reusable If the post process can be reused on the same frame. (default: false)
  109416. * @param textureType Type of textures used when performing the post process. (default: 0)
  109417. * @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)
  109418. */
  109419. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109420. }
  109421. }
  109422. declare module BABYLON {
  109423. /**
  109424. * PostProcessRenderPipeline
  109425. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109426. */
  109427. export class PostProcessRenderPipeline {
  109428. private engine;
  109429. private _renderEffects;
  109430. private _renderEffectsForIsolatedPass;
  109431. /**
  109432. * @hidden
  109433. */
  109434. protected _cameras: Camera[];
  109435. /** @hidden */
  109436. _name: string;
  109437. /**
  109438. * Gets pipeline name
  109439. */
  109440. readonly name: string;
  109441. /**
  109442. * Initializes a PostProcessRenderPipeline
  109443. * @param engine engine to add the pipeline to
  109444. * @param name name of the pipeline
  109445. */
  109446. constructor(engine: Engine, name: string);
  109447. /**
  109448. * Gets the class name
  109449. * @returns "PostProcessRenderPipeline"
  109450. */
  109451. getClassName(): string;
  109452. /**
  109453. * If all the render effects in the pipeline are supported
  109454. */
  109455. readonly isSupported: boolean;
  109456. /**
  109457. * Adds an effect to the pipeline
  109458. * @param renderEffect the effect to add
  109459. */
  109460. addEffect(renderEffect: PostProcessRenderEffect): void;
  109461. /** @hidden */
  109462. _rebuild(): void;
  109463. /** @hidden */
  109464. _enableEffect(renderEffectName: string, cameras: Camera): void;
  109465. /** @hidden */
  109466. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  109467. /** @hidden */
  109468. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109469. /** @hidden */
  109470. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109471. /** @hidden */
  109472. _attachCameras(cameras: Camera, unique: boolean): void;
  109473. /** @hidden */
  109474. _attachCameras(cameras: Camera[], unique: boolean): void;
  109475. /** @hidden */
  109476. _detachCameras(cameras: Camera): void;
  109477. /** @hidden */
  109478. _detachCameras(cameras: Nullable<Camera[]>): void;
  109479. /** @hidden */
  109480. _update(): void;
  109481. /** @hidden */
  109482. _reset(): void;
  109483. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  109484. /**
  109485. * Disposes of the pipeline
  109486. */
  109487. dispose(): void;
  109488. }
  109489. }
  109490. declare module BABYLON {
  109491. /**
  109492. * PostProcessRenderPipelineManager class
  109493. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109494. */
  109495. export class PostProcessRenderPipelineManager {
  109496. private _renderPipelines;
  109497. /**
  109498. * Initializes a PostProcessRenderPipelineManager
  109499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109500. */
  109501. constructor();
  109502. /**
  109503. * Gets the list of supported render pipelines
  109504. */
  109505. readonly supportedPipelines: PostProcessRenderPipeline[];
  109506. /**
  109507. * Adds a pipeline to the manager
  109508. * @param renderPipeline The pipeline to add
  109509. */
  109510. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109511. /**
  109512. * Attaches a camera to the pipeline
  109513. * @param renderPipelineName The name of the pipeline to attach to
  109514. * @param cameras the camera to attach
  109515. * @param unique if the camera can be attached multiple times to the pipeline
  109516. */
  109517. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109518. /**
  109519. * Detaches a camera from the pipeline
  109520. * @param renderPipelineName The name of the pipeline to detach from
  109521. * @param cameras the camera to detach
  109522. */
  109523. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109524. /**
  109525. * Enables an effect by name on a pipeline
  109526. * @param renderPipelineName the name of the pipeline to enable the effect in
  109527. * @param renderEffectName the name of the effect to enable
  109528. * @param cameras the cameras that the effect should be enabled on
  109529. */
  109530. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109531. /**
  109532. * Disables an effect by name on a pipeline
  109533. * @param renderPipelineName the name of the pipeline to disable the effect in
  109534. * @param renderEffectName the name of the effect to disable
  109535. * @param cameras the cameras that the effect should be disabled on
  109536. */
  109537. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109538. /**
  109539. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109540. */
  109541. update(): void;
  109542. /** @hidden */
  109543. _rebuild(): void;
  109544. /**
  109545. * Disposes of the manager and pipelines
  109546. */
  109547. dispose(): void;
  109548. }
  109549. }
  109550. declare module BABYLON {
  109551. interface Scene {
  109552. /** @hidden (Backing field) */
  109553. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109554. /**
  109555. * Gets the postprocess render pipeline manager
  109556. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109557. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109558. */
  109559. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109560. }
  109561. /**
  109562. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109563. */
  109564. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109565. /**
  109566. * The component name helpfull to identify the component in the list of scene components.
  109567. */
  109568. readonly name: string;
  109569. /**
  109570. * The scene the component belongs to.
  109571. */
  109572. scene: Scene;
  109573. /**
  109574. * Creates a new instance of the component for the given scene
  109575. * @param scene Defines the scene to register the component in
  109576. */
  109577. constructor(scene: Scene);
  109578. /**
  109579. * Registers the component in a given scene
  109580. */
  109581. register(): void;
  109582. /**
  109583. * Rebuilds the elements related to this component in case of
  109584. * context lost for instance.
  109585. */
  109586. rebuild(): void;
  109587. /**
  109588. * Disposes the component and the associated ressources
  109589. */
  109590. dispose(): void;
  109591. private _gatherRenderTargets;
  109592. }
  109593. }
  109594. declare module BABYLON {
  109595. /**
  109596. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  109597. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109598. */
  109599. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109600. private _scene;
  109601. private _camerasToBeAttached;
  109602. /**
  109603. * ID of the sharpen post process,
  109604. */
  109605. private readonly SharpenPostProcessId;
  109606. /**
  109607. * @ignore
  109608. * ID of the image processing post process;
  109609. */
  109610. readonly ImageProcessingPostProcessId: string;
  109611. /**
  109612. * @ignore
  109613. * ID of the Fast Approximate Anti-Aliasing post process;
  109614. */
  109615. readonly FxaaPostProcessId: string;
  109616. /**
  109617. * ID of the chromatic aberration post process,
  109618. */
  109619. private readonly ChromaticAberrationPostProcessId;
  109620. /**
  109621. * ID of the grain post process
  109622. */
  109623. private readonly GrainPostProcessId;
  109624. /**
  109625. * Sharpen post process which will apply a sharpen convolution to enhance edges
  109626. */
  109627. sharpen: SharpenPostProcess;
  109628. private _sharpenEffect;
  109629. private bloom;
  109630. /**
  109631. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  109632. */
  109633. depthOfField: DepthOfFieldEffect;
  109634. /**
  109635. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109636. */
  109637. fxaa: FxaaPostProcess;
  109638. /**
  109639. * Image post processing pass used to perform operations such as tone mapping or color grading.
  109640. */
  109641. imageProcessing: ImageProcessingPostProcess;
  109642. /**
  109643. * Chromatic aberration post process which will shift rgb colors in the image
  109644. */
  109645. chromaticAberration: ChromaticAberrationPostProcess;
  109646. private _chromaticAberrationEffect;
  109647. /**
  109648. * Grain post process which add noise to the image
  109649. */
  109650. grain: GrainPostProcess;
  109651. private _grainEffect;
  109652. /**
  109653. * Glow post process which adds a glow to emissive areas of the image
  109654. */
  109655. private _glowLayer;
  109656. /**
  109657. * Animations which can be used to tweak settings over a period of time
  109658. */
  109659. animations: Animation[];
  109660. private _imageProcessingConfigurationObserver;
  109661. private _sharpenEnabled;
  109662. private _bloomEnabled;
  109663. private _depthOfFieldEnabled;
  109664. private _depthOfFieldBlurLevel;
  109665. private _fxaaEnabled;
  109666. private _imageProcessingEnabled;
  109667. private _defaultPipelineTextureType;
  109668. private _bloomScale;
  109669. private _chromaticAberrationEnabled;
  109670. private _grainEnabled;
  109671. private _buildAllowed;
  109672. /**
  109673. * Gets active scene
  109674. */
  109675. readonly scene: Scene;
  109676. /**
  109677. * Enable or disable the sharpen process from the pipeline
  109678. */
  109679. sharpenEnabled: boolean;
  109680. private _resizeObserver;
  109681. private _hardwareScaleLevel;
  109682. private _bloomKernel;
  109683. /**
  109684. * Specifies the size of the bloom blur kernel, relative to the final output size
  109685. */
  109686. bloomKernel: number;
  109687. /**
  109688. * Specifies the weight of the bloom in the final rendering
  109689. */
  109690. private _bloomWeight;
  109691. /**
  109692. * Specifies the luma threshold for the area that will be blurred by the bloom
  109693. */
  109694. private _bloomThreshold;
  109695. private _hdr;
  109696. /**
  109697. * The strength of the bloom.
  109698. */
  109699. bloomWeight: number;
  109700. /**
  109701. * The strength of the bloom.
  109702. */
  109703. bloomThreshold: number;
  109704. /**
  109705. * The scale of the bloom, lower value will provide better performance.
  109706. */
  109707. bloomScale: number;
  109708. /**
  109709. * Enable or disable the bloom from the pipeline
  109710. */
  109711. bloomEnabled: boolean;
  109712. private _rebuildBloom;
  109713. /**
  109714. * If the depth of field is enabled.
  109715. */
  109716. depthOfFieldEnabled: boolean;
  109717. /**
  109718. * Blur level of the depth of field effect. (Higher blur will effect performance)
  109719. */
  109720. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  109721. /**
  109722. * If the anti aliasing is enabled.
  109723. */
  109724. fxaaEnabled: boolean;
  109725. private _samples;
  109726. /**
  109727. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109728. */
  109729. samples: number;
  109730. /**
  109731. * If image processing is enabled.
  109732. */
  109733. imageProcessingEnabled: boolean;
  109734. /**
  109735. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  109736. */
  109737. glowLayerEnabled: boolean;
  109738. /**
  109739. * Enable or disable the chromaticAberration process from the pipeline
  109740. */
  109741. chromaticAberrationEnabled: boolean;
  109742. /**
  109743. * Enable or disable the grain process from the pipeline
  109744. */
  109745. grainEnabled: boolean;
  109746. /**
  109747. * @constructor
  109748. * @param name - The rendering pipeline name (default: "")
  109749. * @param hdr - If high dynamic range textures should be used (default: true)
  109750. * @param scene - The scene linked to this pipeline (default: the last created scene)
  109751. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  109752. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  109753. */
  109754. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  109755. /**
  109756. * Get the class name
  109757. * @returns "DefaultRenderingPipeline"
  109758. */
  109759. getClassName(): string;
  109760. /**
  109761. * Force the compilation of the entire pipeline.
  109762. */
  109763. prepare(): void;
  109764. private _hasCleared;
  109765. private _prevPostProcess;
  109766. private _prevPrevPostProcess;
  109767. private _setAutoClearAndTextureSharing;
  109768. private _depthOfFieldSceneObserver;
  109769. private _buildPipeline;
  109770. private _disposePostProcesses;
  109771. /**
  109772. * Adds a camera to the pipeline
  109773. * @param camera the camera to be added
  109774. */
  109775. addCamera(camera: Camera): void;
  109776. /**
  109777. * Removes a camera from the pipeline
  109778. * @param camera the camera to remove
  109779. */
  109780. removeCamera(camera: Camera): void;
  109781. /**
  109782. * Dispose of the pipeline and stop all post processes
  109783. */
  109784. dispose(): void;
  109785. /**
  109786. * Serialize the rendering pipeline (Used when exporting)
  109787. * @returns the serialized object
  109788. */
  109789. serialize(): any;
  109790. /**
  109791. * Parse the serialized pipeline
  109792. * @param source Source pipeline.
  109793. * @param scene The scene to load the pipeline to.
  109794. * @param rootUrl The URL of the serialized pipeline.
  109795. * @returns An instantiated pipeline from the serialized object.
  109796. */
  109797. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  109798. }
  109799. }
  109800. declare module BABYLON {
  109801. /** @hidden */
  109802. export var lensHighlightsPixelShader: {
  109803. name: string;
  109804. shader: string;
  109805. };
  109806. }
  109807. declare module BABYLON {
  109808. /** @hidden */
  109809. export var depthOfFieldPixelShader: {
  109810. name: string;
  109811. shader: string;
  109812. };
  109813. }
  109814. declare module BABYLON {
  109815. /**
  109816. * BABYLON.JS Chromatic Aberration GLSL Shader
  109817. * Author: Olivier Guyot
  109818. * Separates very slightly R, G and B colors on the edges of the screen
  109819. * Inspired by Francois Tarlier & Martins Upitis
  109820. */
  109821. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  109822. /**
  109823. * @ignore
  109824. * The chromatic aberration PostProcess id in the pipeline
  109825. */
  109826. LensChromaticAberrationEffect: string;
  109827. /**
  109828. * @ignore
  109829. * The highlights enhancing PostProcess id in the pipeline
  109830. */
  109831. HighlightsEnhancingEffect: string;
  109832. /**
  109833. * @ignore
  109834. * The depth-of-field PostProcess id in the pipeline
  109835. */
  109836. LensDepthOfFieldEffect: string;
  109837. private _scene;
  109838. private _depthTexture;
  109839. private _grainTexture;
  109840. private _chromaticAberrationPostProcess;
  109841. private _highlightsPostProcess;
  109842. private _depthOfFieldPostProcess;
  109843. private _edgeBlur;
  109844. private _grainAmount;
  109845. private _chromaticAberration;
  109846. private _distortion;
  109847. private _highlightsGain;
  109848. private _highlightsThreshold;
  109849. private _dofDistance;
  109850. private _dofAperture;
  109851. private _dofDarken;
  109852. private _dofPentagon;
  109853. private _blurNoise;
  109854. /**
  109855. * @constructor
  109856. *
  109857. * Effect parameters are as follow:
  109858. * {
  109859. * chromatic_aberration: number; // from 0 to x (1 for realism)
  109860. * edge_blur: number; // from 0 to x (1 for realism)
  109861. * distortion: number; // from 0 to x (1 for realism)
  109862. * grain_amount: number; // from 0 to 1
  109863. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  109864. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  109865. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  109866. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  109867. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  109868. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  109869. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  109870. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  109871. * }
  109872. * Note: if an effect parameter is unset, effect is disabled
  109873. *
  109874. * @param name The rendering pipeline name
  109875. * @param parameters - An object containing all parameters (see above)
  109876. * @param scene The scene linked to this pipeline
  109877. * @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)
  109878. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109879. */
  109880. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  109881. /**
  109882. * Get the class name
  109883. * @returns "LensRenderingPipeline"
  109884. */
  109885. getClassName(): string;
  109886. /**
  109887. * Gets associated scene
  109888. */
  109889. readonly scene: Scene;
  109890. /**
  109891. * Gets or sets the edge blur
  109892. */
  109893. edgeBlur: number;
  109894. /**
  109895. * Gets or sets the grain amount
  109896. */
  109897. grainAmount: number;
  109898. /**
  109899. * Gets or sets the chromatic aberration amount
  109900. */
  109901. chromaticAberration: number;
  109902. /**
  109903. * Gets or sets the depth of field aperture
  109904. */
  109905. dofAperture: number;
  109906. /**
  109907. * Gets or sets the edge distortion
  109908. */
  109909. edgeDistortion: number;
  109910. /**
  109911. * Gets or sets the depth of field distortion
  109912. */
  109913. dofDistortion: number;
  109914. /**
  109915. * Gets or sets the darken out of focus amount
  109916. */
  109917. darkenOutOfFocus: number;
  109918. /**
  109919. * Gets or sets a boolean indicating if blur noise is enabled
  109920. */
  109921. blurNoise: boolean;
  109922. /**
  109923. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  109924. */
  109925. pentagonBokeh: boolean;
  109926. /**
  109927. * Gets or sets the highlight grain amount
  109928. */
  109929. highlightsGain: number;
  109930. /**
  109931. * Gets or sets the highlight threshold
  109932. */
  109933. highlightsThreshold: number;
  109934. /**
  109935. * Sets the amount of blur at the edges
  109936. * @param amount blur amount
  109937. */
  109938. setEdgeBlur(amount: number): void;
  109939. /**
  109940. * Sets edge blur to 0
  109941. */
  109942. disableEdgeBlur(): void;
  109943. /**
  109944. * Sets the amout of grain
  109945. * @param amount Amount of grain
  109946. */
  109947. setGrainAmount(amount: number): void;
  109948. /**
  109949. * Set grain amount to 0
  109950. */
  109951. disableGrain(): void;
  109952. /**
  109953. * Sets the chromatic aberration amount
  109954. * @param amount amount of chromatic aberration
  109955. */
  109956. setChromaticAberration(amount: number): void;
  109957. /**
  109958. * Sets chromatic aberration amount to 0
  109959. */
  109960. disableChromaticAberration(): void;
  109961. /**
  109962. * Sets the EdgeDistortion amount
  109963. * @param amount amount of EdgeDistortion
  109964. */
  109965. setEdgeDistortion(amount: number): void;
  109966. /**
  109967. * Sets edge distortion to 0
  109968. */
  109969. disableEdgeDistortion(): void;
  109970. /**
  109971. * Sets the FocusDistance amount
  109972. * @param amount amount of FocusDistance
  109973. */
  109974. setFocusDistance(amount: number): void;
  109975. /**
  109976. * Disables depth of field
  109977. */
  109978. disableDepthOfField(): void;
  109979. /**
  109980. * Sets the Aperture amount
  109981. * @param amount amount of Aperture
  109982. */
  109983. setAperture(amount: number): void;
  109984. /**
  109985. * Sets the DarkenOutOfFocus amount
  109986. * @param amount amount of DarkenOutOfFocus
  109987. */
  109988. setDarkenOutOfFocus(amount: number): void;
  109989. private _pentagonBokehIsEnabled;
  109990. /**
  109991. * Creates a pentagon bokeh effect
  109992. */
  109993. enablePentagonBokeh(): void;
  109994. /**
  109995. * Disables the pentagon bokeh effect
  109996. */
  109997. disablePentagonBokeh(): void;
  109998. /**
  109999. * Enables noise blur
  110000. */
  110001. enableNoiseBlur(): void;
  110002. /**
  110003. * Disables noise blur
  110004. */
  110005. disableNoiseBlur(): void;
  110006. /**
  110007. * Sets the HighlightsGain amount
  110008. * @param amount amount of HighlightsGain
  110009. */
  110010. setHighlightsGain(amount: number): void;
  110011. /**
  110012. * Sets the HighlightsThreshold amount
  110013. * @param amount amount of HighlightsThreshold
  110014. */
  110015. setHighlightsThreshold(amount: number): void;
  110016. /**
  110017. * Disables highlights
  110018. */
  110019. disableHighlights(): void;
  110020. /**
  110021. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  110022. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  110023. */
  110024. dispose(disableDepthRender?: boolean): void;
  110025. private _createChromaticAberrationPostProcess;
  110026. private _createHighlightsPostProcess;
  110027. private _createDepthOfFieldPostProcess;
  110028. private _createGrainTexture;
  110029. }
  110030. }
  110031. declare module BABYLON {
  110032. /** @hidden */
  110033. export var ssao2PixelShader: {
  110034. name: string;
  110035. shader: string;
  110036. };
  110037. }
  110038. declare module BABYLON {
  110039. /** @hidden */
  110040. export var ssaoCombinePixelShader: {
  110041. name: string;
  110042. shader: string;
  110043. };
  110044. }
  110045. declare module BABYLON {
  110046. /**
  110047. * Render pipeline to produce ssao effect
  110048. */
  110049. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  110050. /**
  110051. * @ignore
  110052. * The PassPostProcess id in the pipeline that contains the original scene color
  110053. */
  110054. SSAOOriginalSceneColorEffect: string;
  110055. /**
  110056. * @ignore
  110057. * The SSAO PostProcess id in the pipeline
  110058. */
  110059. SSAORenderEffect: string;
  110060. /**
  110061. * @ignore
  110062. * The horizontal blur PostProcess id in the pipeline
  110063. */
  110064. SSAOBlurHRenderEffect: string;
  110065. /**
  110066. * @ignore
  110067. * The vertical blur PostProcess id in the pipeline
  110068. */
  110069. SSAOBlurVRenderEffect: string;
  110070. /**
  110071. * @ignore
  110072. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  110073. */
  110074. SSAOCombineRenderEffect: string;
  110075. /**
  110076. * The output strength of the SSAO post-process. Default value is 1.0.
  110077. */
  110078. totalStrength: number;
  110079. /**
  110080. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  110081. */
  110082. maxZ: number;
  110083. /**
  110084. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  110085. */
  110086. minZAspect: number;
  110087. private _samples;
  110088. /**
  110089. * Number of samples used for the SSAO calculations. Default value is 8
  110090. */
  110091. samples: number;
  110092. private _textureSamples;
  110093. /**
  110094. * Number of samples to use for antialiasing
  110095. */
  110096. textureSamples: number;
  110097. /**
  110098. * Ratio object used for SSAO ratio and blur ratio
  110099. */
  110100. private _ratio;
  110101. /**
  110102. * Dynamically generated sphere sampler.
  110103. */
  110104. private _sampleSphere;
  110105. /**
  110106. * Blur filter offsets
  110107. */
  110108. private _samplerOffsets;
  110109. private _expensiveBlur;
  110110. /**
  110111. * If bilateral blur should be used
  110112. */
  110113. expensiveBlur: boolean;
  110114. /**
  110115. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  110116. */
  110117. radius: number;
  110118. /**
  110119. * The base color of the SSAO post-process
  110120. * The final result is "base + ssao" between [0, 1]
  110121. */
  110122. base: number;
  110123. /**
  110124. * Support test.
  110125. */
  110126. static readonly IsSupported: boolean;
  110127. private _scene;
  110128. private _depthTexture;
  110129. private _normalTexture;
  110130. private _randomTexture;
  110131. private _originalColorPostProcess;
  110132. private _ssaoPostProcess;
  110133. private _blurHPostProcess;
  110134. private _blurVPostProcess;
  110135. private _ssaoCombinePostProcess;
  110136. private _firstUpdate;
  110137. /**
  110138. * Gets active scene
  110139. */
  110140. readonly scene: Scene;
  110141. /**
  110142. * @constructor
  110143. * @param name The rendering pipeline name
  110144. * @param scene The scene linked to this pipeline
  110145. * @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 }
  110146. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110147. */
  110148. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  110149. /**
  110150. * Get the class name
  110151. * @returns "SSAO2RenderingPipeline"
  110152. */
  110153. getClassName(): string;
  110154. /**
  110155. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  110156. */
  110157. dispose(disableGeometryBufferRenderer?: boolean): void;
  110158. private _createBlurPostProcess;
  110159. /** @hidden */
  110160. _rebuild(): void;
  110161. private _bits;
  110162. private _radicalInverse_VdC;
  110163. private _hammersley;
  110164. private _hemisphereSample_uniform;
  110165. private _generateHemisphere;
  110166. private _createSSAOPostProcess;
  110167. private _createSSAOCombinePostProcess;
  110168. private _createRandomTexture;
  110169. /**
  110170. * Serialize the rendering pipeline (Used when exporting)
  110171. * @returns the serialized object
  110172. */
  110173. serialize(): any;
  110174. /**
  110175. * Parse the serialized pipeline
  110176. * @param source Source pipeline.
  110177. * @param scene The scene to load the pipeline to.
  110178. * @param rootUrl The URL of the serialized pipeline.
  110179. * @returns An instantiated pipeline from the serialized object.
  110180. */
  110181. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  110182. }
  110183. }
  110184. declare module BABYLON {
  110185. /** @hidden */
  110186. export var ssaoPixelShader: {
  110187. name: string;
  110188. shader: string;
  110189. };
  110190. }
  110191. declare module BABYLON {
  110192. /**
  110193. * Render pipeline to produce ssao effect
  110194. */
  110195. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  110196. /**
  110197. * @ignore
  110198. * The PassPostProcess id in the pipeline that contains the original scene color
  110199. */
  110200. SSAOOriginalSceneColorEffect: string;
  110201. /**
  110202. * @ignore
  110203. * The SSAO PostProcess id in the pipeline
  110204. */
  110205. SSAORenderEffect: string;
  110206. /**
  110207. * @ignore
  110208. * The horizontal blur PostProcess id in the pipeline
  110209. */
  110210. SSAOBlurHRenderEffect: string;
  110211. /**
  110212. * @ignore
  110213. * The vertical blur PostProcess id in the pipeline
  110214. */
  110215. SSAOBlurVRenderEffect: string;
  110216. /**
  110217. * @ignore
  110218. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  110219. */
  110220. SSAOCombineRenderEffect: string;
  110221. /**
  110222. * The output strength of the SSAO post-process. Default value is 1.0.
  110223. */
  110224. totalStrength: number;
  110225. /**
  110226. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  110227. */
  110228. radius: number;
  110229. /**
  110230. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  110231. * Must not be equal to fallOff and superior to fallOff.
  110232. * Default value is 0.0075
  110233. */
  110234. area: number;
  110235. /**
  110236. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  110237. * Must not be equal to area and inferior to area.
  110238. * Default value is 0.000001
  110239. */
  110240. fallOff: number;
  110241. /**
  110242. * The base color of the SSAO post-process
  110243. * The final result is "base + ssao" between [0, 1]
  110244. */
  110245. base: number;
  110246. private _scene;
  110247. private _depthTexture;
  110248. private _randomTexture;
  110249. private _originalColorPostProcess;
  110250. private _ssaoPostProcess;
  110251. private _blurHPostProcess;
  110252. private _blurVPostProcess;
  110253. private _ssaoCombinePostProcess;
  110254. private _firstUpdate;
  110255. /**
  110256. * Gets active scene
  110257. */
  110258. readonly scene: Scene;
  110259. /**
  110260. * @constructor
  110261. * @param name - The rendering pipeline name
  110262. * @param scene - The scene linked to this pipeline
  110263. * @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 }
  110264. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  110265. */
  110266. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  110267. /**
  110268. * Get the class name
  110269. * @returns "SSAORenderingPipeline"
  110270. */
  110271. getClassName(): string;
  110272. /**
  110273. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  110274. */
  110275. dispose(disableDepthRender?: boolean): void;
  110276. private _createBlurPostProcess;
  110277. /** @hidden */
  110278. _rebuild(): void;
  110279. private _createSSAOPostProcess;
  110280. private _createSSAOCombinePostProcess;
  110281. private _createRandomTexture;
  110282. }
  110283. }
  110284. declare module BABYLON {
  110285. /** @hidden */
  110286. export var standardPixelShader: {
  110287. name: string;
  110288. shader: string;
  110289. };
  110290. }
  110291. declare module BABYLON {
  110292. /**
  110293. * Standard rendering pipeline
  110294. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110295. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  110296. */
  110297. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  110298. /**
  110299. * Public members
  110300. */
  110301. /**
  110302. * Post-process which contains the original scene color before the pipeline applies all the effects
  110303. */
  110304. originalPostProcess: Nullable<PostProcess>;
  110305. /**
  110306. * Post-process used to down scale an image x4
  110307. */
  110308. downSampleX4PostProcess: Nullable<PostProcess>;
  110309. /**
  110310. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  110311. */
  110312. brightPassPostProcess: Nullable<PostProcess>;
  110313. /**
  110314. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  110315. */
  110316. blurHPostProcesses: PostProcess[];
  110317. /**
  110318. * Post-process array storing all the vertical blur post-processes used by the pipeline
  110319. */
  110320. blurVPostProcesses: PostProcess[];
  110321. /**
  110322. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  110323. */
  110324. textureAdderPostProcess: Nullable<PostProcess>;
  110325. /**
  110326. * Post-process used to create volumetric lighting effect
  110327. */
  110328. volumetricLightPostProcess: Nullable<PostProcess>;
  110329. /**
  110330. * Post-process used to smooth the previous volumetric light post-process on the X axis
  110331. */
  110332. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  110333. /**
  110334. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  110335. */
  110336. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  110337. /**
  110338. * Post-process used to merge the volumetric light effect and the real scene color
  110339. */
  110340. volumetricLightMergePostProces: Nullable<PostProcess>;
  110341. /**
  110342. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  110343. */
  110344. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  110345. /**
  110346. * Base post-process used to calculate the average luminance of the final image for HDR
  110347. */
  110348. luminancePostProcess: Nullable<PostProcess>;
  110349. /**
  110350. * Post-processes used to create down sample post-processes in order to get
  110351. * the average luminance of the final image for HDR
  110352. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  110353. */
  110354. luminanceDownSamplePostProcesses: PostProcess[];
  110355. /**
  110356. * Post-process used to create a HDR effect (light adaptation)
  110357. */
  110358. hdrPostProcess: Nullable<PostProcess>;
  110359. /**
  110360. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  110361. */
  110362. textureAdderFinalPostProcess: Nullable<PostProcess>;
  110363. /**
  110364. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  110365. */
  110366. lensFlareFinalPostProcess: Nullable<PostProcess>;
  110367. /**
  110368. * Post-process used to merge the final HDR post-process and the real scene color
  110369. */
  110370. hdrFinalPostProcess: Nullable<PostProcess>;
  110371. /**
  110372. * Post-process used to create a lens flare effect
  110373. */
  110374. lensFlarePostProcess: Nullable<PostProcess>;
  110375. /**
  110376. * Post-process that merges the result of the lens flare post-process and the real scene color
  110377. */
  110378. lensFlareComposePostProcess: Nullable<PostProcess>;
  110379. /**
  110380. * Post-process used to create a motion blur effect
  110381. */
  110382. motionBlurPostProcess: Nullable<PostProcess>;
  110383. /**
  110384. * Post-process used to create a depth of field effect
  110385. */
  110386. depthOfFieldPostProcess: Nullable<PostProcess>;
  110387. /**
  110388. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  110389. */
  110390. fxaaPostProcess: Nullable<FxaaPostProcess>;
  110391. /**
  110392. * Represents the brightness threshold in order to configure the illuminated surfaces
  110393. */
  110394. brightThreshold: number;
  110395. /**
  110396. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  110397. */
  110398. blurWidth: number;
  110399. /**
  110400. * Sets if the blur for highlighted surfaces must be only horizontal
  110401. */
  110402. horizontalBlur: boolean;
  110403. /**
  110404. * Sets the overall exposure used by the pipeline
  110405. */
  110406. exposure: number;
  110407. /**
  110408. * Texture used typically to simulate "dirty" on camera lens
  110409. */
  110410. lensTexture: Nullable<Texture>;
  110411. /**
  110412. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  110413. */
  110414. volumetricLightCoefficient: number;
  110415. /**
  110416. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  110417. */
  110418. volumetricLightPower: number;
  110419. /**
  110420. * Used the set the blur intensity to smooth the volumetric lights
  110421. */
  110422. volumetricLightBlurScale: number;
  110423. /**
  110424. * Light (spot or directional) used to generate the volumetric lights rays
  110425. * The source light must have a shadow generate so the pipeline can get its
  110426. * depth map
  110427. */
  110428. sourceLight: Nullable<SpotLight | DirectionalLight>;
  110429. /**
  110430. * For eye adaptation, represents the minimum luminance the eye can see
  110431. */
  110432. hdrMinimumLuminance: number;
  110433. /**
  110434. * For eye adaptation, represents the decrease luminance speed
  110435. */
  110436. hdrDecreaseRate: number;
  110437. /**
  110438. * For eye adaptation, represents the increase luminance speed
  110439. */
  110440. hdrIncreaseRate: number;
  110441. /**
  110442. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  110443. */
  110444. lensColorTexture: Nullable<Texture>;
  110445. /**
  110446. * The overall strengh for the lens flare effect
  110447. */
  110448. lensFlareStrength: number;
  110449. /**
  110450. * Dispersion coefficient for lens flare ghosts
  110451. */
  110452. lensFlareGhostDispersal: number;
  110453. /**
  110454. * Main lens flare halo width
  110455. */
  110456. lensFlareHaloWidth: number;
  110457. /**
  110458. * Based on the lens distortion effect, defines how much the lens flare result
  110459. * is distorted
  110460. */
  110461. lensFlareDistortionStrength: number;
  110462. /**
  110463. * Lens star texture must be used to simulate rays on the flares and is available
  110464. * in the documentation
  110465. */
  110466. lensStarTexture: Nullable<Texture>;
  110467. /**
  110468. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  110469. * flare effect by taking account of the dirt texture
  110470. */
  110471. lensFlareDirtTexture: Nullable<Texture>;
  110472. /**
  110473. * Represents the focal length for the depth of field effect
  110474. */
  110475. depthOfFieldDistance: number;
  110476. /**
  110477. * Represents the blur intensity for the blurred part of the depth of field effect
  110478. */
  110479. depthOfFieldBlurWidth: number;
  110480. /**
  110481. * For motion blur, defines how much the image is blurred by the movement
  110482. */
  110483. motionStrength: number;
  110484. /**
  110485. * List of animations for the pipeline (IAnimatable implementation)
  110486. */
  110487. animations: Animation[];
  110488. /**
  110489. * Private members
  110490. */
  110491. private _scene;
  110492. private _currentDepthOfFieldSource;
  110493. private _basePostProcess;
  110494. private _hdrCurrentLuminance;
  110495. private _floatTextureType;
  110496. private _ratio;
  110497. private _bloomEnabled;
  110498. private _depthOfFieldEnabled;
  110499. private _vlsEnabled;
  110500. private _lensFlareEnabled;
  110501. private _hdrEnabled;
  110502. private _motionBlurEnabled;
  110503. private _fxaaEnabled;
  110504. private _motionBlurSamples;
  110505. private _volumetricLightStepsCount;
  110506. private _samples;
  110507. /**
  110508. * @ignore
  110509. * Specifies if the bloom pipeline is enabled
  110510. */
  110511. BloomEnabled: boolean;
  110512. /**
  110513. * @ignore
  110514. * Specifies if the depth of field pipeline is enabed
  110515. */
  110516. DepthOfFieldEnabled: boolean;
  110517. /**
  110518. * @ignore
  110519. * Specifies if the lens flare pipeline is enabed
  110520. */
  110521. LensFlareEnabled: boolean;
  110522. /**
  110523. * @ignore
  110524. * Specifies if the HDR pipeline is enabled
  110525. */
  110526. HDREnabled: boolean;
  110527. /**
  110528. * @ignore
  110529. * Specifies if the volumetric lights scattering effect is enabled
  110530. */
  110531. VLSEnabled: boolean;
  110532. /**
  110533. * @ignore
  110534. * Specifies if the motion blur effect is enabled
  110535. */
  110536. MotionBlurEnabled: boolean;
  110537. /**
  110538. * Specifies if anti-aliasing is enabled
  110539. */
  110540. fxaaEnabled: boolean;
  110541. /**
  110542. * Specifies the number of steps used to calculate the volumetric lights
  110543. * Typically in interval [50, 200]
  110544. */
  110545. volumetricLightStepsCount: number;
  110546. /**
  110547. * Specifies the number of samples used for the motion blur effect
  110548. * Typically in interval [16, 64]
  110549. */
  110550. motionBlurSamples: number;
  110551. /**
  110552. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110553. */
  110554. samples: number;
  110555. /**
  110556. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110557. * @constructor
  110558. * @param name The rendering pipeline name
  110559. * @param scene The scene linked to this pipeline
  110560. * @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)
  110561. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  110562. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110563. */
  110564. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  110565. private _buildPipeline;
  110566. private _createDownSampleX4PostProcess;
  110567. private _createBrightPassPostProcess;
  110568. private _createBlurPostProcesses;
  110569. private _createTextureAdderPostProcess;
  110570. private _createVolumetricLightPostProcess;
  110571. private _createLuminancePostProcesses;
  110572. private _createHdrPostProcess;
  110573. private _createLensFlarePostProcess;
  110574. private _createDepthOfFieldPostProcess;
  110575. private _createMotionBlurPostProcess;
  110576. private _getDepthTexture;
  110577. private _disposePostProcesses;
  110578. /**
  110579. * Dispose of the pipeline and stop all post processes
  110580. */
  110581. dispose(): void;
  110582. /**
  110583. * Serialize the rendering pipeline (Used when exporting)
  110584. * @returns the serialized object
  110585. */
  110586. serialize(): any;
  110587. /**
  110588. * Parse the serialized pipeline
  110589. * @param source Source pipeline.
  110590. * @param scene The scene to load the pipeline to.
  110591. * @param rootUrl The URL of the serialized pipeline.
  110592. * @returns An instantiated pipeline from the serialized object.
  110593. */
  110594. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  110595. /**
  110596. * Luminance steps
  110597. */
  110598. static LuminanceSteps: number;
  110599. }
  110600. }
  110601. declare module BABYLON {
  110602. /** @hidden */
  110603. export var tonemapPixelShader: {
  110604. name: string;
  110605. shader: string;
  110606. };
  110607. }
  110608. declare module BABYLON {
  110609. /** Defines operator used for tonemapping */
  110610. export enum TonemappingOperator {
  110611. /** Hable */
  110612. Hable = 0,
  110613. /** Reinhard */
  110614. Reinhard = 1,
  110615. /** HejiDawson */
  110616. HejiDawson = 2,
  110617. /** Photographic */
  110618. Photographic = 3
  110619. }
  110620. /**
  110621. * Defines a post process to apply tone mapping
  110622. */
  110623. export class TonemapPostProcess extends PostProcess {
  110624. private _operator;
  110625. /** Defines the required exposure adjustement */
  110626. exposureAdjustment: number;
  110627. /**
  110628. * Creates a new TonemapPostProcess
  110629. * @param name defines the name of the postprocess
  110630. * @param _operator defines the operator to use
  110631. * @param exposureAdjustment defines the required exposure adjustement
  110632. * @param camera defines the camera to use (can be null)
  110633. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  110634. * @param engine defines the hosting engine (can be ignore if camera is set)
  110635. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  110636. */
  110637. constructor(name: string, _operator: TonemappingOperator,
  110638. /** Defines the required exposure adjustement */
  110639. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  110640. }
  110641. }
  110642. declare module BABYLON {
  110643. /** @hidden */
  110644. export var depthVertexShader: {
  110645. name: string;
  110646. shader: string;
  110647. };
  110648. }
  110649. declare module BABYLON {
  110650. /** @hidden */
  110651. export var volumetricLightScatteringPixelShader: {
  110652. name: string;
  110653. shader: string;
  110654. };
  110655. }
  110656. declare module BABYLON {
  110657. /** @hidden */
  110658. export var volumetricLightScatteringPassPixelShader: {
  110659. name: string;
  110660. shader: string;
  110661. };
  110662. }
  110663. declare module BABYLON {
  110664. /**
  110665. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  110666. */
  110667. export class VolumetricLightScatteringPostProcess extends PostProcess {
  110668. private _volumetricLightScatteringPass;
  110669. private _volumetricLightScatteringRTT;
  110670. private _viewPort;
  110671. private _screenCoordinates;
  110672. private _cachedDefines;
  110673. /**
  110674. * If not undefined, the mesh position is computed from the attached node position
  110675. */
  110676. attachedNode: {
  110677. position: Vector3;
  110678. };
  110679. /**
  110680. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  110681. */
  110682. customMeshPosition: Vector3;
  110683. /**
  110684. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  110685. */
  110686. useCustomMeshPosition: boolean;
  110687. /**
  110688. * If the post-process should inverse the light scattering direction
  110689. */
  110690. invert: boolean;
  110691. /**
  110692. * The internal mesh used by the post-process
  110693. */
  110694. mesh: Mesh;
  110695. /**
  110696. * @hidden
  110697. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  110698. */
  110699. useDiffuseColor: boolean;
  110700. /**
  110701. * Array containing the excluded meshes not rendered in the internal pass
  110702. */
  110703. excludedMeshes: AbstractMesh[];
  110704. /**
  110705. * Controls the overall intensity of the post-process
  110706. */
  110707. exposure: number;
  110708. /**
  110709. * Dissipates each sample's contribution in range [0, 1]
  110710. */
  110711. decay: number;
  110712. /**
  110713. * Controls the overall intensity of each sample
  110714. */
  110715. weight: number;
  110716. /**
  110717. * Controls the density of each sample
  110718. */
  110719. density: number;
  110720. /**
  110721. * @constructor
  110722. * @param name The post-process name
  110723. * @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)
  110724. * @param camera The camera that the post-process will be attached to
  110725. * @param mesh The mesh used to create the light scattering
  110726. * @param samples The post-process quality, default 100
  110727. * @param samplingModeThe post-process filtering mode
  110728. * @param engine The babylon engine
  110729. * @param reusable If the post-process is reusable
  110730. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  110731. */
  110732. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  110733. /**
  110734. * Returns the string "VolumetricLightScatteringPostProcess"
  110735. * @returns "VolumetricLightScatteringPostProcess"
  110736. */
  110737. getClassName(): string;
  110738. private _isReady;
  110739. /**
  110740. * Sets the new light position for light scattering effect
  110741. * @param position The new custom light position
  110742. */
  110743. setCustomMeshPosition(position: Vector3): void;
  110744. /**
  110745. * Returns the light position for light scattering effect
  110746. * @return Vector3 The custom light position
  110747. */
  110748. getCustomMeshPosition(): Vector3;
  110749. /**
  110750. * Disposes the internal assets and detaches the post-process from the camera
  110751. */
  110752. dispose(camera: Camera): void;
  110753. /**
  110754. * Returns the render target texture used by the post-process
  110755. * @return the render target texture used by the post-process
  110756. */
  110757. getPass(): RenderTargetTexture;
  110758. private _meshExcluded;
  110759. private _createPass;
  110760. private _updateMeshScreenCoordinates;
  110761. /**
  110762. * Creates a default mesh for the Volumeric Light Scattering post-process
  110763. * @param name The mesh name
  110764. * @param scene The scene where to create the mesh
  110765. * @return the default mesh
  110766. */
  110767. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  110768. }
  110769. }
  110770. declare module BABYLON {
  110771. interface Scene {
  110772. /** @hidden (Backing field) */
  110773. _boundingBoxRenderer: BoundingBoxRenderer;
  110774. /** @hidden (Backing field) */
  110775. _forceShowBoundingBoxes: boolean;
  110776. /**
  110777. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  110778. */
  110779. forceShowBoundingBoxes: boolean;
  110780. /**
  110781. * Gets the bounding box renderer associated with the scene
  110782. * @returns a BoundingBoxRenderer
  110783. */
  110784. getBoundingBoxRenderer(): BoundingBoxRenderer;
  110785. }
  110786. interface AbstractMesh {
  110787. /** @hidden (Backing field) */
  110788. _showBoundingBox: boolean;
  110789. /**
  110790. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  110791. */
  110792. showBoundingBox: boolean;
  110793. }
  110794. /**
  110795. * Component responsible of rendering the bounding box of the meshes in a scene.
  110796. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  110797. */
  110798. export class BoundingBoxRenderer implements ISceneComponent {
  110799. /**
  110800. * The component name helpfull to identify the component in the list of scene components.
  110801. */
  110802. readonly name: string;
  110803. /**
  110804. * The scene the component belongs to.
  110805. */
  110806. scene: Scene;
  110807. /**
  110808. * Color of the bounding box lines placed in front of an object
  110809. */
  110810. frontColor: Color3;
  110811. /**
  110812. * Color of the bounding box lines placed behind an object
  110813. */
  110814. backColor: Color3;
  110815. /**
  110816. * Defines if the renderer should show the back lines or not
  110817. */
  110818. showBackLines: boolean;
  110819. /**
  110820. * @hidden
  110821. */
  110822. renderList: SmartArray<BoundingBox>;
  110823. private _colorShader;
  110824. private _vertexBuffers;
  110825. private _indexBuffer;
  110826. /**
  110827. * Instantiates a new bounding box renderer in a scene.
  110828. * @param scene the scene the renderer renders in
  110829. */
  110830. constructor(scene: Scene);
  110831. /**
  110832. * Registers the component in a given scene
  110833. */
  110834. register(): void;
  110835. private _evaluateSubMesh;
  110836. private _activeMesh;
  110837. private _prepareRessources;
  110838. private _createIndexBuffer;
  110839. /**
  110840. * Rebuilds the elements related to this component in case of
  110841. * context lost for instance.
  110842. */
  110843. rebuild(): void;
  110844. /**
  110845. * @hidden
  110846. */
  110847. reset(): void;
  110848. /**
  110849. * Render the bounding boxes of a specific rendering group
  110850. * @param renderingGroupId defines the rendering group to render
  110851. */
  110852. render(renderingGroupId: number): void;
  110853. /**
  110854. * In case of occlusion queries, we can render the occlusion bounding box through this method
  110855. * @param mesh Define the mesh to render the occlusion bounding box for
  110856. */
  110857. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  110858. /**
  110859. * Dispose and release the resources attached to this renderer.
  110860. */
  110861. dispose(): void;
  110862. }
  110863. }
  110864. declare module BABYLON {
  110865. /** @hidden */
  110866. export var depthPixelShader: {
  110867. name: string;
  110868. shader: string;
  110869. };
  110870. }
  110871. declare module BABYLON {
  110872. /**
  110873. * This represents a depth renderer in Babylon.
  110874. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  110875. */
  110876. export class DepthRenderer {
  110877. private _scene;
  110878. private _depthMap;
  110879. private _effect;
  110880. private _cachedDefines;
  110881. private _camera;
  110882. /**
  110883. * Specifiess that the depth renderer will only be used within
  110884. * the camera it is created for.
  110885. * This can help forcing its rendering during the camera processing.
  110886. */
  110887. useOnlyInActiveCamera: boolean;
  110888. /** @hidden */
  110889. static _SceneComponentInitialization: (scene: Scene) => void;
  110890. /**
  110891. * Instantiates a depth renderer
  110892. * @param scene The scene the renderer belongs to
  110893. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  110894. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  110895. */
  110896. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  110897. /**
  110898. * Creates the depth rendering effect and checks if the effect is ready.
  110899. * @param subMesh The submesh to be used to render the depth map of
  110900. * @param useInstances If multiple world instances should be used
  110901. * @returns if the depth renderer is ready to render the depth map
  110902. */
  110903. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110904. /**
  110905. * Gets the texture which the depth map will be written to.
  110906. * @returns The depth map texture
  110907. */
  110908. getDepthMap(): RenderTargetTexture;
  110909. /**
  110910. * Disposes of the depth renderer.
  110911. */
  110912. dispose(): void;
  110913. }
  110914. }
  110915. declare module BABYLON {
  110916. interface Scene {
  110917. /** @hidden (Backing field) */
  110918. _depthRenderer: {
  110919. [id: string]: DepthRenderer;
  110920. };
  110921. /**
  110922. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  110923. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  110924. * @returns the created depth renderer
  110925. */
  110926. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  110927. /**
  110928. * Disables a depth renderer for a given camera
  110929. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  110930. */
  110931. disableDepthRenderer(camera?: Nullable<Camera>): void;
  110932. }
  110933. /**
  110934. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  110935. * in several rendering techniques.
  110936. */
  110937. export class DepthRendererSceneComponent implements ISceneComponent {
  110938. /**
  110939. * The component name helpfull to identify the component in the list of scene components.
  110940. */
  110941. readonly name: string;
  110942. /**
  110943. * The scene the component belongs to.
  110944. */
  110945. scene: Scene;
  110946. /**
  110947. * Creates a new instance of the component for the given scene
  110948. * @param scene Defines the scene to register the component in
  110949. */
  110950. constructor(scene: Scene);
  110951. /**
  110952. * Registers the component in a given scene
  110953. */
  110954. register(): void;
  110955. /**
  110956. * Rebuilds the elements related to this component in case of
  110957. * context lost for instance.
  110958. */
  110959. rebuild(): void;
  110960. /**
  110961. * Disposes the component and the associated ressources
  110962. */
  110963. dispose(): void;
  110964. private _gatherRenderTargets;
  110965. private _gatherActiveCameraRenderTargets;
  110966. }
  110967. }
  110968. declare module BABYLON {
  110969. /** @hidden */
  110970. export var outlinePixelShader: {
  110971. name: string;
  110972. shader: string;
  110973. };
  110974. }
  110975. declare module BABYLON {
  110976. /** @hidden */
  110977. export var outlineVertexShader: {
  110978. name: string;
  110979. shader: string;
  110980. };
  110981. }
  110982. declare module BABYLON {
  110983. interface Scene {
  110984. /** @hidden */
  110985. _outlineRenderer: OutlineRenderer;
  110986. /**
  110987. * Gets the outline renderer associated with the scene
  110988. * @returns a OutlineRenderer
  110989. */
  110990. getOutlineRenderer(): OutlineRenderer;
  110991. }
  110992. interface AbstractMesh {
  110993. /** @hidden (Backing field) */
  110994. _renderOutline: boolean;
  110995. /**
  110996. * Gets or sets a boolean indicating if the outline must be rendered as well
  110997. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110998. */
  110999. renderOutline: boolean;
  111000. /** @hidden (Backing field) */
  111001. _renderOverlay: boolean;
  111002. /**
  111003. * Gets or sets a boolean indicating if the overlay must be rendered as well
  111004. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  111005. */
  111006. renderOverlay: boolean;
  111007. }
  111008. /**
  111009. * This class is responsible to draw bothe outline/overlay of meshes.
  111010. * It should not be used directly but through the available method on mesh.
  111011. */
  111012. export class OutlineRenderer implements ISceneComponent {
  111013. /**
  111014. * The name of the component. Each component must have a unique name.
  111015. */
  111016. name: string;
  111017. /**
  111018. * The scene the component belongs to.
  111019. */
  111020. scene: Scene;
  111021. /**
  111022. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  111023. */
  111024. zOffset: number;
  111025. private _engine;
  111026. private _effect;
  111027. private _cachedDefines;
  111028. private _savedDepthWrite;
  111029. /**
  111030. * Instantiates a new outline renderer. (There could be only one per scene).
  111031. * @param scene Defines the scene it belongs to
  111032. */
  111033. constructor(scene: Scene);
  111034. /**
  111035. * Register the component to one instance of a scene.
  111036. */
  111037. register(): void;
  111038. /**
  111039. * Rebuilds the elements related to this component in case of
  111040. * context lost for instance.
  111041. */
  111042. rebuild(): void;
  111043. /**
  111044. * Disposes the component and the associated ressources.
  111045. */
  111046. dispose(): void;
  111047. /**
  111048. * Renders the outline in the canvas.
  111049. * @param subMesh Defines the sumesh to render
  111050. * @param batch Defines the batch of meshes in case of instances
  111051. * @param useOverlay Defines if the rendering is for the overlay or the outline
  111052. */
  111053. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  111054. /**
  111055. * Returns whether or not the outline renderer is ready for a given submesh.
  111056. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  111057. * @param subMesh Defines the submesh to check readyness for
  111058. * @param useInstances Defines wheter wee are trying to render instances or not
  111059. * @returns true if ready otherwise false
  111060. */
  111061. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111062. private _beforeRenderingMesh;
  111063. private _afterRenderingMesh;
  111064. }
  111065. }
  111066. declare module BABYLON {
  111067. /**
  111068. * Defines the list of states available for a task inside a AssetsManager
  111069. */
  111070. export enum AssetTaskState {
  111071. /**
  111072. * Initialization
  111073. */
  111074. INIT = 0,
  111075. /**
  111076. * Running
  111077. */
  111078. RUNNING = 1,
  111079. /**
  111080. * Done
  111081. */
  111082. DONE = 2,
  111083. /**
  111084. * Error
  111085. */
  111086. ERROR = 3
  111087. }
  111088. /**
  111089. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  111090. */
  111091. export abstract class AbstractAssetTask {
  111092. /**
  111093. * Task name
  111094. */ name: string;
  111095. /**
  111096. * Callback called when the task is successful
  111097. */
  111098. onSuccess: (task: any) => void;
  111099. /**
  111100. * Callback called when the task is not successful
  111101. */
  111102. onError: (task: any, message?: string, exception?: any) => void;
  111103. /**
  111104. * Creates a new AssetsManager
  111105. * @param name defines the name of the task
  111106. */
  111107. constructor(
  111108. /**
  111109. * Task name
  111110. */ name: string);
  111111. private _isCompleted;
  111112. private _taskState;
  111113. private _errorObject;
  111114. /**
  111115. * Get if the task is completed
  111116. */
  111117. readonly isCompleted: boolean;
  111118. /**
  111119. * Gets the current state of the task
  111120. */
  111121. readonly taskState: AssetTaskState;
  111122. /**
  111123. * Gets the current error object (if task is in error)
  111124. */
  111125. readonly errorObject: {
  111126. message?: string;
  111127. exception?: any;
  111128. };
  111129. /**
  111130. * Internal only
  111131. * @hidden
  111132. */
  111133. _setErrorObject(message?: string, exception?: any): void;
  111134. /**
  111135. * Execute the current task
  111136. * @param scene defines the scene where you want your assets to be loaded
  111137. * @param onSuccess is a callback called when the task is successfully executed
  111138. * @param onError is a callback called if an error occurs
  111139. */
  111140. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111141. /**
  111142. * Execute the current task
  111143. * @param scene defines the scene where you want your assets to be loaded
  111144. * @param onSuccess is a callback called when the task is successfully executed
  111145. * @param onError is a callback called if an error occurs
  111146. */
  111147. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111148. /**
  111149. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  111150. * This can be used with failed tasks that have the reason for failure fixed.
  111151. */
  111152. reset(): void;
  111153. private onErrorCallback;
  111154. private onDoneCallback;
  111155. }
  111156. /**
  111157. * Define the interface used by progress events raised during assets loading
  111158. */
  111159. export interface IAssetsProgressEvent {
  111160. /**
  111161. * Defines the number of remaining tasks to process
  111162. */
  111163. remainingCount: number;
  111164. /**
  111165. * Defines the total number of tasks
  111166. */
  111167. totalCount: number;
  111168. /**
  111169. * Defines the task that was just processed
  111170. */
  111171. task: AbstractAssetTask;
  111172. }
  111173. /**
  111174. * Class used to share progress information about assets loading
  111175. */
  111176. export class AssetsProgressEvent implements IAssetsProgressEvent {
  111177. /**
  111178. * Defines the number of remaining tasks to process
  111179. */
  111180. remainingCount: number;
  111181. /**
  111182. * Defines the total number of tasks
  111183. */
  111184. totalCount: number;
  111185. /**
  111186. * Defines the task that was just processed
  111187. */
  111188. task: AbstractAssetTask;
  111189. /**
  111190. * Creates a AssetsProgressEvent
  111191. * @param remainingCount defines the number of remaining tasks to process
  111192. * @param totalCount defines the total number of tasks
  111193. * @param task defines the task that was just processed
  111194. */
  111195. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  111196. }
  111197. /**
  111198. * Define a task used by AssetsManager to load meshes
  111199. */
  111200. export class MeshAssetTask extends AbstractAssetTask {
  111201. /**
  111202. * Defines the name of the task
  111203. */
  111204. name: string;
  111205. /**
  111206. * Defines the list of mesh's names you want to load
  111207. */
  111208. meshesNames: any;
  111209. /**
  111210. * Defines the root url to use as a base to load your meshes and associated resources
  111211. */
  111212. rootUrl: string;
  111213. /**
  111214. * Defines the filename of the scene to load from
  111215. */
  111216. sceneFilename: string;
  111217. /**
  111218. * Gets the list of loaded meshes
  111219. */
  111220. loadedMeshes: Array<AbstractMesh>;
  111221. /**
  111222. * Gets the list of loaded particle systems
  111223. */
  111224. loadedParticleSystems: Array<IParticleSystem>;
  111225. /**
  111226. * Gets the list of loaded skeletons
  111227. */
  111228. loadedSkeletons: Array<Skeleton>;
  111229. /**
  111230. * Gets the list of loaded animation groups
  111231. */
  111232. loadedAnimationGroups: Array<AnimationGroup>;
  111233. /**
  111234. * Callback called when the task is successful
  111235. */
  111236. onSuccess: (task: MeshAssetTask) => void;
  111237. /**
  111238. * Callback called when the task is successful
  111239. */
  111240. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  111241. /**
  111242. * Creates a new MeshAssetTask
  111243. * @param name defines the name of the task
  111244. * @param meshesNames defines the list of mesh's names you want to load
  111245. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  111246. * @param sceneFilename defines the filename of the scene to load from
  111247. */
  111248. constructor(
  111249. /**
  111250. * Defines the name of the task
  111251. */
  111252. name: string,
  111253. /**
  111254. * Defines the list of mesh's names you want to load
  111255. */
  111256. meshesNames: any,
  111257. /**
  111258. * Defines the root url to use as a base to load your meshes and associated resources
  111259. */
  111260. rootUrl: string,
  111261. /**
  111262. * Defines the filename of the scene to load from
  111263. */
  111264. sceneFilename: string);
  111265. /**
  111266. * Execute the current task
  111267. * @param scene defines the scene where you want your assets to be loaded
  111268. * @param onSuccess is a callback called when the task is successfully executed
  111269. * @param onError is a callback called if an error occurs
  111270. */
  111271. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111272. }
  111273. /**
  111274. * Define a task used by AssetsManager to load text content
  111275. */
  111276. export class TextFileAssetTask extends AbstractAssetTask {
  111277. /**
  111278. * Defines the name of the task
  111279. */
  111280. name: string;
  111281. /**
  111282. * Defines the location of the file to load
  111283. */
  111284. url: string;
  111285. /**
  111286. * Gets the loaded text string
  111287. */
  111288. text: string;
  111289. /**
  111290. * Callback called when the task is successful
  111291. */
  111292. onSuccess: (task: TextFileAssetTask) => void;
  111293. /**
  111294. * Callback called when the task is successful
  111295. */
  111296. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  111297. /**
  111298. * Creates a new TextFileAssetTask object
  111299. * @param name defines the name of the task
  111300. * @param url defines the location of the file to load
  111301. */
  111302. constructor(
  111303. /**
  111304. * Defines the name of the task
  111305. */
  111306. name: string,
  111307. /**
  111308. * Defines the location of the file to load
  111309. */
  111310. url: string);
  111311. /**
  111312. * Execute the current task
  111313. * @param scene defines the scene where you want your assets to be loaded
  111314. * @param onSuccess is a callback called when the task is successfully executed
  111315. * @param onError is a callback called if an error occurs
  111316. */
  111317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111318. }
  111319. /**
  111320. * Define a task used by AssetsManager to load binary data
  111321. */
  111322. export class BinaryFileAssetTask extends AbstractAssetTask {
  111323. /**
  111324. * Defines the name of the task
  111325. */
  111326. name: string;
  111327. /**
  111328. * Defines the location of the file to load
  111329. */
  111330. url: string;
  111331. /**
  111332. * Gets the lodaded data (as an array buffer)
  111333. */
  111334. data: ArrayBuffer;
  111335. /**
  111336. * Callback called when the task is successful
  111337. */
  111338. onSuccess: (task: BinaryFileAssetTask) => void;
  111339. /**
  111340. * Callback called when the task is successful
  111341. */
  111342. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  111343. /**
  111344. * Creates a new BinaryFileAssetTask object
  111345. * @param name defines the name of the new task
  111346. * @param url defines the location of the file to load
  111347. */
  111348. constructor(
  111349. /**
  111350. * Defines the name of the task
  111351. */
  111352. name: string,
  111353. /**
  111354. * Defines the location of the file to load
  111355. */
  111356. url: string);
  111357. /**
  111358. * Execute the current task
  111359. * @param scene defines the scene where you want your assets to be loaded
  111360. * @param onSuccess is a callback called when the task is successfully executed
  111361. * @param onError is a callback called if an error occurs
  111362. */
  111363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111364. }
  111365. /**
  111366. * Define a task used by AssetsManager to load images
  111367. */
  111368. export class ImageAssetTask extends AbstractAssetTask {
  111369. /**
  111370. * Defines the name of the task
  111371. */
  111372. name: string;
  111373. /**
  111374. * Defines the location of the image to load
  111375. */
  111376. url: string;
  111377. /**
  111378. * Gets the loaded images
  111379. */
  111380. image: HTMLImageElement;
  111381. /**
  111382. * Callback called when the task is successful
  111383. */
  111384. onSuccess: (task: ImageAssetTask) => void;
  111385. /**
  111386. * Callback called when the task is successful
  111387. */
  111388. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  111389. /**
  111390. * Creates a new ImageAssetTask
  111391. * @param name defines the name of the task
  111392. * @param url defines the location of the image to load
  111393. */
  111394. constructor(
  111395. /**
  111396. * Defines the name of the task
  111397. */
  111398. name: string,
  111399. /**
  111400. * Defines the location of the image to load
  111401. */
  111402. url: string);
  111403. /**
  111404. * Execute the current task
  111405. * @param scene defines the scene where you want your assets to be loaded
  111406. * @param onSuccess is a callback called when the task is successfully executed
  111407. * @param onError is a callback called if an error occurs
  111408. */
  111409. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111410. }
  111411. /**
  111412. * Defines the interface used by texture loading tasks
  111413. */
  111414. export interface ITextureAssetTask<TEX extends BaseTexture> {
  111415. /**
  111416. * Gets the loaded texture
  111417. */
  111418. texture: TEX;
  111419. }
  111420. /**
  111421. * Define a task used by AssetsManager to load 2D textures
  111422. */
  111423. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  111424. /**
  111425. * Defines the name of the task
  111426. */
  111427. name: string;
  111428. /**
  111429. * Defines the location of the file to load
  111430. */
  111431. url: string;
  111432. /**
  111433. * Defines if mipmap should not be generated (default is false)
  111434. */
  111435. noMipmap?: boolean | undefined;
  111436. /**
  111437. * Defines if texture must be inverted on Y axis (default is false)
  111438. */
  111439. invertY?: boolean | undefined;
  111440. /**
  111441. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111442. */
  111443. samplingMode: number;
  111444. /**
  111445. * Gets the loaded texture
  111446. */
  111447. texture: Texture;
  111448. /**
  111449. * Callback called when the task is successful
  111450. */
  111451. onSuccess: (task: TextureAssetTask) => void;
  111452. /**
  111453. * Callback called when the task is successful
  111454. */
  111455. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  111456. /**
  111457. * Creates a new TextureAssetTask object
  111458. * @param name defines the name of the task
  111459. * @param url defines the location of the file to load
  111460. * @param noMipmap defines if mipmap should not be generated (default is false)
  111461. * @param invertY defines if texture must be inverted on Y axis (default is false)
  111462. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111463. */
  111464. constructor(
  111465. /**
  111466. * Defines the name of the task
  111467. */
  111468. name: string,
  111469. /**
  111470. * Defines the location of the file to load
  111471. */
  111472. url: string,
  111473. /**
  111474. * Defines if mipmap should not be generated (default is false)
  111475. */
  111476. noMipmap?: boolean | undefined,
  111477. /**
  111478. * Defines if texture must be inverted on Y axis (default is false)
  111479. */
  111480. invertY?: boolean | undefined,
  111481. /**
  111482. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111483. */
  111484. samplingMode?: number);
  111485. /**
  111486. * Execute the current task
  111487. * @param scene defines the scene where you want your assets to be loaded
  111488. * @param onSuccess is a callback called when the task is successfully executed
  111489. * @param onError is a callback called if an error occurs
  111490. */
  111491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111492. }
  111493. /**
  111494. * Define a task used by AssetsManager to load cube textures
  111495. */
  111496. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  111497. /**
  111498. * Defines the name of the task
  111499. */
  111500. name: string;
  111501. /**
  111502. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111503. */
  111504. url: string;
  111505. /**
  111506. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111507. */
  111508. extensions?: string[] | undefined;
  111509. /**
  111510. * Defines if mipmaps should not be generated (default is false)
  111511. */
  111512. noMipmap?: boolean | undefined;
  111513. /**
  111514. * Defines the explicit list of files (undefined by default)
  111515. */
  111516. files?: string[] | undefined;
  111517. /**
  111518. * Gets the loaded texture
  111519. */
  111520. texture: CubeTexture;
  111521. /**
  111522. * Callback called when the task is successful
  111523. */
  111524. onSuccess: (task: CubeTextureAssetTask) => void;
  111525. /**
  111526. * Callback called when the task is successful
  111527. */
  111528. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  111529. /**
  111530. * Creates a new CubeTextureAssetTask
  111531. * @param name defines the name of the task
  111532. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111533. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111534. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111535. * @param files defines the explicit list of files (undefined by default)
  111536. */
  111537. constructor(
  111538. /**
  111539. * Defines the name of the task
  111540. */
  111541. name: string,
  111542. /**
  111543. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111544. */
  111545. url: string,
  111546. /**
  111547. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111548. */
  111549. extensions?: string[] | undefined,
  111550. /**
  111551. * Defines if mipmaps should not be generated (default is false)
  111552. */
  111553. noMipmap?: boolean | undefined,
  111554. /**
  111555. * Defines the explicit list of files (undefined by default)
  111556. */
  111557. files?: string[] | undefined);
  111558. /**
  111559. * Execute the current task
  111560. * @param scene defines the scene where you want your assets to be loaded
  111561. * @param onSuccess is a callback called when the task is successfully executed
  111562. * @param onError is a callback called if an error occurs
  111563. */
  111564. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111565. }
  111566. /**
  111567. * Define a task used by AssetsManager to load HDR cube textures
  111568. */
  111569. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  111570. /**
  111571. * Defines the name of the task
  111572. */
  111573. name: string;
  111574. /**
  111575. * Defines the location of the file to load
  111576. */
  111577. url: string;
  111578. /**
  111579. * Defines the desired size (the more it increases the longer the generation will be)
  111580. */
  111581. size: number;
  111582. /**
  111583. * Defines if mipmaps should not be generated (default is false)
  111584. */
  111585. noMipmap: boolean;
  111586. /**
  111587. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111588. */
  111589. generateHarmonics: boolean;
  111590. /**
  111591. * 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)
  111592. */
  111593. gammaSpace: boolean;
  111594. /**
  111595. * Internal Use Only
  111596. */
  111597. reserved: boolean;
  111598. /**
  111599. * Gets the loaded texture
  111600. */
  111601. texture: HDRCubeTexture;
  111602. /**
  111603. * Callback called when the task is successful
  111604. */
  111605. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  111606. /**
  111607. * Callback called when the task is successful
  111608. */
  111609. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  111610. /**
  111611. * Creates a new HDRCubeTextureAssetTask object
  111612. * @param name defines the name of the task
  111613. * @param url defines the location of the file to load
  111614. * @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.
  111615. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111616. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111617. * @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)
  111618. * @param reserved Internal use only
  111619. */
  111620. constructor(
  111621. /**
  111622. * Defines the name of the task
  111623. */
  111624. name: string,
  111625. /**
  111626. * Defines the location of the file to load
  111627. */
  111628. url: string,
  111629. /**
  111630. * Defines the desired size (the more it increases the longer the generation will be)
  111631. */
  111632. size: number,
  111633. /**
  111634. * Defines if mipmaps should not be generated (default is false)
  111635. */
  111636. noMipmap?: boolean,
  111637. /**
  111638. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111639. */
  111640. generateHarmonics?: boolean,
  111641. /**
  111642. * 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)
  111643. */
  111644. gammaSpace?: boolean,
  111645. /**
  111646. * Internal Use Only
  111647. */
  111648. reserved?: boolean);
  111649. /**
  111650. * Execute the current task
  111651. * @param scene defines the scene where you want your assets to be loaded
  111652. * @param onSuccess is a callback called when the task is successfully executed
  111653. * @param onError is a callback called if an error occurs
  111654. */
  111655. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111656. }
  111657. /**
  111658. * This class can be used to easily import assets into a scene
  111659. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  111660. */
  111661. export class AssetsManager {
  111662. private _scene;
  111663. private _isLoading;
  111664. protected _tasks: AbstractAssetTask[];
  111665. protected _waitingTasksCount: number;
  111666. protected _totalTasksCount: number;
  111667. /**
  111668. * Callback called when all tasks are processed
  111669. */
  111670. onFinish: (tasks: AbstractAssetTask[]) => void;
  111671. /**
  111672. * Callback called when a task is successful
  111673. */
  111674. onTaskSuccess: (task: AbstractAssetTask) => void;
  111675. /**
  111676. * Callback called when a task had an error
  111677. */
  111678. onTaskError: (task: AbstractAssetTask) => void;
  111679. /**
  111680. * Callback called when a task is done (whatever the result is)
  111681. */
  111682. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  111683. /**
  111684. * Observable called when all tasks are processed
  111685. */
  111686. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  111687. /**
  111688. * Observable called when a task had an error
  111689. */
  111690. onTaskErrorObservable: Observable<AbstractAssetTask>;
  111691. /**
  111692. * Observable called when all tasks were executed
  111693. */
  111694. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  111695. /**
  111696. * Observable called when a task is done (whatever the result is)
  111697. */
  111698. onProgressObservable: Observable<IAssetsProgressEvent>;
  111699. /**
  111700. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  111701. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  111702. */
  111703. useDefaultLoadingScreen: boolean;
  111704. /**
  111705. * Creates a new AssetsManager
  111706. * @param scene defines the scene to work on
  111707. */
  111708. constructor(scene: Scene);
  111709. /**
  111710. * Add a MeshAssetTask to the list of active tasks
  111711. * @param taskName defines the name of the new task
  111712. * @param meshesNames defines the name of meshes to load
  111713. * @param rootUrl defines the root url to use to locate files
  111714. * @param sceneFilename defines the filename of the scene file
  111715. * @returns a new MeshAssetTask object
  111716. */
  111717. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  111718. /**
  111719. * Add a TextFileAssetTask to the list of active tasks
  111720. * @param taskName defines the name of the new task
  111721. * @param url defines the url of the file to load
  111722. * @returns a new TextFileAssetTask object
  111723. */
  111724. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  111725. /**
  111726. * Add a BinaryFileAssetTask to the list of active tasks
  111727. * @param taskName defines the name of the new task
  111728. * @param url defines the url of the file to load
  111729. * @returns a new BinaryFileAssetTask object
  111730. */
  111731. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  111732. /**
  111733. * Add a ImageAssetTask to the list of active tasks
  111734. * @param taskName defines the name of the new task
  111735. * @param url defines the url of the file to load
  111736. * @returns a new ImageAssetTask object
  111737. */
  111738. addImageTask(taskName: string, url: string): ImageAssetTask;
  111739. /**
  111740. * Add a TextureAssetTask to the list of active tasks
  111741. * @param taskName defines the name of the new task
  111742. * @param url defines the url of the file to load
  111743. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111744. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  111745. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  111746. * @returns a new TextureAssetTask object
  111747. */
  111748. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  111749. /**
  111750. * Add a CubeTextureAssetTask to the list of active tasks
  111751. * @param taskName defines the name of the new task
  111752. * @param url defines the url of the file to load
  111753. * @param extensions defines the extension to use to load the cube map (can be null)
  111754. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111755. * @param files defines the list of files to load (can be null)
  111756. * @returns a new CubeTextureAssetTask object
  111757. */
  111758. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  111759. /**
  111760. *
  111761. * Add a HDRCubeTextureAssetTask to the list of active tasks
  111762. * @param taskName defines the name of the new task
  111763. * @param url defines the url of the file to load
  111764. * @param size defines the size you want for the cubemap (can be null)
  111765. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111766. * @param generateHarmonics defines if you want to automatically generate (true by default)
  111767. * @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)
  111768. * @param reserved Internal use only
  111769. * @returns a new HDRCubeTextureAssetTask object
  111770. */
  111771. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  111772. /**
  111773. * Remove a task from the assets manager.
  111774. * @param task the task to remove
  111775. */
  111776. removeTask(task: AbstractAssetTask): void;
  111777. private _decreaseWaitingTasksCount;
  111778. private _runTask;
  111779. /**
  111780. * Reset the AssetsManager and remove all tasks
  111781. * @return the current instance of the AssetsManager
  111782. */
  111783. reset(): AssetsManager;
  111784. /**
  111785. * Start the loading process
  111786. * @return the current instance of the AssetsManager
  111787. */
  111788. load(): AssetsManager;
  111789. /**
  111790. * Start the loading process as an async operation
  111791. * @return a promise returning the list of failed tasks
  111792. */
  111793. loadAsync(): Promise<void>;
  111794. }
  111795. }
  111796. declare module BABYLON {
  111797. /**
  111798. * Wrapper class for promise with external resolve and reject.
  111799. */
  111800. export class Deferred<T> {
  111801. /**
  111802. * The promise associated with this deferred object.
  111803. */
  111804. readonly promise: Promise<T>;
  111805. private _resolve;
  111806. private _reject;
  111807. /**
  111808. * The resolve method of the promise associated with this deferred object.
  111809. */
  111810. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  111811. /**
  111812. * The reject method of the promise associated with this deferred object.
  111813. */
  111814. readonly reject: (reason?: any) => void;
  111815. /**
  111816. * Constructor for this deferred object.
  111817. */
  111818. constructor();
  111819. }
  111820. }
  111821. declare module BABYLON {
  111822. /**
  111823. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  111824. */
  111825. export class MeshExploder {
  111826. private _centerMesh;
  111827. private _meshes;
  111828. private _meshesOrigins;
  111829. private _toCenterVectors;
  111830. private _scaledDirection;
  111831. private _newPosition;
  111832. private _centerPosition;
  111833. /**
  111834. * Explodes meshes from a center mesh.
  111835. * @param meshes The meshes to explode.
  111836. * @param centerMesh The mesh to be center of explosion.
  111837. */
  111838. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  111839. private _setCenterMesh;
  111840. /**
  111841. * Get class name
  111842. * @returns "MeshExploder"
  111843. */
  111844. getClassName(): string;
  111845. /**
  111846. * "Exploded meshes"
  111847. * @returns Array of meshes with the centerMesh at index 0.
  111848. */
  111849. getMeshes(): Array<Mesh>;
  111850. /**
  111851. * Explodes meshes giving a specific direction
  111852. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  111853. */
  111854. explode(direction?: number): void;
  111855. }
  111856. }
  111857. declare module BABYLON {
  111858. /**
  111859. * Class used to help managing file picking and drag'n'drop
  111860. */
  111861. export class FilesInput {
  111862. /**
  111863. * List of files ready to be loaded
  111864. */
  111865. static readonly FilesToLoad: {
  111866. [key: string]: File;
  111867. };
  111868. /**
  111869. * Callback called when a file is processed
  111870. */
  111871. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  111872. private _engine;
  111873. private _currentScene;
  111874. private _sceneLoadedCallback;
  111875. private _progressCallback;
  111876. private _additionalRenderLoopLogicCallback;
  111877. private _textureLoadingCallback;
  111878. private _startingProcessingFilesCallback;
  111879. private _onReloadCallback;
  111880. private _errorCallback;
  111881. private _elementToMonitor;
  111882. private _sceneFileToLoad;
  111883. private _filesToLoad;
  111884. /**
  111885. * Creates a new FilesInput
  111886. * @param engine defines the rendering engine
  111887. * @param scene defines the hosting scene
  111888. * @param sceneLoadedCallback callback called when scene is loaded
  111889. * @param progressCallback callback called to track progress
  111890. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  111891. * @param textureLoadingCallback callback called when a texture is loading
  111892. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  111893. * @param onReloadCallback callback called when a reload is requested
  111894. * @param errorCallback callback call if an error occurs
  111895. */
  111896. 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);
  111897. private _dragEnterHandler;
  111898. private _dragOverHandler;
  111899. private _dropHandler;
  111900. /**
  111901. * Calls this function to listen to drag'n'drop events on a specific DOM element
  111902. * @param elementToMonitor defines the DOM element to track
  111903. */
  111904. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  111905. /**
  111906. * Release all associated resources
  111907. */
  111908. dispose(): void;
  111909. private renderFunction;
  111910. private drag;
  111911. private drop;
  111912. private _traverseFolder;
  111913. private _processFiles;
  111914. /**
  111915. * Load files from a drop event
  111916. * @param event defines the drop event to use as source
  111917. */
  111918. loadFiles(event: any): void;
  111919. private _processReload;
  111920. /**
  111921. * Reload the current scene from the loaded files
  111922. */
  111923. reload(): void;
  111924. }
  111925. }
  111926. declare module BABYLON {
  111927. /**
  111928. * Defines the root class used to create scene optimization to use with SceneOptimizer
  111929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111930. */
  111931. export class SceneOptimization {
  111932. /**
  111933. * Defines the priority of this optimization (0 by default which means first in the list)
  111934. */
  111935. priority: number;
  111936. /**
  111937. * Gets a string describing the action executed by the current optimization
  111938. * @returns description string
  111939. */
  111940. getDescription(): string;
  111941. /**
  111942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111943. * @param scene defines the current scene where to apply this optimization
  111944. * @param optimizer defines the current optimizer
  111945. * @returns true if everything that can be done was applied
  111946. */
  111947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111948. /**
  111949. * Creates the SceneOptimization object
  111950. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111951. * @param desc defines the description associated with the optimization
  111952. */
  111953. constructor(
  111954. /**
  111955. * Defines the priority of this optimization (0 by default which means first in the list)
  111956. */
  111957. priority?: number);
  111958. }
  111959. /**
  111960. * Defines an optimization used to reduce the size of render target textures
  111961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111962. */
  111963. export class TextureOptimization extends SceneOptimization {
  111964. /**
  111965. * Defines the priority of this optimization (0 by default which means first in the list)
  111966. */
  111967. priority: number;
  111968. /**
  111969. * 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
  111970. */
  111971. maximumSize: number;
  111972. /**
  111973. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111974. */
  111975. step: number;
  111976. /**
  111977. * Gets a string describing the action executed by the current optimization
  111978. * @returns description string
  111979. */
  111980. getDescription(): string;
  111981. /**
  111982. * Creates the TextureOptimization object
  111983. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111984. * @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
  111985. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111986. */
  111987. constructor(
  111988. /**
  111989. * Defines the priority of this optimization (0 by default which means first in the list)
  111990. */
  111991. priority?: number,
  111992. /**
  111993. * 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
  111994. */
  111995. maximumSize?: number,
  111996. /**
  111997. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111998. */
  111999. step?: number);
  112000. /**
  112001. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112002. * @param scene defines the current scene where to apply this optimization
  112003. * @param optimizer defines the current optimizer
  112004. * @returns true if everything that can be done was applied
  112005. */
  112006. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112007. }
  112008. /**
  112009. * Defines an optimization used to increase or decrease the rendering resolution
  112010. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112011. */
  112012. export class HardwareScalingOptimization extends SceneOptimization {
  112013. /**
  112014. * Defines the priority of this optimization (0 by default which means first in the list)
  112015. */
  112016. priority: number;
  112017. /**
  112018. * Defines the maximum scale to use (2 by default)
  112019. */
  112020. maximumScale: number;
  112021. /**
  112022. * Defines the step to use between two passes (0.5 by default)
  112023. */
  112024. step: number;
  112025. private _currentScale;
  112026. private _directionOffset;
  112027. /**
  112028. * Gets a string describing the action executed by the current optimization
  112029. * @return description string
  112030. */
  112031. getDescription(): string;
  112032. /**
  112033. * Creates the HardwareScalingOptimization object
  112034. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112035. * @param maximumScale defines the maximum scale to use (2 by default)
  112036. * @param step defines the step to use between two passes (0.5 by default)
  112037. */
  112038. constructor(
  112039. /**
  112040. * Defines the priority of this optimization (0 by default which means first in the list)
  112041. */
  112042. priority?: number,
  112043. /**
  112044. * Defines the maximum scale to use (2 by default)
  112045. */
  112046. maximumScale?: number,
  112047. /**
  112048. * Defines the step to use between two passes (0.5 by default)
  112049. */
  112050. step?: number);
  112051. /**
  112052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112053. * @param scene defines the current scene where to apply this optimization
  112054. * @param optimizer defines the current optimizer
  112055. * @returns true if everything that can be done was applied
  112056. */
  112057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112058. }
  112059. /**
  112060. * Defines an optimization used to remove shadows
  112061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112062. */
  112063. export class ShadowsOptimization extends SceneOptimization {
  112064. /**
  112065. * Gets a string describing the action executed by the current optimization
  112066. * @return description string
  112067. */
  112068. getDescription(): string;
  112069. /**
  112070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112071. * @param scene defines the current scene where to apply this optimization
  112072. * @param optimizer defines the current optimizer
  112073. * @returns true if everything that can be done was applied
  112074. */
  112075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112076. }
  112077. /**
  112078. * Defines an optimization used to turn post-processes off
  112079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112080. */
  112081. export class PostProcessesOptimization extends SceneOptimization {
  112082. /**
  112083. * Gets a string describing the action executed by the current optimization
  112084. * @return description string
  112085. */
  112086. getDescription(): string;
  112087. /**
  112088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112089. * @param scene defines the current scene where to apply this optimization
  112090. * @param optimizer defines the current optimizer
  112091. * @returns true if everything that can be done was applied
  112092. */
  112093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112094. }
  112095. /**
  112096. * Defines an optimization used to turn lens flares off
  112097. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112098. */
  112099. export class LensFlaresOptimization extends SceneOptimization {
  112100. /**
  112101. * Gets a string describing the action executed by the current optimization
  112102. * @return description string
  112103. */
  112104. getDescription(): string;
  112105. /**
  112106. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112107. * @param scene defines the current scene where to apply this optimization
  112108. * @param optimizer defines the current optimizer
  112109. * @returns true if everything that can be done was applied
  112110. */
  112111. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112112. }
  112113. /**
  112114. * Defines an optimization based on user defined callback.
  112115. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112116. */
  112117. export class CustomOptimization extends SceneOptimization {
  112118. /**
  112119. * Callback called to apply the custom optimization.
  112120. */
  112121. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  112122. /**
  112123. * Callback called to get custom description
  112124. */
  112125. onGetDescription: () => string;
  112126. /**
  112127. * Gets a string describing the action executed by the current optimization
  112128. * @returns description string
  112129. */
  112130. getDescription(): string;
  112131. /**
  112132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112133. * @param scene defines the current scene where to apply this optimization
  112134. * @param optimizer defines the current optimizer
  112135. * @returns true if everything that can be done was applied
  112136. */
  112137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112138. }
  112139. /**
  112140. * Defines an optimization used to turn particles off
  112141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112142. */
  112143. export class ParticlesOptimization extends SceneOptimization {
  112144. /**
  112145. * Gets a string describing the action executed by the current optimization
  112146. * @return description string
  112147. */
  112148. getDescription(): string;
  112149. /**
  112150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112151. * @param scene defines the current scene where to apply this optimization
  112152. * @param optimizer defines the current optimizer
  112153. * @returns true if everything that can be done was applied
  112154. */
  112155. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112156. }
  112157. /**
  112158. * Defines an optimization used to turn render targets off
  112159. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112160. */
  112161. export class RenderTargetsOptimization extends SceneOptimization {
  112162. /**
  112163. * Gets a string describing the action executed by the current optimization
  112164. * @return description string
  112165. */
  112166. getDescription(): string;
  112167. /**
  112168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112169. * @param scene defines the current scene where to apply this optimization
  112170. * @param optimizer defines the current optimizer
  112171. * @returns true if everything that can be done was applied
  112172. */
  112173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112174. }
  112175. /**
  112176. * Defines an optimization used to merge meshes with compatible materials
  112177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112178. */
  112179. export class MergeMeshesOptimization extends SceneOptimization {
  112180. private static _UpdateSelectionTree;
  112181. /**
  112182. * Gets or sets a boolean which defines if optimization octree has to be updated
  112183. */
  112184. /**
  112185. * Gets or sets a boolean which defines if optimization octree has to be updated
  112186. */
  112187. static UpdateSelectionTree: boolean;
  112188. /**
  112189. * Gets a string describing the action executed by the current optimization
  112190. * @return description string
  112191. */
  112192. getDescription(): string;
  112193. private _canBeMerged;
  112194. /**
  112195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112196. * @param scene defines the current scene where to apply this optimization
  112197. * @param optimizer defines the current optimizer
  112198. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  112199. * @returns true if everything that can be done was applied
  112200. */
  112201. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  112202. }
  112203. /**
  112204. * Defines a list of options used by SceneOptimizer
  112205. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112206. */
  112207. export class SceneOptimizerOptions {
  112208. /**
  112209. * Defines the target frame rate to reach (60 by default)
  112210. */
  112211. targetFrameRate: number;
  112212. /**
  112213. * Defines the interval between two checkes (2000ms by default)
  112214. */
  112215. trackerDuration: number;
  112216. /**
  112217. * Gets the list of optimizations to apply
  112218. */
  112219. optimizations: SceneOptimization[];
  112220. /**
  112221. * Creates a new list of options used by SceneOptimizer
  112222. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  112223. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  112224. */
  112225. constructor(
  112226. /**
  112227. * Defines the target frame rate to reach (60 by default)
  112228. */
  112229. targetFrameRate?: number,
  112230. /**
  112231. * Defines the interval between two checkes (2000ms by default)
  112232. */
  112233. trackerDuration?: number);
  112234. /**
  112235. * Add a new optimization
  112236. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  112237. * @returns the current SceneOptimizerOptions
  112238. */
  112239. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  112240. /**
  112241. * Add a new custom optimization
  112242. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  112243. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  112244. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112245. * @returns the current SceneOptimizerOptions
  112246. */
  112247. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  112248. /**
  112249. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  112250. * @param targetFrameRate defines the target frame rate (60 by default)
  112251. * @returns a SceneOptimizerOptions object
  112252. */
  112253. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  112254. /**
  112255. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  112256. * @param targetFrameRate defines the target frame rate (60 by default)
  112257. * @returns a SceneOptimizerOptions object
  112258. */
  112259. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  112260. /**
  112261. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  112262. * @param targetFrameRate defines the target frame rate (60 by default)
  112263. * @returns a SceneOptimizerOptions object
  112264. */
  112265. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  112266. }
  112267. /**
  112268. * Class used to run optimizations in order to reach a target frame rate
  112269. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112270. */
  112271. export class SceneOptimizer implements IDisposable {
  112272. private _isRunning;
  112273. private _options;
  112274. private _scene;
  112275. private _currentPriorityLevel;
  112276. private _targetFrameRate;
  112277. private _trackerDuration;
  112278. private _currentFrameRate;
  112279. private _sceneDisposeObserver;
  112280. private _improvementMode;
  112281. /**
  112282. * Defines an observable called when the optimizer reaches the target frame rate
  112283. */
  112284. onSuccessObservable: Observable<SceneOptimizer>;
  112285. /**
  112286. * Defines an observable called when the optimizer enables an optimization
  112287. */
  112288. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  112289. /**
  112290. * Defines an observable called when the optimizer is not able to reach the target frame rate
  112291. */
  112292. onFailureObservable: Observable<SceneOptimizer>;
  112293. /**
  112294. * Gets a boolean indicating if the optimizer is in improvement mode
  112295. */
  112296. readonly isInImprovementMode: boolean;
  112297. /**
  112298. * Gets the current priority level (0 at start)
  112299. */
  112300. readonly currentPriorityLevel: number;
  112301. /**
  112302. * Gets the current frame rate checked by the SceneOptimizer
  112303. */
  112304. readonly currentFrameRate: number;
  112305. /**
  112306. * Gets or sets the current target frame rate (60 by default)
  112307. */
  112308. /**
  112309. * Gets or sets the current target frame rate (60 by default)
  112310. */
  112311. targetFrameRate: number;
  112312. /**
  112313. * Gets or sets the current interval between two checks (every 2000ms by default)
  112314. */
  112315. /**
  112316. * Gets or sets the current interval between two checks (every 2000ms by default)
  112317. */
  112318. trackerDuration: number;
  112319. /**
  112320. * Gets the list of active optimizations
  112321. */
  112322. readonly optimizations: SceneOptimization[];
  112323. /**
  112324. * Creates a new SceneOptimizer
  112325. * @param scene defines the scene to work on
  112326. * @param options defines the options to use with the SceneOptimizer
  112327. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  112328. * @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)
  112329. */
  112330. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  112331. /**
  112332. * Stops the current optimizer
  112333. */
  112334. stop(): void;
  112335. /**
  112336. * Reset the optimizer to initial step (current priority level = 0)
  112337. */
  112338. reset(): void;
  112339. /**
  112340. * Start the optimizer. By default it will try to reach a specific framerate
  112341. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  112342. */
  112343. start(): void;
  112344. private _checkCurrentState;
  112345. /**
  112346. * Release all resources
  112347. */
  112348. dispose(): void;
  112349. /**
  112350. * Helper function to create a SceneOptimizer with one single line of code
  112351. * @param scene defines the scene to work on
  112352. * @param options defines the options to use with the SceneOptimizer
  112353. * @param onSuccess defines a callback to call on success
  112354. * @param onFailure defines a callback to call on failure
  112355. * @returns the new SceneOptimizer object
  112356. */
  112357. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  112358. }
  112359. }
  112360. declare module BABYLON {
  112361. /**
  112362. * Class used to serialize a scene into a string
  112363. */
  112364. export class SceneSerializer {
  112365. /**
  112366. * Clear cache used by a previous serialization
  112367. */
  112368. static ClearCache(): void;
  112369. /**
  112370. * Serialize a scene into a JSON compatible object
  112371. * @param scene defines the scene to serialize
  112372. * @returns a JSON compatible object
  112373. */
  112374. static Serialize(scene: Scene): any;
  112375. /**
  112376. * Serialize a mesh into a JSON compatible object
  112377. * @param toSerialize defines the mesh to serialize
  112378. * @param withParents defines if parents must be serialized as well
  112379. * @param withChildren defines if children must be serialized as well
  112380. * @returns a JSON compatible object
  112381. */
  112382. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  112383. }
  112384. }
  112385. declare module BABYLON {
  112386. /**
  112387. * This represents the different options avilable for the video capture.
  112388. */
  112389. export interface VideoRecorderOptions {
  112390. /** Defines the mime type of the video */
  112391. mimeType: string;
  112392. /** Defines the video the video should be recorded at */
  112393. fps: number;
  112394. /** Defines the chunk size for the recording data */
  112395. recordChunckSize: number;
  112396. /** The audio tracks to attach to the record */
  112397. audioTracks?: MediaStreamTrack[];
  112398. }
  112399. /**
  112400. * This can helps recording videos from BabylonJS.
  112401. * This is based on the available WebRTC functionalities of the browser.
  112402. *
  112403. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  112404. */
  112405. export class VideoRecorder {
  112406. private static readonly _defaultOptions;
  112407. /**
  112408. * Returns wehther or not the VideoRecorder is available in your browser.
  112409. * @param engine Defines the Babylon Engine to check the support for
  112410. * @returns true if supported otherwise false
  112411. */
  112412. static IsSupported(engine: Engine): boolean;
  112413. private readonly _options;
  112414. private _canvas;
  112415. private _mediaRecorder;
  112416. private _recordedChunks;
  112417. private _fileName;
  112418. private _resolve;
  112419. private _reject;
  112420. /**
  112421. * True wether a recording is already in progress.
  112422. */
  112423. readonly isRecording: boolean;
  112424. /**
  112425. * Create a new VideoCapture object which can help converting what you see in Babylon to
  112426. * a video file.
  112427. * @param engine Defines the BabylonJS Engine you wish to record
  112428. * @param options Defines options that can be used to customized the capture
  112429. */
  112430. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  112431. /**
  112432. * Stops the current recording before the default capture timeout passed in the startRecording
  112433. * functions.
  112434. */
  112435. stopRecording(): void;
  112436. /**
  112437. * Starts recording the canvas for a max duration specified in parameters.
  112438. * @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.
  112439. * @param maxDuration Defines the maximum recording time in seconds.
  112440. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  112441. * @return a promise callback at the end of the recording with the video data in Blob.
  112442. */
  112443. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  112444. /**
  112445. * Releases internal resources used during the recording.
  112446. */
  112447. dispose(): void;
  112448. private _handleDataAvailable;
  112449. private _handleError;
  112450. private _handleStop;
  112451. }
  112452. }
  112453. declare module BABYLON {
  112454. /**
  112455. * Helper class to push actions to a pool of workers.
  112456. */
  112457. export class WorkerPool implements IDisposable {
  112458. private _workerInfos;
  112459. private _pendingActions;
  112460. /**
  112461. * Constructor
  112462. * @param workers Array of workers to use for actions
  112463. */
  112464. constructor(workers: Array<Worker>);
  112465. /**
  112466. * Terminates all workers and clears any pending actions.
  112467. */
  112468. dispose(): void;
  112469. /**
  112470. * Pushes an action to the worker pool. If all the workers are active, the action will be
  112471. * pended until a worker has completed its action.
  112472. * @param action The action to perform. Call onComplete when the action is complete.
  112473. */
  112474. push(action: (worker: Worker, onComplete: () => void) => void): void;
  112475. private _execute;
  112476. }
  112477. }
  112478. declare module BABYLON {
  112479. /**
  112480. * Class containing a set of static utilities functions for screenshots
  112481. */
  112482. export class ScreenshotTools {
  112483. /**
  112484. * Captures a screenshot of the current rendering
  112485. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  112486. * @param engine defines the rendering engine
  112487. * @param camera defines the source camera
  112488. * @param size This parameter can be set to a single number or to an object with the
  112489. * following (optional) properties: precision, width, height. If a single number is passed,
  112490. * it will be used for both width and height. If an object is passed, the screenshot size
  112491. * will be derived from the parameters. The precision property is a multiplier allowing
  112492. * rendering at a higher or lower resolution
  112493. * @param successCallback defines the callback receives a single parameter which contains the
  112494. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112495. * src parameter of an <img> to display it
  112496. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  112497. * Check your browser for supported MIME types
  112498. */
  112499. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  112500. /**
  112501. * Generates an image screenshot from the specified camera.
  112502. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  112503. * @param engine The engine to use for rendering
  112504. * @param camera The camera to use for rendering
  112505. * @param size This parameter can be set to a single number or to an object with the
  112506. * following (optional) properties: precision, width, height. If a single number is passed,
  112507. * it will be used for both width and height. If an object is passed, the screenshot size
  112508. * will be derived from the parameters. The precision property is a multiplier allowing
  112509. * rendering at a higher or lower resolution
  112510. * @param successCallback The callback receives a single parameter which contains the
  112511. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112512. * src parameter of an <img> to display it
  112513. * @param mimeType The MIME type of the screenshot image (default: image/png).
  112514. * Check your browser for supported MIME types
  112515. * @param samples Texture samples (default: 1)
  112516. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  112517. * @param fileName A name for for the downloaded file.
  112518. */
  112519. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  112520. }
  112521. }
  112522. declare module BABYLON {
  112523. /**
  112524. * A cursor which tracks a point on a path
  112525. */
  112526. export class PathCursor {
  112527. private path;
  112528. /**
  112529. * Stores path cursor callbacks for when an onchange event is triggered
  112530. */
  112531. private _onchange;
  112532. /**
  112533. * The value of the path cursor
  112534. */
  112535. value: number;
  112536. /**
  112537. * The animation array of the path cursor
  112538. */
  112539. animations: Animation[];
  112540. /**
  112541. * Initializes the path cursor
  112542. * @param path The path to track
  112543. */
  112544. constructor(path: Path2);
  112545. /**
  112546. * Gets the cursor point on the path
  112547. * @returns A point on the path cursor at the cursor location
  112548. */
  112549. getPoint(): Vector3;
  112550. /**
  112551. * Moves the cursor ahead by the step amount
  112552. * @param step The amount to move the cursor forward
  112553. * @returns This path cursor
  112554. */
  112555. moveAhead(step?: number): PathCursor;
  112556. /**
  112557. * Moves the cursor behind by the step amount
  112558. * @param step The amount to move the cursor back
  112559. * @returns This path cursor
  112560. */
  112561. moveBack(step?: number): PathCursor;
  112562. /**
  112563. * Moves the cursor by the step amount
  112564. * If the step amount is greater than one, an exception is thrown
  112565. * @param step The amount to move the cursor
  112566. * @returns This path cursor
  112567. */
  112568. move(step: number): PathCursor;
  112569. /**
  112570. * Ensures that the value is limited between zero and one
  112571. * @returns This path cursor
  112572. */
  112573. private ensureLimits;
  112574. /**
  112575. * Runs onchange callbacks on change (used by the animation engine)
  112576. * @returns This path cursor
  112577. */
  112578. private raiseOnChange;
  112579. /**
  112580. * Executes a function on change
  112581. * @param f A path cursor onchange callback
  112582. * @returns This path cursor
  112583. */
  112584. onchange(f: (cursor: PathCursor) => void): PathCursor;
  112585. }
  112586. }
  112587. declare module BABYLON {
  112588. /** @hidden */
  112589. export var blurPixelShader: {
  112590. name: string;
  112591. shader: string;
  112592. };
  112593. }
  112594. declare module BABYLON {
  112595. /** @hidden */
  112596. export var bones300Declaration: {
  112597. name: string;
  112598. shader: string;
  112599. };
  112600. }
  112601. declare module BABYLON {
  112602. /** @hidden */
  112603. export var instances300Declaration: {
  112604. name: string;
  112605. shader: string;
  112606. };
  112607. }
  112608. declare module BABYLON {
  112609. /** @hidden */
  112610. export var pointCloudVertexDeclaration: {
  112611. name: string;
  112612. shader: string;
  112613. };
  112614. }
  112615. // Mixins
  112616. interface Window {
  112617. mozIndexedDB: IDBFactory;
  112618. webkitIndexedDB: IDBFactory;
  112619. msIndexedDB: IDBFactory;
  112620. webkitURL: typeof URL;
  112621. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  112622. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  112623. WebGLRenderingContext: WebGLRenderingContext;
  112624. MSGesture: MSGesture;
  112625. CANNON: any;
  112626. AudioContext: AudioContext;
  112627. webkitAudioContext: AudioContext;
  112628. PointerEvent: any;
  112629. Math: Math;
  112630. Uint8Array: Uint8ArrayConstructor;
  112631. Float32Array: Float32ArrayConstructor;
  112632. mozURL: typeof URL;
  112633. msURL: typeof URL;
  112634. VRFrameData: any; // WebVR, from specs 1.1
  112635. DracoDecoderModule: any;
  112636. setImmediate(handler: (...args: any[]) => void): number;
  112637. }
  112638. interface HTMLCanvasElement {
  112639. requestPointerLock(): void;
  112640. msRequestPointerLock?(): void;
  112641. mozRequestPointerLock?(): void;
  112642. webkitRequestPointerLock?(): void;
  112643. /** Track wether a record is in progress */
  112644. isRecording: boolean;
  112645. /** Capture Stream method defined by some browsers */
  112646. captureStream(fps?: number): MediaStream;
  112647. }
  112648. interface CanvasRenderingContext2D {
  112649. msImageSmoothingEnabled: boolean;
  112650. }
  112651. interface MouseEvent {
  112652. mozMovementX: number;
  112653. mozMovementY: number;
  112654. webkitMovementX: number;
  112655. webkitMovementY: number;
  112656. msMovementX: number;
  112657. msMovementY: number;
  112658. }
  112659. interface Navigator {
  112660. mozGetVRDevices: (any: any) => any;
  112661. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112662. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112663. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112664. webkitGetGamepads(): Gamepad[];
  112665. msGetGamepads(): Gamepad[];
  112666. webkitGamepads(): Gamepad[];
  112667. }
  112668. interface HTMLVideoElement {
  112669. mozSrcObject: any;
  112670. }
  112671. interface Math {
  112672. fround(x: number): number;
  112673. imul(a: number, b: number): number;
  112674. }
  112675. interface WebGLProgram {
  112676. context?: WebGLRenderingContext;
  112677. vertexShader?: WebGLShader;
  112678. fragmentShader?: WebGLShader;
  112679. isParallelCompiled: boolean;
  112680. onCompiled?: () => void;
  112681. }
  112682. interface WebGLRenderingContext {
  112683. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  112684. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  112685. vertexAttribDivisor(index: number, divisor: number): void;
  112686. createVertexArray(): any;
  112687. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  112688. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  112689. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  112690. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  112691. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  112692. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  112693. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  112694. // Queries
  112695. createQuery(): WebGLQuery;
  112696. deleteQuery(query: WebGLQuery): void;
  112697. beginQuery(target: number, query: WebGLQuery): void;
  112698. endQuery(target: number): void;
  112699. getQueryParameter(query: WebGLQuery, pname: number): any;
  112700. getQuery(target: number, pname: number): any;
  112701. MAX_SAMPLES: number;
  112702. RGBA8: number;
  112703. READ_FRAMEBUFFER: number;
  112704. DRAW_FRAMEBUFFER: number;
  112705. UNIFORM_BUFFER: number;
  112706. HALF_FLOAT_OES: number;
  112707. RGBA16F: number;
  112708. RGBA32F: number;
  112709. R32F: number;
  112710. RG32F: number;
  112711. RGB32F: number;
  112712. R16F: number;
  112713. RG16F: number;
  112714. RGB16F: number;
  112715. RED: number;
  112716. RG: number;
  112717. R8: number;
  112718. RG8: number;
  112719. UNSIGNED_INT_24_8: number;
  112720. DEPTH24_STENCIL8: number;
  112721. /* Multiple Render Targets */
  112722. drawBuffers(buffers: number[]): void;
  112723. readBuffer(src: number): void;
  112724. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  112725. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  112726. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  112727. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  112728. // Occlusion Query
  112729. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  112730. ANY_SAMPLES_PASSED: number;
  112731. QUERY_RESULT_AVAILABLE: number;
  112732. QUERY_RESULT: number;
  112733. }
  112734. interface WebGLBuffer {
  112735. references: number;
  112736. capacity: number;
  112737. is32Bits: boolean;
  112738. }
  112739. interface WebGLProgram {
  112740. transformFeedback?: WebGLTransformFeedback | null;
  112741. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  112742. }
  112743. interface EXT_disjoint_timer_query {
  112744. QUERY_COUNTER_BITS_EXT: number;
  112745. TIME_ELAPSED_EXT: number;
  112746. TIMESTAMP_EXT: number;
  112747. GPU_DISJOINT_EXT: number;
  112748. QUERY_RESULT_EXT: number;
  112749. QUERY_RESULT_AVAILABLE_EXT: number;
  112750. queryCounterEXT(query: WebGLQuery, target: number): void;
  112751. createQueryEXT(): WebGLQuery;
  112752. beginQueryEXT(target: number, query: WebGLQuery): void;
  112753. endQueryEXT(target: number): void;
  112754. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  112755. deleteQueryEXT(query: WebGLQuery): void;
  112756. }
  112757. interface WebGLUniformLocation {
  112758. _currentState: any;
  112759. }
  112760. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  112761. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  112762. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  112763. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112764. interface WebGLRenderingContext {
  112765. readonly RASTERIZER_DISCARD: number;
  112766. readonly DEPTH_COMPONENT24: number;
  112767. readonly TEXTURE_3D: number;
  112768. readonly TEXTURE_2D_ARRAY: number;
  112769. readonly TEXTURE_COMPARE_FUNC: number;
  112770. readonly TEXTURE_COMPARE_MODE: number;
  112771. readonly COMPARE_REF_TO_TEXTURE: number;
  112772. readonly TEXTURE_WRAP_R: number;
  112773. readonly HALF_FLOAT: number;
  112774. readonly RGB8: number;
  112775. readonly RED_INTEGER: number;
  112776. readonly RG_INTEGER: number;
  112777. readonly RGB_INTEGER: number;
  112778. readonly RGBA_INTEGER: number;
  112779. readonly R8_SNORM: number;
  112780. readonly RG8_SNORM: number;
  112781. readonly RGB8_SNORM: number;
  112782. readonly RGBA8_SNORM: number;
  112783. readonly R8I: number;
  112784. readonly RG8I: number;
  112785. readonly RGB8I: number;
  112786. readonly RGBA8I: number;
  112787. readonly R8UI: number;
  112788. readonly RG8UI: number;
  112789. readonly RGB8UI: number;
  112790. readonly RGBA8UI: number;
  112791. readonly R16I: number;
  112792. readonly RG16I: number;
  112793. readonly RGB16I: number;
  112794. readonly RGBA16I: number;
  112795. readonly R16UI: number;
  112796. readonly RG16UI: number;
  112797. readonly RGB16UI: number;
  112798. readonly RGBA16UI: number;
  112799. readonly R32I: number;
  112800. readonly RG32I: number;
  112801. readonly RGB32I: number;
  112802. readonly RGBA32I: number;
  112803. readonly R32UI: number;
  112804. readonly RG32UI: number;
  112805. readonly RGB32UI: number;
  112806. readonly RGBA32UI: number;
  112807. readonly RGB10_A2UI: number;
  112808. readonly R11F_G11F_B10F: number;
  112809. readonly RGB9_E5: number;
  112810. readonly RGB10_A2: number;
  112811. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  112812. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  112813. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  112814. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  112815. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  112816. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  112817. 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;
  112818. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  112819. readonly TRANSFORM_FEEDBACK: number;
  112820. readonly INTERLEAVED_ATTRIBS: number;
  112821. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  112822. createTransformFeedback(): WebGLTransformFeedback;
  112823. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  112824. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  112825. beginTransformFeedback(primitiveMode: number): void;
  112826. endTransformFeedback(): void;
  112827. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  112828. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112829. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112830. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112831. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  112832. }
  112833. interface ImageBitmap {
  112834. readonly width: number;
  112835. readonly height: number;
  112836. close(): void;
  112837. }
  112838. interface WebGLQuery extends WebGLObject {
  112839. }
  112840. declare var WebGLQuery: {
  112841. prototype: WebGLQuery;
  112842. new(): WebGLQuery;
  112843. };
  112844. interface WebGLSampler extends WebGLObject {
  112845. }
  112846. declare var WebGLSampler: {
  112847. prototype: WebGLSampler;
  112848. new(): WebGLSampler;
  112849. };
  112850. interface WebGLSync extends WebGLObject {
  112851. }
  112852. declare var WebGLSync: {
  112853. prototype: WebGLSync;
  112854. new(): WebGLSync;
  112855. };
  112856. interface WebGLTransformFeedback extends WebGLObject {
  112857. }
  112858. declare var WebGLTransformFeedback: {
  112859. prototype: WebGLTransformFeedback;
  112860. new(): WebGLTransformFeedback;
  112861. };
  112862. interface WebGLVertexArrayObject extends WebGLObject {
  112863. }
  112864. declare var WebGLVertexArrayObject: {
  112865. prototype: WebGLVertexArrayObject;
  112866. new(): WebGLVertexArrayObject;
  112867. };
  112868. // Type definitions for WebVR API
  112869. // Project: https://w3c.github.io/webvr/
  112870. // Definitions by: six a <https://github.com/lostfictions>
  112871. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112872. interface VRDisplay extends EventTarget {
  112873. /**
  112874. * Dictionary of capabilities describing the VRDisplay.
  112875. */
  112876. readonly capabilities: VRDisplayCapabilities;
  112877. /**
  112878. * z-depth defining the far plane of the eye view frustum
  112879. * enables mapping of values in the render target depth
  112880. * attachment to scene coordinates. Initially set to 10000.0.
  112881. */
  112882. depthFar: number;
  112883. /**
  112884. * z-depth defining the near plane of the eye view frustum
  112885. * enables mapping of values in the render target depth
  112886. * attachment to scene coordinates. Initially set to 0.01.
  112887. */
  112888. depthNear: number;
  112889. /**
  112890. * An identifier for this distinct VRDisplay. Used as an
  112891. * association point in the Gamepad API.
  112892. */
  112893. readonly displayId: number;
  112894. /**
  112895. * A display name, a user-readable name identifying it.
  112896. */
  112897. readonly displayName: string;
  112898. readonly isConnected: boolean;
  112899. readonly isPresenting: boolean;
  112900. /**
  112901. * If this VRDisplay supports room-scale experiences, the optional
  112902. * stage attribute contains details on the room-scale parameters.
  112903. */
  112904. readonly stageParameters: VRStageParameters | null;
  112905. /**
  112906. * Passing the value returned by `requestAnimationFrame` to
  112907. * `cancelAnimationFrame` will unregister the callback.
  112908. * @param handle Define the hanle of the request to cancel
  112909. */
  112910. cancelAnimationFrame(handle: number): void;
  112911. /**
  112912. * Stops presenting to the VRDisplay.
  112913. * @returns a promise to know when it stopped
  112914. */
  112915. exitPresent(): Promise<void>;
  112916. /**
  112917. * Return the current VREyeParameters for the given eye.
  112918. * @param whichEye Define the eye we want the parameter for
  112919. * @returns the eye parameters
  112920. */
  112921. getEyeParameters(whichEye: string): VREyeParameters;
  112922. /**
  112923. * Populates the passed VRFrameData with the information required to render
  112924. * the current frame.
  112925. * @param frameData Define the data structure to populate
  112926. * @returns true if ok otherwise false
  112927. */
  112928. getFrameData(frameData: VRFrameData): boolean;
  112929. /**
  112930. * Get the layers currently being presented.
  112931. * @returns the list of VR layers
  112932. */
  112933. getLayers(): VRLayer[];
  112934. /**
  112935. * Return a VRPose containing the future predicted pose of the VRDisplay
  112936. * when the current frame will be presented. The value returned will not
  112937. * change until JavaScript has returned control to the browser.
  112938. *
  112939. * The VRPose will contain the position, orientation, velocity,
  112940. * and acceleration of each of these properties.
  112941. * @returns the pose object
  112942. */
  112943. getPose(): VRPose;
  112944. /**
  112945. * Return the current instantaneous pose of the VRDisplay, with no
  112946. * prediction applied.
  112947. * @returns the current instantaneous pose
  112948. */
  112949. getImmediatePose(): VRPose;
  112950. /**
  112951. * The callback passed to `requestAnimationFrame` will be called
  112952. * any time a new frame should be rendered. When the VRDisplay is
  112953. * presenting the callback will be called at the native refresh
  112954. * rate of the HMD. When not presenting this function acts
  112955. * identically to how window.requestAnimationFrame acts. Content should
  112956. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112957. * asynchronously from other displays and at differing refresh rates.
  112958. * @param callback Define the eaction to run next frame
  112959. * @returns the request handle it
  112960. */
  112961. requestAnimationFrame(callback: FrameRequestCallback): number;
  112962. /**
  112963. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112964. * Repeat calls while already presenting will update the VRLayers being displayed.
  112965. * @param layers Define the list of layer to present
  112966. * @returns a promise to know when the request has been fulfilled
  112967. */
  112968. requestPresent(layers: VRLayer[]): Promise<void>;
  112969. /**
  112970. * Reset the pose for this display, treating its current position and
  112971. * orientation as the "origin/zero" values. VRPose.position,
  112972. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112973. * updated when calling resetPose(). This should be called in only
  112974. * sitting-space experiences.
  112975. */
  112976. resetPose(): void;
  112977. /**
  112978. * The VRLayer provided to the VRDisplay will be captured and presented
  112979. * in the HMD. Calling this function has the same effect on the source
  112980. * canvas as any other operation that uses its source image, and canvases
  112981. * created without preserveDrawingBuffer set to true will be cleared.
  112982. * @param pose Define the pose to submit
  112983. */
  112984. submitFrame(pose?: VRPose): void;
  112985. }
  112986. declare var VRDisplay: {
  112987. prototype: VRDisplay;
  112988. new(): VRDisplay;
  112989. };
  112990. interface VRLayer {
  112991. leftBounds?: number[] | Float32Array | null;
  112992. rightBounds?: number[] | Float32Array | null;
  112993. source?: HTMLCanvasElement | null;
  112994. }
  112995. interface VRDisplayCapabilities {
  112996. readonly canPresent: boolean;
  112997. readonly hasExternalDisplay: boolean;
  112998. readonly hasOrientation: boolean;
  112999. readonly hasPosition: boolean;
  113000. readonly maxLayers: number;
  113001. }
  113002. interface VREyeParameters {
  113003. /** @deprecated */
  113004. readonly fieldOfView: VRFieldOfView;
  113005. readonly offset: Float32Array;
  113006. readonly renderHeight: number;
  113007. readonly renderWidth: number;
  113008. }
  113009. interface VRFieldOfView {
  113010. readonly downDegrees: number;
  113011. readonly leftDegrees: number;
  113012. readonly rightDegrees: number;
  113013. readonly upDegrees: number;
  113014. }
  113015. interface VRFrameData {
  113016. readonly leftProjectionMatrix: Float32Array;
  113017. readonly leftViewMatrix: Float32Array;
  113018. readonly pose: VRPose;
  113019. readonly rightProjectionMatrix: Float32Array;
  113020. readonly rightViewMatrix: Float32Array;
  113021. readonly timestamp: number;
  113022. }
  113023. interface VRPose {
  113024. readonly angularAcceleration: Float32Array | null;
  113025. readonly angularVelocity: Float32Array | null;
  113026. readonly linearAcceleration: Float32Array | null;
  113027. readonly linearVelocity: Float32Array | null;
  113028. readonly orientation: Float32Array | null;
  113029. readonly position: Float32Array | null;
  113030. readonly timestamp: number;
  113031. }
  113032. interface VRStageParameters {
  113033. sittingToStandingTransform?: Float32Array;
  113034. sizeX?: number;
  113035. sizeY?: number;
  113036. }
  113037. interface Navigator {
  113038. getVRDisplays(): Promise<VRDisplay[]>;
  113039. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  113040. }
  113041. interface Window {
  113042. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  113043. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  113044. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  113045. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  113046. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  113047. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  113048. }
  113049. interface Gamepad {
  113050. readonly displayId: number;
  113051. }
  113052. interface XRDevice {
  113053. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  113054. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  113055. }
  113056. interface XRSession {
  113057. getInputSources(): Array<any>;
  113058. baseLayer: XRWebGLLayer;
  113059. requestFrameOfReference(type: string): Promise<void>;
  113060. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  113061. end(): Promise<void>;
  113062. requestAnimationFrame: Function;
  113063. addEventListener: Function;
  113064. }
  113065. interface XRSessionCreationOptions {
  113066. outputContext?: WebGLRenderingContext | null;
  113067. immersive?: boolean;
  113068. environmentIntegration?: boolean;
  113069. }
  113070. interface XRLayer {
  113071. getViewport: Function;
  113072. framebufferWidth: number;
  113073. framebufferHeight: number;
  113074. }
  113075. interface XRView {
  113076. projectionMatrix: Float32Array;
  113077. }
  113078. interface XRFrame {
  113079. getDevicePose: Function;
  113080. getInputPose: Function;
  113081. views: Array<XRView>;
  113082. baseLayer: XRLayer;
  113083. }
  113084. interface XRFrameOfReference {
  113085. }
  113086. interface XRWebGLLayer extends XRLayer {
  113087. framebuffer: WebGLFramebuffer;
  113088. }
  113089. declare var XRWebGLLayer: {
  113090. prototype: XRWebGLLayer;
  113091. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  113092. };